1+ import json
12import logging
23import tarfile
34import tempfile
@@ -326,52 +327,34 @@ def _wait_for_deployment(
326327 toolkit .print_line ()
327328
328329 toolkit .print (
329- f"You can also check the status at [link]{ check_deployment_url } [/link]" ,
330+ f"You can also check the status at [link= { check_deployment_url } ]{ check_deployment_url } [/link]" ,
330331 )
331332 toolkit .print_line ()
332333
333334 time_elapsed = 0
334335
336+ started_at = time .monotonic ()
337+
338+ last_message_changed_at = time .monotonic ()
339+
335340 with toolkit .progress (
336- "Deploying..." , inline_logs = True , lines_to_show = 20
341+ next ( messages ) , inline_logs = True , lines_to_show = 20
337342 ) as progress :
338343 for line in _stream_build_logs (deployment_id ):
339- import json
344+ time_elapsed = time . monotonic () - started_at
340345
341346 data = json .loads (line )
342347
343348 if "message" in data :
344349 progress .log (Text .from_ansi (data ["message" ].rstrip ()))
345350
346- toolkit .print_line ()
347-
348- with toolkit .progress ("Deploying..." ) as progress :
349- while True :
350- with handle_http_errors (progress ):
351- deployment = _get_deployment (app_id , deployment_id )
352-
353- if deployment .status == DeploymentStatus .success :
354- progress .log (
355- f"🐔 Ready the chicken! Your app is ready at { deployment .url } "
356- )
357- break
358- elif deployment .status == DeploymentStatus .failed :
359- progress .set_error (
360- f"Deployment failed. Please check the logs for more information.\n \n [link={ check_deployment_url } ]{ check_deployment_url } [/link]"
361- )
362-
363- raise typer .Exit (1 )
364- else :
365- message = next (messages )
366- progress .log (
367- f"{ message } ({ DeploymentStatus .to_human_readable (deployment .status )} )"
368- )
351+ if time_elapsed > 10 :
352+ messages = cycle (LONG_WAIT_MESSAGES )
369353
370- time .sleep ( 4 )
371- time_elapsed += 4
354+ if ( time .monotonic () - last_message_changed_at ) > 2 :
355+ progress . title = next ( messages )
372356
373- if time_elapsed == len (WAITING_MESSAGES ) * 4 :
374- messages = cycle (LONG_WAIT_MESSAGES )
357+ last_message_changed_at = time .monotonic ()
375358
376359
377360def _setup_environment_variables (toolkit : RichToolkit , app_id : str ) -> None :
@@ -383,7 +366,9 @@ def _setup_environment_variables(toolkit: RichToolkit, app_id: str) -> None:
383366 env_vars = {}
384367
385368 while True :
386- key = toolkit .input ("Enter the environment variable name: [ENTER to skip]" )
369+ key = toolkit .input (
370+ "Enter the environment variable name: [ENTER to skip]" , required = False
371+ )
387372
388373 if key .strip () == "" :
389374 break
@@ -487,5 +472,5 @@ def deploy(
487472 _wait_for_deployment (toolkit , app .id , deployment .id , check_deployment_url )
488473 else :
489474 toolkit .print (
490- f"Check the status of your deployment at [link]{ check_deployment_url } [/link]"
475+ f"Check the status of your deployment at [link= { check_deployment_url } ]{ check_deployment_url } [/link]"
491476 )
0 commit comments