aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/sky.py
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/scripts/sky.py
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/scripts/sky.py')
-rw-r--r--build/scripts/sky.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/build/scripts/sky.py b/build/scripts/sky.py
new file mode 100644
index 00000000000..b703af7ed1e
--- /dev/null
+++ b/build/scripts/sky.py
@@ -0,0 +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)