better errors + better tools
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
from os import chdir, system, path
|
||||
from sys import argv
|
||||
from subprocess import run, PIPE
|
||||
from multiprocessing import Process
|
||||
|
||||
apps = ['core', 'api', 'www']
|
||||
commands = {
|
||||
@ -14,19 +16,29 @@ def print_commands():
|
||||
print('Available commands:', [c for c in commands])
|
||||
|
||||
|
||||
def run_command_in_app(app: str, command: str):
|
||||
chdir(app)
|
||||
result = run(command.split(' '), stdout=PIPE, stderr=PIPE, text=True)
|
||||
|
||||
status = 'DONE' if result.returncode == 0 else 'ERROR'
|
||||
print('%s:\t%s' % (app, status))
|
||||
if status == 'ERROR':
|
||||
print(result.stdout, result.stderr)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
if len(argv) < 2:
|
||||
print_commands()
|
||||
exit()
|
||||
|
||||
cmd = sys.argv[1]
|
||||
cmd = argv[1]
|
||||
if cmd not in commands:
|
||||
print('Command \'%s\' not available' % cmd)
|
||||
print_commands()
|
||||
exit()
|
||||
|
||||
chdir(path.join(path.dirname(path.realpath(__file__)), '..'))
|
||||
|
||||
print('Running \'%s\' on %d apps: %s' % (commands[cmd], len(apps), apps))
|
||||
for app in apps:
|
||||
os.chdir(app)
|
||||
os.system(commands[cmd])
|
||||
os.chdir('..')
|
||||
Process(target=run_command_in_app, args=(app, commands[cmd])).start()
|
||||
|
Reference in New Issue
Block a user