Loading cccli/cli.py +14 −13 Original line number Diff line number Diff line Loading @@ -88,19 +88,13 @@ class Cli(object): else: prompt = "" while True: try: try: argv = shlex.split(self.printer.getline(prompt), comments=True) except ValueError as e: print type(e) self.printer.error("Lexer: %s"%str(e)) continue except KeyboardInterrupt: self.printer.out("") continue except EOFError: break except SystemExit: break if len(argv) == 0: continue # alias subsitution Loading @@ -109,6 +103,13 @@ class Cli(object): argv = shlex.split(self.alias[argv[0]]) argv.extend(oldargv) self._exec_command(argv) except KeyboardInterrupt: self.printer.out("") continue except EOFError: break except SystemExit: break if self.interactive: self.printer.out("tcho!") Loading cccli/command.py +19 −11 Original line number Diff line number Diff line Loading @@ -226,20 +226,28 @@ class Command(object): raise cmdBadArgument() tql = str.join("", argv[1:]) # print tql list result items = self.cli.rpc.list(tql) if len(items) == 0: self.printer.out("No selected object") return self.printer.out("Your request give the following result:") for item in items: self.printer.out("%s"%item["id"]) self.printer.out("Count: %s"%len(items)) if self.printer.ask("Are you sure to %s? (yes/NO) "%argv[0], "yes") != "yes": try: objs = self.cli.rpc.list(tql) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) if len(objs) == 0: raise cmdWarning("No selected object") self.printer.out("You request give the following result:") for obj in objs: self.printer.out("%sid:%s%s%s"%(color["green"],color["yellow"],obj["id"],color["reset"])) self.printer.out("%sCount: %s%s"%(color["green"],color["reset"], len(objs))) if self.printer.ask("Are you sure to %s%s%s these %s id? (yes/NO) "%(color["lred"], argv[0], color["reset"], len(objs)), "yes") != "yes": raise cmdWarning("Aborted") if len(items) > 5: if len(objs) > 5: if self.printer.ask("You request is on more than 5 objets. Are you really sure to %s its? (Yes, I am) "%argv[0], "Yes, I am") != "Yes, I am": raise cmdWarning("Aborted") try: self.cli.rpc[argv[0]](tql) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) def cmd_start(self, argv): '''Start objects''' Loading Loading
cccli/cli.py +14 −13 Original line number Diff line number Diff line Loading @@ -88,19 +88,13 @@ class Cli(object): else: prompt = "" while True: try: try: argv = shlex.split(self.printer.getline(prompt), comments=True) except ValueError as e: print type(e) self.printer.error("Lexer: %s"%str(e)) continue except KeyboardInterrupt: self.printer.out("") continue except EOFError: break except SystemExit: break if len(argv) == 0: continue # alias subsitution Loading @@ -109,6 +103,13 @@ class Cli(object): argv = shlex.split(self.alias[argv[0]]) argv.extend(oldargv) self._exec_command(argv) except KeyboardInterrupt: self.printer.out("") continue except EOFError: break except SystemExit: break if self.interactive: self.printer.out("tcho!") Loading
cccli/command.py +19 −11 Original line number Diff line number Diff line Loading @@ -226,20 +226,28 @@ class Command(object): raise cmdBadArgument() tql = str.join("", argv[1:]) # print tql list result items = self.cli.rpc.list(tql) if len(items) == 0: self.printer.out("No selected object") return self.printer.out("Your request give the following result:") for item in items: self.printer.out("%s"%item["id"]) self.printer.out("Count: %s"%len(items)) if self.printer.ask("Are you sure to %s? (yes/NO) "%argv[0], "yes") != "yes": try: objs = self.cli.rpc.list(tql) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) if len(objs) == 0: raise cmdWarning("No selected object") self.printer.out("You request give the following result:") for obj in objs: self.printer.out("%sid:%s%s%s"%(color["green"],color["yellow"],obj["id"],color["reset"])) self.printer.out("%sCount: %s%s"%(color["green"],color["reset"], len(objs))) if self.printer.ask("Are you sure to %s%s%s these %s id? (yes/NO) "%(color["lred"], argv[0], color["reset"], len(objs)), "yes") != "yes": raise cmdWarning("Aborted") if len(items) > 5: if len(objs) > 5: if self.printer.ask("You request is on more than 5 objets. Are you really sure to %s its? (Yes, I am) "%argv[0], "Yes, I am") != "Yes, I am": raise cmdWarning("Aborted") try: self.cli.rpc[argv[0]](tql) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) def cmd_start(self, argv): '''Start objects''' Loading