def running_processes(): processes = [] for name in config.keys(): if validate(name): processes.append(name) return processes
import yaml import re, os import argparse from processes import start, stop, validate args = parse_args() config = read_config() if args == 'show': # show list and status of services max_name_len = 0 for name in config: name_len = len(name) if name_len > max_name_len: max_name_len = name_len for name, (path, _, _) in config.items(): skip = ' ' * (max_name_len - len(name)) pid = validate(name) if pid: ex_str = green('running [%d]' % pid) else: ex_str = red('not running') try: if len(config[name][1]) > 0: ex_str += '\t(deps: ' + ', '.join(config[name][1]) + ')' except: pass print '%s:%s %s' % (blue(name), skip, ex_str) elif args[0] in ['start', 'stop']: try: name = args[1] data = config[name]