Loading cccli/command/account.py +16 −6 Original line number Diff line number Diff line Loading @@ -10,20 +10,30 @@ from sjrpc.core.exceptions import * from cccli.printer import Printer, color from cccli.command.command import OptionCommand, TqlCommand class Command_addaccount(OptionCommand): class Command_addaccount(TqlCommand): '''Create an account''' def __init__(self, cli, argv0): OptionCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <account name> <role>") TqlCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <account name> <role> [password]") def __call__(self, argv): # parse args self.parse_args(argv) if len(self.args) != 2: if len(self.args) == 2: _pass = None elif len(self.args) == 3: _pass = self.args[2] if self.printer.isinteractive(): self.printer.warn("Removing last line from history") self.printer.history.removelast() else: raise cmdBadArgument() # execute command self.rpccall("addaccount", self.args[0], self.args[1]) # add account self.rpccall("addaccount", self.args[0], self.args[1], _status=False) # set password if _pass is not None: self.rpccall("passwd", "a=%s"%self.args[0], _pass) class Command_delaccount(TqlCommand): Loading cccli/command/command.py +10 −2 Original line number Diff line number Diff line Loading @@ -94,15 +94,23 @@ class TqlCommand(OptionCommand): def rpccall(self, *args, **kwargs): '''Call a RPC method an show tql return''' # check for status printing if "_status" in kwargs: _status = kwargs["_status"] del kwargs["_status"] elif self.options.status: _status = True else: _status = False # Do RPC Call try: d = self.rpc.call(*args, **kwargs) if self.options.status: if _status: self.show_status(d) return d except RpcError as e: raise cmdError("RPCError: %s"%str(e)) def show_status(self, ans): '''Show status of an Tql request''' try: Loading Loading
cccli/command/account.py +16 −6 Original line number Diff line number Diff line Loading @@ -10,20 +10,30 @@ from sjrpc.core.exceptions import * from cccli.printer import Printer, color from cccli.command.command import OptionCommand, TqlCommand class Command_addaccount(OptionCommand): class Command_addaccount(TqlCommand): '''Create an account''' def __init__(self, cli, argv0): OptionCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <account name> <role>") TqlCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <account name> <role> [password]") def __call__(self, argv): # parse args self.parse_args(argv) if len(self.args) != 2: if len(self.args) == 2: _pass = None elif len(self.args) == 3: _pass = self.args[2] if self.printer.isinteractive(): self.printer.warn("Removing last line from history") self.printer.history.removelast() else: raise cmdBadArgument() # execute command self.rpccall("addaccount", self.args[0], self.args[1]) # add account self.rpccall("addaccount", self.args[0], self.args[1], _status=False) # set password if _pass is not None: self.rpccall("passwd", "a=%s"%self.args[0], _pass) class Command_delaccount(TqlCommand): Loading
cccli/command/command.py +10 −2 Original line number Diff line number Diff line Loading @@ -94,15 +94,23 @@ class TqlCommand(OptionCommand): def rpccall(self, *args, **kwargs): '''Call a RPC method an show tql return''' # check for status printing if "_status" in kwargs: _status = kwargs["_status"] del kwargs["_status"] elif self.options.status: _status = True else: _status = False # Do RPC Call try: d = self.rpc.call(*args, **kwargs) if self.options.status: if _status: self.show_status(d) return d except RpcError as e: raise cmdError("RPCError: %s"%str(e)) def show_status(self, ans): '''Show status of an Tql request''' try: Loading