Use 'Chip.logger' objects to print information from the client script.
@@ -15,6 +15,7 @@ import os
import shutil
import subprocess
import sys
+import time
###################################
def get_base_url(chip):
@@ -154,6 +155,9 @@ async def remote_run(chip, stage):
'''
+ # Time how long the process has been running for.
+ step_start = time.monotonic()
+
# Ask the remote server to start processing the requested step.
chip.cfg['start']['value'] = [stage]
chip.cfg['stop']['value'] = [stage]
@@ -162,7 +166,9 @@ async def remote_run(chip, stage):
# Check the job's progress periodically until it finishes.
is_busy = True
while is_busy:
- print("%s stage running. Please wait."%stage)
+ chip.logger.info("%s stage running. (%d seconds)"%(
+ stage,
+ int(time.monotonic() - step_start)))
await asyncio.sleep(3)
try:
is_busy = await is_job_busy(chip, stage)
@@ -171,8 +177,8 @@ async def remote_run(chip, stage):
# reach the server due to a transient network issue.
# Retrying ensures that jobs don't break off when the connection drops.
is_busy = True
- print("Unknown error encountered: retrying.")
- print("%s stage completed!"%stage)
+ chip.logger.info("Unknown network error encountered: retrying.")
+ chip.logger.info("%s stage completed!"%stage)
###################################
async def request_remote_run(chip, stage):
@@ -213,7 +219,7 @@ async def request_remote_run(chip, stage):
if resp.status == 302:
redirect_url = resp.headers['Location']
else:
- print(await resp.text())
+ chip.logger.info(await resp.text())
return
###################################
@@ -391,11 +397,11 @@ async def upload_import_dir(chip):
if resp.status == 302:
redirect_url = resp.headers['Location']
elif resp.status >= 400:
- print(await resp.text())
- print('Error importing project data; quitting.')
+ chip.logger.info(await resp.text())
+ chip.logger.error('Error importing project data; quitting.')
sys.exit(1)
else:
- print(await resp.text())
+ chip.logger.info(await resp.text())
return
###################################
