diff --git a/src/dragon/wizard.py b/src/dragon/wizard.py index ec58f3d87..87451fd65 100644 --- a/src/dragon/wizard.py +++ b/src/dragon/wizard.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 -import json, os, shutil, ssl, sys, tarfile -from ruyaml import YAML -from urllib import request +import os, shutil, sys from .util import deployable_path @@ -29,20 +27,15 @@ def setup_wizard(): os.chdir(dragon_root_dir) for repo in ('lib', 'include', 'frameworks', 'sdks', 'src'): - try: - get_supporting( - f'https://api.github.com/repos/DragonBuild/{repo}/releases/latest', - repo - ) - except Exception as ex: - log(ex) - log('Potentially ratelimited, attempting fallback by cloning repo (this adds some overhead)') - if os.path.isdir(f'{repo}') and os.path.isdir(f'{repo}/.git'): - os.chdir(f'{repo}') - os.system('git pull origin $(git rev-parse --abbrev-ref HEAD)') - os.chdir(dragon_root_dir) - else: - os.system(f'git clone --depth=1 https://github.com/dragonbuild/{repo}') + if os.path.isdir(f'{repo}') and not os.path.isdir(f'{repo}/.git'): + shutil.rmtree(f'{repo}') + os.system(f'git clone --depth=1 --recursive https://github.com/DragonBuild/{repo}') + elif os.path.isdir(f'{repo}') and os.path.isdir(f'{repo}/.git'): + os.chdir(f'{repo}') + os.system('git pull origin $(git rev-parse --abbrev-ref HEAD)') + os.chdir(dragon_root_dir) + else: + os.system(f'git clone --depth=1 --recursive https://github.com/DragonBuild/{repo}') log('Deploying internal configuration') try: @@ -57,43 +50,6 @@ def setup_wizard(): pass log('Done!') - -def get_supporting(api: str, destination: str): - ctx = ssl.create_default_context() - ctx.check_hostname = False - ctx.verify_mode = ssl.CERT_NONE # python doesn't bundle certs on macOS, so we have to disable SSL :) - response: dict = json.load(request.urlopen(api, context=ctx)) - if os.path.exists(f'{destination}/metadata.yml'): - with open(f'{destination}/metadata.yml', 'r') as fd: - yaml=YAML(typ='safe') # default, if not specfied, is 'rt' (round-trip) - metadata = yaml.load(fd) - version = metadata['version'] - if version == response['tag_name']: - log(f'Latest {destination} already installed') - return - tar_url = response['tarball_url'] - - try: - shutil.rmtree(f'./{destination}') - except FileNotFoundError: - pass - - log(f'Updating supporting {destination} v{response["tag_name"]} from {tar_url} ...') - tar_bytes = request.urlopen(tar_url, context=ctx).read() - - fname = 'tmp.tar.gz' - with open(fname, 'wb') as f: - f.write(tar_bytes) - - tar = tarfile.open(fname) - extracted_name = tar.members[0].name - - log(f'Extracting into {os.environ["DRAGON_ROOT_DIR"] + destination}') - tar.extractall() - os.rename(extracted_name, destination) - os.remove(fname) - - if __name__ == '__main__': setup_wizard() os.system('dragon v')