Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def build_url(self):
from ai2thor.build import arch_platform_map
import ai2thor.build
if platform.system() in BUILDS:
return (BUILDS[platform.system()]['url'], BUILDS[platform.system()]['sha256'])
else:
url = None
sha256_build = None
git_dir = os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../.git")
for commit_id in subprocess.check_output('git --git-dir=' + git_dir + ' log -n 10 --format=%H', shell=True).decode('ascii').strip().split("\n"):
arch = arch_platform_map[platform.system()]
try:
u = ai2thor.downloader.commit_build_url(arch, commit_id)
if os.path.isfile(self.executable_path(url=u)):
# don't need sha256 since we aren't going to download
url = u
break
elif ai2thor.downloader.commit_build_exists(arch, commit_id):
sha256_build = ai2thor.downloader.commit_build_sha256(arch, commit_id)
url = u
break
except Exception:
pass
if url is None:
raise Exception("Couldn't find a suitable build url for platform: %s" % platform.system())
# print("Got build for %s: " % (url))
return (BUILDS[platform.system()]['url'], BUILDS[platform.system()]['sha256'])
else:
url = None
sha256_build = None
git_dir = os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../.git")
for commit_id in subprocess.check_output('git --git-dir=' + git_dir + ' log -n 10 --format=%H', shell=True).decode('ascii').strip().split("\n"):
arch = arch_platform_map[platform.system()]
try:
u = ai2thor.downloader.commit_build_url(arch, commit_id)
if os.path.isfile(self.executable_path(url=u)):
# don't need sha256 since we aren't going to download
url = u
break
elif ai2thor.downloader.commit_build_exists(arch, commit_id):
sha256_build = ai2thor.downloader.commit_build_sha256(arch, commit_id)
url = u
break
except Exception:
pass
if url is None:
raise Exception("Couldn't find a suitable build url for platform: %s" % platform.system())
# print("Got build for %s: " % (url))
return (url, sha256_build)
def poll_ci_build(context):
from ai2thor.build import platform_map
import ai2thor.downloader
import time
commit_id = (
subprocess.check_output("git log -n 1 --format=%H", shell=True)
.decode("ascii")
.strip()
)
for i in range(360):
missing = False
for arch in platform_map.keys():
if (i % 5) == 0:
print("checking %s for commit id %s" % (arch, commit_id))
if ai2thor.downloader.commit_build_log_exists(arch, commit_id):
print("log exists %s" % commit_id)
else:
missing = True
if not missing:
break
time.sleep(10)
for arch in platform_map.keys():
if not ai2thor.downloader.commit_build_exists(arch, commit_id):
print(
"Build log url: %s"
% ai2thor.downloader.commit_build_log_url(arch, commit_id)
)
raise Exception("Failed to build %s for commit: %s " % (arch, commit_id))
for arch in platform_map.keys():
if (i % 5) == 0:
print("checking %s for commit id %s" % (arch, commit_id))
if ai2thor.downloader.commit_build_log_exists(arch, commit_id):
print("log exists %s" % commit_id)
else:
missing = True
if not missing:
break
time.sleep(10)
for arch in platform_map.keys():
if not ai2thor.downloader.commit_build_exists(arch, commit_id):
print(
"Build log url: %s"
% ai2thor.downloader.commit_build_log_url(arch, commit_id)
)
raise Exception("Failed to build %s for commit: %s " % (arch, commit_id))