def processObject(self, obj): """Operate on the provided job object.""" # ask the user if we should continue if not obj.pre(self, "Change %s of the job?" % self.opts.key): return # represent value in type appropriate to member; it will be packed for transmission if self.opts.key in self.IntListAttrs: value = [int(v) for v in stringutil.str2list(self.opts.value)] elif self.opts.key in self.StrListAttrs: value = stringutil.str2list(self.opts.value) else: value = self.opts.value # try to run the operation query.jattr(obj, key=self.opts.key, value=value) obj.post(self, "%s changed" % self.opts.key)
def parseArgs(self, *args, **kwargs): result = super(ChangeJobAttributeCmd, self).parseArgs(*args, **kwargs) # make sure key and value were specified if self.opts.key is None: raise tq.TqError, "no key provided" if self.opts.value is None: raise tq.TqError, "no value provided :)" if self.opts.key in self.IntListAttrs: values = stringutil.str2list(self.opts.value) for value in values: if not value.isdigit(): raise tq.TqError, "value must be a comma separated list of integers" return result