Skip to content

Commit 85aee1b

Browse files
authored
Merge pull request #210 from chescales/fix/pull-media-without-remote-id
Fixed bug where pulling media without remote id was not possible.
2 parents 3b44e1a + 8242304 commit 85aee1b

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

divio_cli/cli.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def project_deploy_log(obj, remote_id, stage):
215215
@click.pass_obj
216216
def project_dashboard(obj, remote_id):
217217
"""Open project dashboard"""
218-
click.launch(get_cp_url(obj.client, remote_id))
218+
click.launch(get_cp_url(client=obj.client, project_id=remote_id))
219219

220220

221221
@project.command(name='up')
@@ -310,15 +310,15 @@ def environment_variables(obj, remote_id, stage, show_all_vars,
310310
@click.pass_obj
311311
def project_open_test(obj, remote_id):
312312
"""Open project test site"""
313-
open_project_cloud_site(obj.client, remote_id, 'test')
313+
open_project_cloud_site(obj.client, project_id=remote_id, stage='test')
314314

315315

316316
@project.command(name='live')
317317
@allow_remote_id_override
318318
@click.pass_obj
319319
def project_open_live(obj, remote_id):
320320
"""Open project live site"""
321-
open_project_cloud_site(obj.client, remote_id, 'live')
321+
open_project_cloud_site(obj.client, project_id=remote_id, stage='live')
322322

323323

324324
@project.command(name='status')
@@ -338,7 +338,11 @@ def project_stop():
338338
@click.pass_obj
339339
def project_cheatsheet(obj, remote_id):
340340
"""Show useful commands for your project"""
341-
click.launch(get_cp_url(obj.client, remote_id, 'local-development/'))
341+
click.launch(get_cp_url(
342+
obj.client,
343+
project_id=remote_id,
344+
section='local-development/'),
345+
)
342346

343347

344348
@project.command(name='setup')
@@ -403,7 +407,7 @@ def pull_media(obj, remote_id, stage):
403407
Pull media files from your deployed website. Stage is either
404408
test (default) or live
405409
"""
406-
localdev.pull_media(obj.client, stage, remote_id)
410+
localdev.pull_media(obj.client, stage=stage, remote_id=remote_id)
407411

408412

409413
@project.group(name='push')
@@ -432,13 +436,18 @@ def push_db(obj, remote_id, stage, dumpfile, noinput):
432436
click.secho(messages.PUSH_DB_WARNING.format(stage=stage), fg='red')
433437
if not click.confirm('\nAre you sure you want to continue?'):
434438
return
435-
localdev.push_db(obj.client, stage, remote_id)
439+
localdev.push_db(obj.client, stage=stage, remote_id=remote_id)
436440
else:
437441
if not noinput:
438442
click.secho(messages.PUSH_DB_WARNING.format(stage=stage), fg='red')
439443
if not click.confirm('\nAre you sure you want to continue?'):
440444
return
441-
localdev.push_local_db(obj.client, stage, dumpfile, remote_id)
445+
localdev.push_local_db(
446+
obj.client,
447+
stage=stage,
448+
dump_filename=dumpfile,
449+
website_id=remote_id,
450+
)
442451

443452

444453
@project_push.command(name='media')
@@ -456,7 +465,7 @@ def push_media(obj, remote_id, stage, noinput):
456465
click.secho(messages.PUSH_MEDIA_WARNING.format(stage=stage), fg='red')
457466
if not click.confirm('\nAre you sure you want to continue?'):
458467
return
459-
localdev.push_media(obj.client, stage, remote_id)
468+
localdev.push_media(obj.client, stage=stage, remote_id=remote_id)
460469

461470

462471
@project.group(name='import')

divio_cli/localdev/main.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def setup_website_containers(client, stage, path):
7171

7272
if docker_compose_config.has_service('db'):
7373
has_db_service = True
74-
existing_db_container_id = utils.get_db_container_id(path, False)
74+
existing_db_container_id = utils.get_db_container_id(
75+
path=path,
76+
raise_on_missing=False,
77+
)
7578
else:
7679
has_db_service = False
7780
existing_db_container_id = None
@@ -133,16 +136,16 @@ def del_rw(action, name, exc):
133136
sys.exit(1)
134137

135138
# clone git project
136-
clone_project(website_slug, path)
139+
clone_project(website_slug=website_slug, path=path)
137140

138141
# check for new baseproject + add .aldryn
139-
configure_project(website_slug, path, client)
142+
configure_project(website_slug=website_slug, path=path, client=client)
140143

141144
# setup docker website containers
142-
setup_website_containers(client, stage, path)
145+
setup_website_containers(client=client, stage=stage, path=path)
143146

144147
# download media files
145-
pull_media(client, stage, path)
148+
pull_media(client=client, stage=stage, path=path)
146149

147150
instructions = (
148151
"Your workspace is setup and ready to start.",
@@ -359,7 +362,8 @@ def setup(self):
359362
click.secho(' ---> Preparing download', nl=False)
360363
start_preparation = time()
361364
response = self.client.download_db_request(
362-
self.remote_id, self.stage) or {}
365+
self.remote_id, self.stage,
366+
) or {}
363367
progress_url = response.get('progress_url')
364368
if not progress_url:
365369
click.secho(' error!', fg='red')
@@ -387,10 +391,11 @@ def get_db_restore_command(self):
387391
return cmd.format(self.db_dump_path)
388392

389393

390-
def pull_media(client, stage, remote_id, path=None):
394+
def pull_media(client, stage, remote_id=None, path=None):
391395
project_home = utils.get_project_home(path)
392396
website_id = utils.get_aldryn_project_settings(project_home)['id']
393397
website_slug = utils.get_aldryn_project_settings(project_home)['slug']
398+
remote_id = remote_id or website_id
394399
remote_project_name = (
395400
website_slug if remote_id == website_id
396401
else 'Project {}'.format(remote_id)

0 commit comments

Comments
 (0)