Clean lazytox script (#48583)

This commit is contained in:
Martin Hjelmare 2021-04-01 20:34:01 +02:00 committed by GitHub
parent 125161df6b
commit c9cd6b0fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,13 +32,14 @@ def printc(the_color, *args):
return return
try: try:
print(escape_codes[the_color] + msg + escape_codes["reset"]) print(escape_codes[the_color] + msg + escape_codes["reset"])
except KeyError: except KeyError as err:
print(msg) print(msg)
raise ValueError(f"Invalid color {the_color}") raise ValueError(f"Invalid color {the_color}") from err
def validate_requirements_ok(): def validate_requirements_ok():
"""Validate requirements, returns True of ok.""" """Validate requirements, returns True of ok."""
# pylint: disable=import-error,import-outside-toplevel
from gen_requirements_all import main as req_main from gen_requirements_all import main as req_main
return req_main(True) == 0 return req_main(True) == 0
@ -67,7 +68,6 @@ async def async_exec(*args, display=False):
printc("cyan", *argsp) printc("cyan", *argsp)
try: try:
kwargs = { kwargs = {
"loop": LOOP,
"stdout": asyncio.subprocess.PIPE, "stdout": asyncio.subprocess.PIPE,
"stderr": asyncio.subprocess.STDOUT, "stderr": asyncio.subprocess.STDOUT,
} }
@ -232,15 +232,7 @@ async def main():
if __name__ == "__main__": if __name__ == "__main__":
LOOP = (
asyncio.ProactorEventLoop()
if sys.platform == "win32"
else asyncio.get_event_loop()
)
try: try:
LOOP.run_until_complete(main()) asyncio.run(main())
except (FileNotFoundError, KeyboardInterrupt): except (FileNotFoundError, KeyboardInterrupt):
pass pass
finally:
LOOP.close()