Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
S2-group
GitHub Repository: S2-group/android-runner
Path: blob/master/AndroidRunner/Tests.py
629 views
1
import logging
2
3
from .util import ConfigError
4
5
def is_integer(number, minimum=0):
6
if not isinstance(number, int):
7
raise ConfigError('%s is not an integer' % number)
8
if number < minimum:
9
raise ConfigError('%s should be equal or larger than %i' % (number, minimum))
10
return number
11
12
13
def is_string(string):
14
if not isinstance(string, str):
15
raise ConfigError('String expected, got %s' % type(string))
16
return string
17
18
19
def check_dependencies(devices, dependencies):
20
for device in devices:
21
installed_apps = device.is_installed(dependencies)
22
not_installed_apps = [name for name, installed in list(installed_apps.items()) if not installed]
23
if not_installed_apps:
24
for name in not_installed_apps:
25
logging.error('%s: Required package %s is not installed' % (device.id, name))
26
raise ConfigError('Required packages %s are not installed on device %s' % (not_installed_apps, device.id))
27
28
def is_valid_option(cmd, valid_options):
29
if cmd:
30
match = [x for x in valid_options if x == cmd]
31
if len(match) != 1:
32
raise ConfigError("'%s' not recognized. Use one of: %s" % (cmd, valid_options))
33
return cmd
34
35