@@ -166,13 +166,12 @@ def login(ctx: Context, username, password) -> None:
166166def logout (ctx ):
167167 """Logout and expire the token."""
168168
169- log ("Log out…" )
170-
171169 payload = ctx .obj ["client" ].logout ()
172170
173171 if ctx .obj ["format_json" ]:
174172 print_json (payload )
175173 else :
174+ log ("Log out…" )
176175 log (payload ["detail" ])
177176
178177
@@ -210,8 +209,6 @@ def status(ctx: Context):
210209def list_projects (ctx : Context , include_public : bool , ** opts ) -> None :
211210 """List QFieldCloud projects."""
212211
213- log ("Listing projects…" )
214-
215212 projects : List [Dict [str , Any ]] = ctx .obj ["client" ].list_projects (
216213 include_public ,
217214 sdk .Pagination (** opts ),
@@ -220,6 +217,7 @@ def list_projects(ctx: Context, include_public: bool, **opts) -> None:
220217 if ctx .obj ["format_json" ]:
221218 print_json (projects )
222219 else :
220+ log ("Listing projects…" )
223221 if projects :
224222 log ("Projects the current user has access to:" )
225223 log (format_project_table (projects ))
@@ -239,13 +237,12 @@ def list_projects(ctx: Context, include_public: bool, **opts) -> None:
239237def list_files (ctx : Context , project_id , skip_metadata ):
240238 """List QFieldCloud project files."""
241239
242- log (f'Getting file list for "{ project_id } "…' )
243-
244240 files = ctx .obj ["client" ].list_remote_files (project_id , skip_metadata )
245241
246242 if ctx .obj ["format_json" ]:
247243 print_json (files )
248244 else :
245+ log (f'Getting file list for "{ project_id } "…' )
249246 if files :
250247 log (f'Files for project "{ project_id } ":' )
251248 for file in files :
@@ -269,15 +266,14 @@ def list_files(ctx: Context, project_id, skip_metadata):
269266def create_project (ctx : Context , name , owner , description , is_public ):
270267 """Creates a new empty QFieldCloud project."""
271268
272- log ("Creating project {}…" .format (f"{ owner } /{ name } " if owner else name ))
273-
274269 project = ctx .obj ["client" ].create_project (
275270 name , owner , description = description , is_public = is_public
276271 )
277272
278273 if ctx .obj ["format_json" ]:
279274 print_json (project )
280275 else :
276+ log ("Creating project {}…" .format (f"{ owner } /{ name } " if owner else name ))
281277 log ("Created project:" )
282278 log (format_project_table ([project ]))
283279
@@ -288,14 +284,13 @@ def create_project(ctx: Context, name, owner, description, is_public):
288284def delete_project (ctx : Context , project_id ):
289285 """Deletes a QFieldCloud project."""
290286
291- log (f'Deleting project "{ project_id } "…' )
292-
293287 payload = ctx .obj ["client" ].delete_project (project_id )
294288
295289 if ctx .obj ["format_json" ]:
296290 # print_json(payload)
297291 print (payload , payload .content )
298292 else :
293+ log (f'Deleting project "{ project_id } "…' )
299294 log (f'Deleted project "{ project_id } ".' )
300295
301296
@@ -315,8 +310,6 @@ def delete_project(ctx: Context, project_id):
315310def upload_files (ctx : Context , project_id , project_path , filter_glob , throw_on_error ):
316311 """Upload files to a QFieldCloud project."""
317312
318- log (f'Uploading files "{ project_id } " from { project_path } …' )
319-
320313 files = ctx .obj ["client" ].upload_files (
321314 project_id ,
322315 sdk .FileTransferType .PROJECT ,
@@ -329,6 +322,7 @@ def upload_files(ctx: Context, project_id, project_path, filter_glob, throw_on_e
329322 if ctx .obj ["format_json" ]:
330323 print_json (files )
331324 else :
325+ log (f'Uploading files "{ project_id } " from { project_path } …' )
332326 if files :
333327 log (f"Upload finished after uploading { len (files )} ." )
334328 for file in files :
@@ -360,8 +354,6 @@ def download_files(
360354):
361355 """Download QFieldCloud project files."""
362356
363- log (f'Downloading project "{ project_id } " files to { local_dir } …' )
364-
365357 files = ctx .obj ["client" ].download_project (
366358 project_id ,
367359 local_dir ,
@@ -374,6 +366,7 @@ def download_files(
374366 if ctx .obj ["format_json" ]:
375367 print_json (files )
376368 else :
369+ log (f'Downloading project "{ project_id } " files to { local_dir } …' )
377370 if files :
378371 count = 0
379372 for file in files :
@@ -442,12 +435,12 @@ def patch_project(
442435def delete_files (ctx : Context , project_id , paths , throw_on_error ):
443436 """Delete QFieldCloud project files."""
444437
445- log (f'Deleting project "{ project_id } " files…' )
446-
447438 paths_result = ctx .obj ["client" ].delete_files (project_id , paths , throw_on_error )
448439
449440 if ctx .obj ["format_json" ]:
450441 print_json (paths_result )
442+ else :
443+ log (f'Deleting project "{ project_id } " files…' )
451444
452445
453446@cli .command ()
@@ -463,8 +456,6 @@ def delete_files(ctx: Context, project_id, paths, throw_on_error):
463456def list_jobs (ctx : Context , project_id , job_type : Optional [sdk .JobTypes ], ** opts ):
464457 """List project jobs."""
465458
466- log (f'Listing project "{ project_id } " jobs…' )
467-
468459 jobs : List [Dict ] = ctx .obj ["client" ].list_jobs (
469460 project_id ,
470461 job_type ,
@@ -474,6 +465,7 @@ def list_jobs(ctx: Context, project_id, job_type: Optional[sdk.JobTypes], **opts
474465 if ctx .obj ["format_json" ]:
475466 print_json (jobs )
476467 else :
468+ log (f'Listing project "{ project_id } " jobs…' )
477469 for job in jobs :
478470 log (
479471 f'Job "{ job ["id" ]} " of project "{ project_id } " is of type "{ job ["type" ]} " and has status "{ job ["status" ]} ".'
@@ -492,13 +484,12 @@ def list_jobs(ctx: Context, project_id, job_type: Optional[sdk.JobTypes], **opts
492484def job_trigger (ctx : Context , project_id , job_type , force ):
493485 """Triggers a new job."""
494486
495- log (f'Triggering "{ job_type } " job for project "{ project_id } "…' )
496-
497487 status = ctx .obj ["client" ].job_trigger (project_id , job_type , force )
498488
499489 if ctx .obj ["format_json" ]:
500490 print_json (status )
501491 else :
492+ log (f'Triggering "{ job_type } " job for project "{ project_id } "…' )
502493 log (
503494 f'Job of type "{ job_type } " triggered for project "{ project_id } ": { status ["id" ]} '
504495 )
@@ -510,13 +501,12 @@ def job_trigger(ctx: Context, project_id, job_type, force):
510501def job_status (ctx : Context , job_id ):
511502 """Get job status."""
512503
513- log (f'Getting job "{ job_id } " status…' )
514-
515504 status = ctx .obj ["client" ].job_status (job_id )
516505
517506 if ctx .obj ["format_json" ]:
518507 print_json (status )
519508 else :
509+ log (f'Getting job "{ job_id } " status…' )
520510 log (f'Job status for { job_id } : { status ["status" ]} ' )
521511
522512
@@ -526,13 +516,13 @@ def job_status(ctx: Context, job_id):
526516@click .pass_context
527517def delta_push (ctx : Context , project_id : str , delta_filename : str ) -> None :
528518 """Push a delta file to a project with PROJECT_ID."""
529- log (f'Pushing delta file "{ delta_filename } " to project "{ project_id } "…' )
530519
531520 response = ctx .obj ["client" ].push_delta (project_id , delta_filename )
532521
533522 if ctx .obj ["format_json" ]:
534523 print_json (response )
535524 else :
525+ log (f'Pushing delta file "{ delta_filename } " to project "{ project_id } "…' )
536526 log (f'Delta file "{ delta_filename } " pushed to project "{ project_id } ".' )
537527
538528
@@ -542,13 +532,12 @@ def delta_push(ctx: Context, project_id: str, delta_filename: str) -> None:
542532def package_latest (ctx : Context , project_id ):
543533 """Check project packaging status."""
544534
545- log (f'Getting the latest project "{ project_id } " package info…' )
546-
547535 status = ctx .obj ["client" ].package_latest (project_id )
548536
549537 if ctx .obj ["format_json" ]:
550538 print_json (status )
551539 else :
540+ log (f'Getting the latest project "{ project_id } " package info…' )
552541 log (f'Packaging status for { project_id } : { status ["status" ]} ' )
553542 if status ["layers" ] is None :
554543 if status ["status" ] == "failed" :
@@ -589,8 +578,6 @@ def package_download(
589578):
590579 """Download packaged QFieldCloud project files."""
591580
592- log (f'Downloading the latest project "{ project_id } " package files to { local_dir } …' )
593-
594581 files = ctx .obj ["client" ].package_download (
595582 project_id ,
596583 local_dir ,
@@ -603,6 +590,9 @@ def package_download(
603590 if ctx .obj ["format_json" ]:
604591 print_json (files )
605592 else :
593+ log (
594+ f'Downloading the latest project "{ project_id } " package files to { local_dir } …'
595+ )
606596 if files :
607597 log (f"Download status of packaged files in project { project_id } :" )
608598 for file in files :
0 commit comments