Skip to content

Commit

Permalink
Fix template download
Browse files Browse the repository at this point in the history
  • Loading branch information
blythed committed Nov 13, 2024
1 parent 9eecc89 commit b6014a5
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions superduper/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,33 +107,37 @@ def bootstrap(
import subprocess

logging.info('Downloading remote template...')
file_name = template.split('/')[-1]
dir_name = file_name[:-4]
subprocess.run(['curl', '-O', '-k', template])
template = template.split('/')[-1]
subprocess.run(['unzip', '-o', file_name, '-d', dir_name])
template = dir_name

if destination is not None:
if os.path.exists(template):
template_directory = template
else:
root = os.path.dirname(os.path.dirname(__file__))
template_directory = os.path.join(root, f'templates/{template}')
print(template_directory)
import shutil

shutil.copytree(template_directory, destination)
return

if template in existing:
logging.warn(f'Template {template} already exists')

logging.info(f'Applying template: {template} from inbuilt')
if os.path.exists(template):
if destination is not None:
import shutil
shutil.copytree(template, destination)
return
tem = Template.read(template)

else:
tem = getattr(inbuilt, template)
if os.path.exists(destination):
tem = getattr(inbuilt, template)
tem.export(destination)
return

if tem.identifier in existing:
logging.warn(f'Template {tem.identifier} already exists')
logging.warn('Aborting...')
return

logging.info(f'Installating template: {template}')

if tem.requirements and pip_install:
with open('/tmp/requirements.txt', 'w') as f:
f.write('\n'.join(tem.requirements))
subprocess.run(['pip', 'install', '-r', '/tmp/requirements.txt'])

db.apply(tem)


Expand Down

0 comments on commit b6014a5

Please sign in to comment.