better logging

This commit is contained in:
JerryXiao 2019-09-08 11:45:26 +08:00
parent b96164fe93
commit f23d480acb
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA

View file

@ -500,23 +500,33 @@ updmgr = updateManager()
def info(): def info(retf='human'):
ret = str(jobsmgr) if retf == 'pkgconfigs':
ret += '\nhuman-readable:\n' ret = jobsmgr.pkgconfigs
ret += "".join([f"{k} = {jobsmgr.jobs[k]}\n" for k in jobsmgr.jobs]) elif retf == 'jobsmgr':
ret += f"idle: {jobsmgr.idle}" ret = jobsmgr
else:
# retf = 'human'
ret = str(jobsmgr)
ret += '\nhuman-readable:\n'
ret += "".join([f"{k} = {jobsmgr.jobs[k]}\n" for k in jobsmgr.jobs])
ret += f"idle: {jobsmgr.idle}"
return ret return ret
def rebuild_package(pkgdirname, clean=False): def rebuild_package(pkgdirname, clean=False):
logger.info(f'rebuild command accecpted for {pkgdirname}')
return jobsmgr.rebuild_package(pkgdirname, clean=clean) return jobsmgr.rebuild_package(pkgdirname, clean=clean)
def clean(pkgdirname): def clean(pkgdirname):
logger.info(f'clean command accecpted for {pkgdirname}')
return jobsmgr.reset_dir(pkgdirname=pkgdirname) return jobsmgr.reset_dir(pkgdirname=pkgdirname)
def clean_all(): def clean_all():
logger.info('clean command accecpted for all')
return jobsmgr.reset_dir(all=True) return jobsmgr.reset_dir(all=True)
def force_upload(pkgdirname, overwrite=False): def force_upload(pkgdirname, overwrite=False):
logger.info(f'force_upload command accecpted for {pkgdirname}')
return jobsmgr.force_upload_package(pkgdirname, overwrite=overwrite) return jobsmgr.force_upload_package(pkgdirname, overwrite=overwrite)
def getup(): def getup():
@ -527,7 +537,7 @@ def run(funcname, args=list(), kwargs=dict()):
'force_upload', 'getup'): 'force_upload', 'getup'):
logger.debug('running: %s %s %s',funcname, args, kwargs) logger.debug('running: %s %s %s',funcname, args, kwargs)
ret = eval(funcname)(*args, **kwargs) ret = eval(funcname)(*args, **kwargs)
logger.info('done: %s %s %s',funcname, args, kwargs) logger.debug('run: done: %s %s %s',funcname, args, kwargs)
return ret return ret
else: else:
logger.error('unexpected: %s %s %s',funcname, args, kwargs) logger.error('unexpected: %s %s %s',funcname, args, kwargs)
@ -544,7 +554,6 @@ def __main():
if type(myrecv) is list and len(myrecv) == 3: if type(myrecv) is list and len(myrecv) == 3:
(funcname, args, kwargs) = myrecv (funcname, args, kwargs) = myrecv
funcname = str(funcname) funcname = str(funcname)
logger.debug('running: %s %s %s', funcname, args, kwargs)
conn.send(run(funcname, args=args, kwargs=kwargs)) conn.send(run(funcname, args=args, kwargs=kwargs))
except Exception: except Exception:
print_exc_plus() print_exc_plus()