@@ -126,7 +126,7 @@ def cli(
126126
127127 qfieldcloud-cli login user pass
128128
129- qfieldcloud-cli -u user -p pass -U https://localhost /api/v1/ list-projects
129+ qfieldcloud-cli -u user -p pass -U https://app.qfield.cloud /api/v1/ list-projects
130130 """
131131 ctx .ensure_object (dict )
132132 ctx .obj ["client" ] = sdk .Client (url , verify_ssl , token = token )
@@ -143,13 +143,12 @@ def cli(
143143def login (ctx : Context , username , password ) -> None :
144144 """Login to QFieldCloud."""
145145
146- log (f"Log in { username } …" )
147-
148146 user_data = ctx .obj ["client" ].login (username , password )
149147
150148 if ctx .obj ["format_json" ]:
151149 print_json (user_data )
152150 else :
151+ log (f"Log in { username } …" )
153152 log (f'Welcome to QFieldCloud, { user_data ["username" ]} .' )
154153 log (
155154 "QFieldCloud has generated a secret token to identify you. "
@@ -167,13 +166,12 @@ def login(ctx: Context, username, password) -> None:
167166def logout (ctx ):
168167 """Logout and expire the token."""
169168
170- log ("Log out…" )
171-
172169 payload = ctx .obj ["client" ].logout ()
173170
174171 if ctx .obj ["format_json" ]:
175172 print_json (payload )
176173 else :
174+ log ("Log out…" )
177175 log (payload ["detail" ])
178176
179177
@@ -211,8 +209,6 @@ def status(ctx: Context):
211209def list_projects (ctx : Context , include_public : bool , ** opts ) -> None :
212210 """List QFieldCloud projects."""
213211
214- log ("Listing projects…" )
215-
216212 projects : List [Dict [str , Any ]] = ctx .obj ["client" ].list_projects (
217213 include_public ,
218214 sdk .Pagination (** opts ),
@@ -221,6 +217,7 @@ def list_projects(ctx: Context, include_public: bool, **opts) -> None:
221217 if ctx .obj ["format_json" ]:
222218 print_json (projects )
223219 else :
220+ log ("Listing projects…" )
224221 if projects :
225222 log ("Projects the current user has access to:" )
226223 log (format_project_table (projects ))
@@ -240,13 +237,12 @@ def list_projects(ctx: Context, include_public: bool, **opts) -> None:
240237def list_files (ctx : Context , project_id , skip_metadata ):
241238 """List QFieldCloud project files."""
242239
243- log (f'Getting file list for "{ project_id } "…' )
244-
245240 files = ctx .obj ["client" ].list_remote_files (project_id , skip_metadata )
246241
247242 if ctx .obj ["format_json" ]:
248243 print_json (files )
249244 else :
245+ log (f'Getting file list for "{ project_id } "…' )
250246 if files :
251247 log (f'Files for project "{ project_id } ":' )
252248 for file in files :
@@ -270,15 +266,14 @@ def list_files(ctx: Context, project_id, skip_metadata):
270266def create_project (ctx : Context , name , owner , description , is_public ):
271267 """Creates a new empty QFieldCloud project."""
272268
273- log ("Creating project {}…" .format (f"{ owner } /{ name } " if owner else name ))
274-
275269 project = ctx .obj ["client" ].create_project (
276270 name , owner , description = description , is_public = is_public
277271 )
278272
279273 if ctx .obj ["format_json" ]:
280274 print_json (project )
281275 else :
276+ log ("Creating project {}…" .format (f"{ owner } /{ name } " if owner else name ))
282277 log ("Created project:" )
283278 log (format_project_table ([project ]))
284279
@@ -289,14 +284,13 @@ def create_project(ctx: Context, name, owner, description, is_public):
289284def delete_project (ctx : Context , project_id ):
290285 """Deletes a QFieldCloud project."""
291286
292- log (f'Deleting project "{ project_id } "…' )
293-
294287 payload = ctx .obj ["client" ].delete_project (project_id )
295288
296289 if ctx .obj ["format_json" ]:
297290 # print_json(payload)
298291 print (payload , payload .content )
299292 else :
293+ log (f'Deleting project "{ project_id } "…' )
300294 log (f'Deleted project "{ project_id } ".' )
301295
302296
@@ -316,8 +310,6 @@ def delete_project(ctx: Context, project_id):
316310def upload_files (ctx : Context , project_id , project_path , filter_glob , throw_on_error ):
317311 """Upload files to a QFieldCloud project."""
318312
319- log (f'Uploading files "{ project_id } " from { project_path } …' )
320-
321313 files = ctx .obj ["client" ].upload_files (
322314 project_id ,
323315 sdk .FileTransferType .PROJECT ,
@@ -330,6 +322,7 @@ def upload_files(ctx: Context, project_id, project_path, filter_glob, throw_on_e
330322 if ctx .obj ["format_json" ]:
331323 print_json (files )
332324 else :
325+ log (f'Uploading files "{ project_id } " from { project_path } …' )
333326 if files :
334327 log (f"Upload finished after uploading { len (files )} ." )
335328 for file in files :
@@ -361,8 +354,6 @@ def download_files(
361354):
362355 """Download QFieldCloud project files."""
363356
364- log (f'Downloading project "{ project_id } " files to { local_dir } …' )
365-
366357 files = ctx .obj ["client" ].download_project (
367358 project_id ,
368359 local_dir ,
@@ -375,6 +366,7 @@ def download_files(
375366 if ctx .obj ["format_json" ]:
376367 print_json (files )
377368 else :
369+ log (f'Downloading project "{ project_id } " files to { local_dir } …' )
378370 if files :
379371 count = 0
380372 for file in files :
@@ -443,12 +435,12 @@ def patch_project(
443435def delete_files (ctx : Context , project_id , paths , throw_on_error ):
444436 """Delete QFieldCloud project files."""
445437
446- log (f'Deleting project "{ project_id } " files…' )
447-
448438 paths_result = ctx .obj ["client" ].delete_files (project_id , paths , throw_on_error )
449439
450440 if ctx .obj ["format_json" ]:
451441 print_json (paths_result )
442+ else :
443+ log (f'Deleting project "{ project_id } " files…' )
452444
453445
454446@cli .command ()
@@ -464,8 +456,6 @@ def delete_files(ctx: Context, project_id, paths, throw_on_error):
464456def list_jobs (ctx : Context , project_id , job_type : Optional [sdk .JobTypes ], ** opts ):
465457 """List project jobs."""
466458
467- log (f'Listing project "{ project_id } " jobs…' )
468-
469459 jobs : List [Dict ] = ctx .obj ["client" ].list_jobs (
470460 project_id ,
471461 job_type ,
@@ -475,6 +465,7 @@ def list_jobs(ctx: Context, project_id, job_type: Optional[sdk.JobTypes], **opts
475465 if ctx .obj ["format_json" ]:
476466 print_json (jobs )
477467 else :
468+ log (f'Listing project "{ project_id } " jobs…' )
478469 for job in jobs :
479470 log (
480471 f'Job "{ job ["id" ]} " of project "{ project_id } " is of type "{ job ["type" ]} " and has status "{ job ["status" ]} ".'
@@ -493,13 +484,12 @@ def list_jobs(ctx: Context, project_id, job_type: Optional[sdk.JobTypes], **opts
493484def job_trigger (ctx : Context , project_id , job_type , force ):
494485 """Triggers a new job."""
495486
496- log (f'Triggering "{ job_type } " job for project "{ project_id } "…' )
497-
498487 status = ctx .obj ["client" ].job_trigger (project_id , job_type , force )
499488
500489 if ctx .obj ["format_json" ]:
501490 print_json (status )
502491 else :
492+ log (f'Triggering "{ job_type } " job for project "{ project_id } "…' )
503493 log (
504494 f'Job of type "{ job_type } " triggered for project "{ project_id } ": { status ["id" ]} '
505495 )
@@ -511,13 +501,12 @@ def job_trigger(ctx: Context, project_id, job_type, force):
511501def job_status (ctx : Context , job_id ):
512502 """Get job status."""
513503
514- log (f'Getting job "{ job_id } " status…' )
515-
516504 status = ctx .obj ["client" ].job_status (job_id )
517505
518506 if ctx .obj ["format_json" ]:
519507 print_json (status )
520508 else :
509+ log (f'Getting job "{ job_id } " status…' )
521510 log (f'Job status for { job_id } : { status ["status" ]} ' )
522511
523512
@@ -527,13 +516,13 @@ def job_status(ctx: Context, job_id):
527516@click .pass_context
528517def delta_push (ctx : Context , project_id : str , delta_filename : str ) -> None :
529518 """Push a delta file to a project with PROJECT_ID."""
530- log (f'Pushing delta file "{ delta_filename } " to project "{ project_id } "…' )
531519
532520 response = ctx .obj ["client" ].push_delta (project_id , delta_filename )
533521
534522 if ctx .obj ["format_json" ]:
535523 print_json (response )
536524 else :
525+ log (f'Pushing delta file "{ delta_filename } " to project "{ project_id } "…' )
537526 log (f'Delta file "{ delta_filename } " pushed to project "{ project_id } ".' )
538527
539528
@@ -543,13 +532,12 @@ def delta_push(ctx: Context, project_id: str, delta_filename: str) -> None:
543532def package_latest (ctx : Context , project_id ):
544533 """Check project packaging status."""
545534
546- log (f'Getting the latest project "{ project_id } " package info…' )
547-
548535 status = ctx .obj ["client" ].package_latest (project_id )
549536
550537 if ctx .obj ["format_json" ]:
551538 print_json (status )
552539 else :
540+ log (f'Getting the latest project "{ project_id } " package info…' )
553541 log (f'Packaging status for { project_id } : { status ["status" ]} ' )
554542 if status ["layers" ] is None :
555543 if status ["status" ] == "failed" :
@@ -590,8 +578,6 @@ def package_download(
590578):
591579 """Download packaged QFieldCloud project files."""
592580
593- log (f'Downloading the latest project "{ project_id } " package files to { local_dir } …' )
594-
595581 files = ctx .obj ["client" ].package_download (
596582 project_id ,
597583 local_dir ,
@@ -604,6 +590,9 @@ def package_download(
604590 if ctx .obj ["format_json" ]:
605591 print_json (files )
606592 else :
593+ log (
594+ f'Downloading the latest project "{ project_id } " package files to { local_dir } …'
595+ )
607596 if files :
608597 log (f"Download status of packaged files in project { project_id } :" )
609598 for file in files :
0 commit comments