import re parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='none') parser.add_argument('command') parser.add_argument('executable', nargs='?', default='none') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "view <executable> [-h]") io.exitSuccess() if args.executable == 'none': if io.runCommandMuted("screen -ls | grep {}".format(args.package)): io.printAsync(io.Empty(), "checking executables in ", args.package, "..", io.Progress()) stdout = subprocess.check_output( ["screen", "-ls | grep", args.package]).decode("utf-8") executables = re.findall('__([a-z + _]+)', stdout) if len(executables) > 0: for executable in executables: io.println(io.Success(), executable, "is running") else: io.println(io.Fail(), "no executable is running") io.exitSuccess() io.printAsync(io.Empty(), "checking executable..", io.Progress())
import re parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='all') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('command') parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "view <executable> [-h]") io.exitSuccess() if args.package == 'all': executable_exist = False for package in pkg.packages: if io.runCommandMuted("screen -ls | grep {}".format(package)): io.printAsync(io.Empty(), "checking executables in ", package, "..", io.Progress()) stdout = subprocess.check_output(["screen", "-ls | grep", package]).decode("utf-8") executables = re.findall('__([a-z + _]+)', stdout) if len(executables) > 0: executable_exist = True for executable in executables: io.println(io.Success(), executable, "is running") if not executable_exist: io.println(io.Fail(), "no executable is running") io.exitSuccess()
parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if len(args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "view <executable> [-h]") io.exitSuccess() target_packages = list() target_executables = list() if args.package == 'all': package_clear = True for package in pkg.packages: if io.runCommandMuted("screen -ls | grep {}".format(package)): io.printAsync(io.Empty(), "checking executables in ", package, "..", io.Progress()) stdout = subprocess.check_output(["screen", "-ls | grep", package]).decode("utf-8") executables = re.findall('__([a-z + _]+)', stdout) if len(executables)>0: for executable in executables: if package_clear: io.println(io.Warn(), "some packages are running:") package_clear = False target_packages.append(package) target_executables.append(executable) io.println(io.WarnList(), executable, "in", package) if len(target_executables) == 0: string = io.println(io.Fail(), "no executable is running")
import argparse parser = argparse.ArgumentParser(add_help=False) parser.add_argument('package', nargs='?', default='none') parser.add_argument('command') parser.add_argument('executable', nargs='?', default='none') parser.add_argument('residuals', nargs='*', default=[]) parser.add_argument('-h', '--help', action='store_true') args = parser.parse_args() if args.package == 'none' or args.executable == 'none' or len( args.residuals) > 0 or args.help: io.println(io.Yellow("usage:"), args.package, "kill <executable> [-h]") io.exitFail() io.printAsync(io.Empty(), "checking executable..", io.Progress()) if not io.runCommandMuted("screen -ls | grep {}__{}".format( args.package, args.executable)): io.println(io.Fail(), args.executable, "in", args.package, "has not been run") io.exitFail() io.printAsync(io.Empty(), "killing executable..", io.Progress()) if not io.runCommandMuted("screen -XS {}__{} quit".format( args.package, args.executable)): io.println(io.Fail(), "failed to kill", args.executable, "in", args.package) io.exitFail() io.println(io.Success(), "done killing", args.executable, "in", args.package) io.exitSuccess()