This commit is contained in:
Matt Wobensmith 2019-10-09 10:42:06 -07:00 коммит произвёл mwobensmith
Родитель fb033dbec6
Коммит ecb9f062ed
1 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -74,7 +74,6 @@ class _Settings:
DEFAULT_UI_DELAY_SHORT = 0.5
DEFAULT_UI_DELAY_LONG = 2.5
DEFAULT_SYSTEM_DELAY = 5
PACKAGE_ROOT = os.path.realpath(os.path.split(__file__)[0] + "/../..")
def __init__(
self,
@ -97,7 +96,6 @@ class _Settings:
mouse_scroll_step=DEFAULT_MOUSE_SCROLL_STEP,
key_shortcut_delay=DEFAULT_KEY_SHORTCUT_DELAY,
site_load_timeout=DEFAULT_SITE_LOAD_TIMEOUT,
package_root=PACKAGE_ROOT,
):
self.wait_scan_rate = wait_scan_rate
@ -208,6 +206,10 @@ class _Settings:
def virtual_keyboard(self, value):
self._virtual_keyboard = value
@property
def package_root(self):
return os.path.realpath(os.path.split(__file__)[0] + "/../..")
@property
def code_root(self):
return self._code_root
@ -224,10 +226,23 @@ class _Settings:
def get_active_root():
cmd = subprocess.run(
"pipenv --where", shell=True, stdout=subprocess.PIPE, timeout=5
)
return cmd.stdout.decode("utf-8").strip()
"""
Determine location of targets/tests dynamically, using this priority:
1. Set by user via environment variable.
2. Using the Pipfile to locate active project.
3. If neither of the above, default to package root.
"""
try:
return os.environ["IRIS_CODE_ROOT"]
except KeyError:
cmd = subprocess.run(
"pipenv --where", shell=True, stdout=subprocess.PIPE, timeout=5
)
path = cmd.stdout.decode("utf-8").strip()
if os.path.exists(path):
return path
else:
return os.path.realpath(os.path.dirname(__file__) + "/../..")
Settings = _Settings()