class Overlay: def __init__(self): self.cmd = Command( "main", arguments=[("overlay", False)], subcommands=[ ("sync", [("method", False), ("uri", False)], self.sync), ("generate-tree", [], self.generate_tree), ], ) self.overlay = None def __call__(self, args=None): args = self.cmd.parse_args(args) return args.action(args) def run_command(self, cmd, args): flag = True if not os.path.exists(cmd): flag = False for d in os.environ["PATH"].split(os.pathsep): f = os.path.join(d, cmd) if os.path.exists(f): flag = True break if not flag: raise OverlayError("command " + cmd + " not found") cmd = [cmd] + args subprocess.check_call(cmd, universal_newlines=True) def sync(self, args): return 0 def generate_tree(self, args): return 0
def __init__(self): self.cmd = Command( "main", arguments=[("overlay", False)], subcommands=[ ("sync", [("method", False), ("uri", False)], self.sync), ("generate-tree", [], self.generate_tree), ], ) self.overlay = None