diff options
author | dankolesnikov <dankolesnikov@yandex-team.ru> | 2022-02-10 16:51:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:07 +0300 |
commit | 98174ab8f0e6dbed8894c8226f62cac4bf36171d (patch) | |
tree | 00cab7b3b62da0fe104a2a99c2886064cc0b0d63 /build/scripts/sky.py | |
parent | 2e8363373770594fa3e83f1410d513cff82abb30 (diff) | |
download | ydb-98174ab8f0e6dbed8894c8226f62cac4bf36171d.tar.gz |
Restoring authorship annotation for <dankolesnikov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/scripts/sky.py')
-rw-r--r-- | build/scripts/sky.py | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/build/scripts/sky.py b/build/scripts/sky.py index b703af7ed1e..15e95e76c06 100644 --- a/build/scripts/sky.py +++ b/build/scripts/sky.py @@ -1,43 +1,43 @@ -import logging -import os -import subprocess - -import fetch_from - - -class UnsupportedProtocolException(Exception): - pass - - -def executable_path(): - return "/usr/local/bin/sky" - - -def is_avaliable(): - if not os.path.exists(executable_path()): - return False - try: - subprocess.check_output([executable_path(), "--version"]) - return True - except subprocess.CalledProcessError: - return False - except OSError: - return False - - -def fetch(skynet_id, file_name, timeout=None): - if not is_avaliable(): - raise UnsupportedProtocolException("Skynet is not available") - - target_dir = os.path.abspath(fetch_from.uniq_string_generator()) - os.mkdir(target_dir) - - cmd_args = [executable_path(), "get", "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] - if timeout is not None: - cmd_args += ["--timeout", str(timeout)] - - logging.info("Call skynet with args: %s", cmd_args) - stdout = subprocess.check_output(cmd_args).strip() - logging.debug("Skynet call with args %s is finished, result is %s", cmd_args, stdout) - - return os.path.join(target_dir, file_name) +import logging +import os +import subprocess + +import fetch_from + + +class UnsupportedProtocolException(Exception): + pass + + +def executable_path(): + return "/usr/local/bin/sky" + + +def is_avaliable(): + if not os.path.exists(executable_path()): + return False + try: + subprocess.check_output([executable_path(), "--version"]) + return True + except subprocess.CalledProcessError: + return False + except OSError: + return False + + +def fetch(skynet_id, file_name, timeout=None): + if not is_avaliable(): + raise UnsupportedProtocolException("Skynet is not available") + + target_dir = os.path.abspath(fetch_from.uniq_string_generator()) + os.mkdir(target_dir) + + cmd_args = [executable_path(), "get", "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] + if timeout is not None: + cmd_args += ["--timeout", str(timeout)] + + logging.info("Call skynet with args: %s", cmd_args) + stdout = subprocess.check_output(cmd_args).strip() + logging.debug("Skynet call with args %s is finished, result is %s", cmd_args, stdout) + + return os.path.join(target_dir, file_name) |