Loading cccli/command.py +26 −15 Original line number Diff line number Diff line Loading @@ -295,6 +295,7 @@ class TqlCommand(RemoteCommand): _tql_print: print tql with filter _exception: catch or not RPCError exception _direct: call directly, no listing before _list: list of arg which are added to call arg one by one (=> multiple call) ''' # set rpccall default option value Loading @@ -306,6 +307,7 @@ class TqlCommand(RemoteCommand): "tql_index": 1, "tql_print": False, "callback": None, "list": [], } # check for options modifiers for o in _options.keys(): Loading Loading @@ -336,11 +338,24 @@ class TqlCommand(RemoteCommand): def _unsecure_rpccall(self, _options, args, kwargs): '''Just call an RPC without checking before''' try: # list mode call command for each argument # return is returned as a list if len(_options["list"]) == 0: d = self.rpc.call(*args, **kwargs) if _options["callback"] is not None: _options["callback"](d) if _options["status"]: self.print_objects(d, ["output"], index=_options["index"]) else: d = [] for arg in _options["list"]: args2 = args + [ arg ] r = self.rpc.call(*args2, **kwargs) d.append(r) if _options["callback"] is not None: _options["callback"](r) if _options["status"]: self.print_objects(r, ["output"], index=_options["index"]) return d except RpcError as e: if _options["exception"]: Loading Loading @@ -371,13 +386,9 @@ class TqlCommand(RemoteCommand): raise cmdWarning("User aborted") # per validated id execution (this is a kind of atomic implementation) for obj in objs["objects"]: try: l = list(args) l[_options["tql_index"]] = "id=%s"%obj["id"] d = self.cli.rpc.call(*tuple(l), **kwargs) if _options["callback"] is not None: _options["callback"](d) if _options["status"]: self.print_objects(d, ["output"], index=False) except RpcError as e: self.printer.error("RPCError: %s"%str(e)) # make a list from tupe for editing args2 = list(args) # ovewrite tql object by id from object args2[_options["tql_index"]] = "id=%s"%obj["id"] # now we can make call self._unsecure_rpccall(_options, args2, kwargs) cccli/commands/right.py +1 −3 Original line number Diff line number Diff line Loading @@ -99,9 +99,7 @@ class Command_delright(TqlCommand): if "*" in self.args[1:]: self.rpccall("delright", self.args[0], None) else: self.rpccall("list", self.args[0], _status=False) for index in l: self.rpccall("delright", self.args[0], index, _direct=True) self.rpccall("delright", self.args[0], _list=l) def remote_functions(self): return set(('delright',)) Loading
cccli/command.py +26 −15 Original line number Diff line number Diff line Loading @@ -295,6 +295,7 @@ class TqlCommand(RemoteCommand): _tql_print: print tql with filter _exception: catch or not RPCError exception _direct: call directly, no listing before _list: list of arg which are added to call arg one by one (=> multiple call) ''' # set rpccall default option value Loading @@ -306,6 +307,7 @@ class TqlCommand(RemoteCommand): "tql_index": 1, "tql_print": False, "callback": None, "list": [], } # check for options modifiers for o in _options.keys(): Loading Loading @@ -336,11 +338,24 @@ class TqlCommand(RemoteCommand): def _unsecure_rpccall(self, _options, args, kwargs): '''Just call an RPC without checking before''' try: # list mode call command for each argument # return is returned as a list if len(_options["list"]) == 0: d = self.rpc.call(*args, **kwargs) if _options["callback"] is not None: _options["callback"](d) if _options["status"]: self.print_objects(d, ["output"], index=_options["index"]) else: d = [] for arg in _options["list"]: args2 = args + [ arg ] r = self.rpc.call(*args2, **kwargs) d.append(r) if _options["callback"] is not None: _options["callback"](r) if _options["status"]: self.print_objects(r, ["output"], index=_options["index"]) return d except RpcError as e: if _options["exception"]: Loading Loading @@ -371,13 +386,9 @@ class TqlCommand(RemoteCommand): raise cmdWarning("User aborted") # per validated id execution (this is a kind of atomic implementation) for obj in objs["objects"]: try: l = list(args) l[_options["tql_index"]] = "id=%s"%obj["id"] d = self.cli.rpc.call(*tuple(l), **kwargs) if _options["callback"] is not None: _options["callback"](d) if _options["status"]: self.print_objects(d, ["output"], index=False) except RpcError as e: self.printer.error("RPCError: %s"%str(e)) # make a list from tupe for editing args2 = list(args) # ovewrite tql object by id from object args2[_options["tql_index"]] = "id=%s"%obj["id"] # now we can make call self._unsecure_rpccall(_options, args2, kwargs)
cccli/commands/right.py +1 −3 Original line number Diff line number Diff line Loading @@ -99,9 +99,7 @@ class Command_delright(TqlCommand): if "*" in self.args[1:]: self.rpccall("delright", self.args[0], None) else: self.rpccall("list", self.args[0], _status=False) for index in l: self.rpccall("delright", self.args[0], index, _direct=True) self.rpccall("delright", self.args[0], _list=l) def remote_functions(self): return set(('delright',))