Loading cccli/command.py +9 −5 Original line number Diff line number Diff line Loading @@ -81,7 +81,8 @@ class Commands(object): h = self.cmds[argv0](self.cli, argv0).help() return h if h is not None else "" def load_commands(self, path, cls): @staticmethod def load_commands(path, cls): '''Load sublasss of cls from package name''' cmds=dict() for name in os.listdir(path): Loading Loading @@ -161,10 +162,12 @@ class OptionCommand(Command): class OptionCommandParser(OptionParser): '''Parser of Option for OptionCommand''' def error(self, e): @staticmethod def error(e): raise cmdBadArgument(e) def exit(self): @staticmethod def exit(): raise cmdExit() def __init__(self, cli, argv0): Loading Loading @@ -214,7 +217,8 @@ class RemoteCommand(OptionCommand): help="Print object lines indexed") self.rpc = cli.rpc def remote_functions(self): @staticmethod def remote_functions(): '''Return a set of needed remote functions''' raise NotImplementedError Loading cccli/printer.py +19 −12 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ class Printer(object): # enable completion self.completion.readline = readline def out(self, message="", fd=None, nl=os.linesep, flush=True): @staticmethod def out(message="", fd=None, nl=os.linesep, flush=True): '''Print a message in fd ended by nl''' if fd is None: fd = sys.stdout Loading @@ -79,31 +80,36 @@ class Printer(object): if flush: fd.flush() def err(self, message, fd=None, nl=os.linesep): @staticmethod def err(message, fd=None, nl=os.linesep): if fd is None: fd = sys.stderr self.out(message, fd, nl) Printer.out(message, fd, nl) def fatal(self, message, quit=True, fd=None, nl=os.linesep): self.err("%sFatal%s: %s%s"%(color["lred"],color["red"],message, color["reset"]), @staticmethod def fatal(message, quit=True, fd=None, nl=os.linesep): Printer.err("%sFatal%s: %s%s"%(color["lred"],color["red"],message, color["reset"]), fd, nl) if quit: os._exit(42) def error(self, message, fd=None, nl=os.linesep): self.err("%sError%s: %s%s"%(color["lred"],color["red"],message,color["reset"]), @staticmethod def error(message, fd=None, nl=os.linesep): Printer.err("%sError%s: %s%s"%(color["lred"],color["red"],message,color["reset"]), fd, nl) def warn(self, message, fd=None, nl=os.linesep): self.err("%sWarning%s: %s%s"%(color["lyellow"],color["yellow"],message,color["reset"]), @staticmethod def warn(message, fd=None, nl=os.linesep): Printer.err("%sWarning%s: %s%s"%(color["lyellow"],color["yellow"],message,color["reset"]), fd, nl) def debug(self, message, fd=None, nl=os.linesep): @staticmethod def debug(message, fd=None, nl=os.linesep): if cccli.debug: self.err("%s%s%s"%(color["lgrey"],message,color["reset"]), fd, nl) Printer.err("%s%s%s"%(color["lgrey"],message,color["reset"]), fd, nl) def isinteractive(self): return self.readline is not None Loading @@ -113,7 +119,8 @@ class Printer(object): if self.readline is not None: self.err(message, fd, nl) def getline(self, prompt): @staticmethod def getline(prompt): '''Read a line from stdin''' try: s = raw_input(prompt) Loading Loading
cccli/command.py +9 −5 Original line number Diff line number Diff line Loading @@ -81,7 +81,8 @@ class Commands(object): h = self.cmds[argv0](self.cli, argv0).help() return h if h is not None else "" def load_commands(self, path, cls): @staticmethod def load_commands(path, cls): '''Load sublasss of cls from package name''' cmds=dict() for name in os.listdir(path): Loading Loading @@ -161,10 +162,12 @@ class OptionCommand(Command): class OptionCommandParser(OptionParser): '''Parser of Option for OptionCommand''' def error(self, e): @staticmethod def error(e): raise cmdBadArgument(e) def exit(self): @staticmethod def exit(): raise cmdExit() def __init__(self, cli, argv0): Loading Loading @@ -214,7 +217,8 @@ class RemoteCommand(OptionCommand): help="Print object lines indexed") self.rpc = cli.rpc def remote_functions(self): @staticmethod def remote_functions(): '''Return a set of needed remote functions''' raise NotImplementedError Loading
cccli/printer.py +19 −12 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ class Printer(object): # enable completion self.completion.readline = readline def out(self, message="", fd=None, nl=os.linesep, flush=True): @staticmethod def out(message="", fd=None, nl=os.linesep, flush=True): '''Print a message in fd ended by nl''' if fd is None: fd = sys.stdout Loading @@ -79,31 +80,36 @@ class Printer(object): if flush: fd.flush() def err(self, message, fd=None, nl=os.linesep): @staticmethod def err(message, fd=None, nl=os.linesep): if fd is None: fd = sys.stderr self.out(message, fd, nl) Printer.out(message, fd, nl) def fatal(self, message, quit=True, fd=None, nl=os.linesep): self.err("%sFatal%s: %s%s"%(color["lred"],color["red"],message, color["reset"]), @staticmethod def fatal(message, quit=True, fd=None, nl=os.linesep): Printer.err("%sFatal%s: %s%s"%(color["lred"],color["red"],message, color["reset"]), fd, nl) if quit: os._exit(42) def error(self, message, fd=None, nl=os.linesep): self.err("%sError%s: %s%s"%(color["lred"],color["red"],message,color["reset"]), @staticmethod def error(message, fd=None, nl=os.linesep): Printer.err("%sError%s: %s%s"%(color["lred"],color["red"],message,color["reset"]), fd, nl) def warn(self, message, fd=None, nl=os.linesep): self.err("%sWarning%s: %s%s"%(color["lyellow"],color["yellow"],message,color["reset"]), @staticmethod def warn(message, fd=None, nl=os.linesep): Printer.err("%sWarning%s: %s%s"%(color["lyellow"],color["yellow"],message,color["reset"]), fd, nl) def debug(self, message, fd=None, nl=os.linesep): @staticmethod def debug(message, fd=None, nl=os.linesep): if cccli.debug: self.err("%s%s%s"%(color["lgrey"],message,color["reset"]), fd, nl) Printer.err("%s%s%s"%(color["lgrey"],message,color["reset"]), fd, nl) def isinteractive(self): return self.readline is not None Loading @@ -113,7 +119,8 @@ class Printer(object): if self.readline is not None: self.err(message, fd, nl) def getline(self, prompt): @staticmethod def getline(prompt): '''Read a line from stdin''' try: s = raw_input(prompt) Loading