+ returns the status as a dict for simpler usage from other Python programs

This commit is contained in:
nicobo 2020-05-26 23:15:53 +02:00
parent 207ff6c394
commit 707a881931
No known key found for this signature in database
GPG key ID: 2581E71C5FA5285F
2 changed files with 4 additions and 0 deletions

View file

@ -191,6 +191,8 @@ def run( args=sys.argv[1:] ):
# NOTE ensure_ascii=False + encode('utf-8').decode() is not mandatory but allows printing plain UTF-8 strings rather than \u... or \x... # NOTE ensure_ascii=False + encode('utf-8').decode() is not mandatory but allows printing plain UTF-8 strings rather than \u... or \x...
# NOTE default=repr is mandatory because some objects in the args are not serializable # NOTE default=repr is mandatory because some objects in the args are not serializable
print( json.dumps(status,skipkeys=True,ensure_ascii=False,default=repr).encode('utf-8').decode(), file=sys.stdout, flush=True ) print( json.dumps(status,skipkeys=True,ensure_ascii=False,default=repr).encode('utf-8').decode(), file=sys.stdout, flush=True )
# Still returns the full status for simpler handling in Python
return status
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -694,6 +694,8 @@ def run( args=sys.argv[1:] ):
# NOTE ensure_ascii=False + encode('utf-8').decode() is not mandatory but allows printing plain UTF-8 strings rather than \u... or \x... # NOTE ensure_ascii=False + encode('utf-8').decode() is not mandatory but allows printing plain UTF-8 strings rather than \u... or \x...
# NOTE default=repr is mandatory because some objects in the args are not serializable # NOTE default=repr is mandatory because some objects in the args are not serializable
print( json.dumps(status,skipkeys=True,ensure_ascii=False,default=repr).encode('utf-8').decode(), file=sys.stdout, flush=True ) print( json.dumps(status,skipkeys=True,ensure_ascii=False,default=repr).encode('utf-8').decode(), file=sys.stdout, flush=True )
# Still returns the full status for simpler handling in Python
return status
if __name__ == '__main__': if __name__ == '__main__':