Loading...
Searching...
No Matches
lomiri Namespace Reference

## Namespaces

namespace | shell
namespace | application_lifecycle
namespace | sensors

## Classes

class | LomiriException

## Functions

| running_installed_tests ()
| get_lib_path ()
| get_default_extra_mock_libraries ()
| get_mocks_library_path ()
| get_binary_path (binary="lomiri")
| get_data_dirs (data_dirs_mock_enabled=True)
| _get_full_mock_data_path ()
| _get_xdg_env_path ()
| _get_xdg_upstart_env ()
| get_grid_size ()

## Detailed Description

    lomiri autopilot tests and helpers - top level package.

## Function Documentation

## _get_full_mock_data_path()

lomiri._get_full_mock_data_path | ( |  | ) |

protected

Definition at line 111 of file __init__.py.

def _get_full_mock_data_path():
if running_installed_tests():
data_path = "/usr/share/lomiri/mocks/data"
else:
data_path = "../../mocks/data"
return os.path.abspath(
os.path.join(
os.path.dirname(__file__),
data_path
)
)

## _get_xdg_env_path()

lomiri._get_xdg_env_path | ( |  | ) |

protected

Definition at line 124 of file __init__.py.

def _get_xdg_env_path():
path = os.getenv("XDG_DATA_DIRS")
if path is None:
path = _get_xdg_upstart_env()
return path

## _get_xdg_upstart_env()

lomiri._get_xdg_upstart_env | ( |  | ) |

protected

Definition at line 131 of file __init__.py.

def _get_xdg_upstart_env():
try:
return subprocess.check_output([
"/sbin/initctl",
"get-env",
"--global",
"XDG_DATA_DIRS"
], universal_newlines=True).rstrip()
except subprocess.CalledProcessError:
return None

## get_binary_path()

lomiri.get_binary_path | ( |  | binary = "lomiri" | ) |

    Return the path to the specified binary.

Definition at line 79 of file __init__.py.

def get_binary_path(binary="lomiri"):
"""Return the path to the specified binary."""
binary_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"../../../builddir/install/bin/%s" % binary
)
)
if not os.path.exists(binary_path):
try:
binary_path = subprocess.check_output(
['which', binary],
universal_newlines=True,
).strip()
except subprocess.CalledProcessError as e:
raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
return binary_path

## get_data_dirs()

lomiri.get_data_dirs | ( |  | data_dirs_mock_enabled = True | ) |

    Prepend a mock data path to XDG_DATA_DIRS.

Definition at line 98 of file __init__.py.

def get_data_dirs(data_dirs_mock_enabled=True):
"""Prepend a mock data path to XDG_DATA_DIRS."""
data_dirs = _get_xdg_env_path()
if data_dirs_mock_enabled:
mock_data_path = _get_full_mock_data_path()
if os.path.exists(mock_data_path):
if data_dirs is not None:
data_dirs = '{0}:{1}'.format(mock_data_path, data_dirs)
else:
data_dirs = mock_data_path
return data_dirs

## get_default_extra_mock_libraries()

lomiri.get_default_extra_mock_libraries | ( |  | ) |

Definition at line 50 of file __init__.py.

def get_default_extra_mock_libraries():
mocks_path = get_mocks_library_path()
return os.path.join(mocks_path, 'libusermetrics')

## get_grid_size()

lomiri.get_grid_size | ( |  | ) |

Definition at line 143 of file __init__.py.

def get_grid_size():
grid_size = os.getenv('GRID_UNIT_PX')
if grid_size is None:
raise RuntimeError(
"Environment variable GRID_UNIT_PX has not been set."
)
return int(grid_size)

## get_lib_path()

lomiri.get_lib_path | ( |  | ) |

    Return the library path to use in this test run.

Definition at line 36 of file __init__.py.

def get_lib_path():
"""Return the library path to use in this test run."""
if running_installed_tests():
lib_path = os.path.join(
"/usr/lib/",
sysconfig.get_config_var('MULTIARCH'),
"lomiri"
)
else:
binary_path = get_binary_path()
lib_path = os.path.dirname(binary_path)
return lib_path

## get_mocks_library_path()

lomiri.get_mocks_library_path | ( |  | ) |

Definition at line 55 of file __init__.py.

def get_mocks_library_path():
if running_installed_tests():
mock_path = "qml/mocks/"
else:
mock_path = os.path.join(
"../lib/",
sysconfig.get_config_var('MULTIARCH'),
"lomiri/qml/mocks/"
)
lib_path = get_lib_path()
ld_library_path = os.path.abspath(
os.path.join(
lib_path,
mock_path,
)
)
if not os.path.exists(ld_library_path):
raise RuntimeError(
"Expected library path does not exists: %s." % (ld_library_path)
)
return ld_library_path

## running_installed_tests()

lomiri.running_installed_tests | ( |  | ) |

Definition at line 31 of file __init__.py.

def running_installed_tests():
binary_path = get_binary_path()
return binary_path.startswith('/usr')