def run(self, *args, **kwargs): filter = dict( limit=kwargs.pop("limit", None), name=kwargs.pop("name", None), family=kwargs.pop("family", None), tags=kwargs.pop("tag", []), distroid=kwargs.pop("distro_id", None), ) format = kwargs['format'] self.set_hub(**kwargs) distros = self.hub.distros.filter(filter) if format == 'json': print json.dumps(distros, indent=4) elif format == 'tabular': if distros: print "-" * 70 for distro in distros: print " ID: %s" % distro['distro_id'] print " Name: %s" % distro['distro_name'] print "OSVersion: %s" % distro['distro_version'] print " Tags: %s" % ", ".join(distro['distro_tags']) print "-" * 70 else: sys.stderr.write("Nothing Matches\n") if not distros: sys.exit(1)
def run(self, *args, **kwargs): filter = dict( limit = kwargs.pop("limit", None), name = kwargs.pop("name", None), treepath = kwargs.pop("treepath", None), labcontroller = kwargs.pop("labcontroller", None), family = kwargs.pop("family", None), arch = kwargs.pop("arch", None), tags = kwargs.pop("tag", []), distro_id = kwargs.pop("distro_id", None), distro_tree_id = kwargs.pop("distro_tree_id", None), xml = kwargs.pop('xml_filter', None), ) format = kwargs['format'] self.set_hub(**kwargs) distro_trees = self.hub.distrotrees.filter(filter) if format == 'json': print json.dumps(distro_trees, indent=4) elif format == 'tabular': if distro_trees: print "-"*70 for dt in distro_trees: print " ID: %s" % dt['distro_tree_id'] print " Name: %-34.34s Arch: %s" % (dt['distro_name'], dt['arch']) print "OSVersion: %-34.34s Variant: %s" % (dt['distro_osversion'], dt['variant']) print " Tags: %s" % ", ".join(dt['distro_tags']) print print " Lab controller/URLs:" for labc, url in dt['available']: print " %-32s: %s" % (labc, url) print "-"*70 else: sys.stderr.write("Nothing Matches\n") if not distro_trees: sys.exit(1)
def run(self, *args, **kwargs): filter = dict( limit = kwargs.pop("limit", None), name = kwargs.pop("name", None), family = kwargs.pop("family", None), tags = kwargs.pop("tag", []), distroid = kwargs.pop("distro_id", None), ) format = kwargs['format'] self.set_hub(**kwargs) distros = self.hub.distros.filter(filter) if format == 'json': print json.dumps(distros, indent=4) elif format == 'tabular': if distros: print "-"*70 for distro in distros: print " ID: %s" % distro['distro_id'] print " Name: %s" % distro['distro_name'] print "OSVersion: %s" % distro['distro_version'] print " Tags: %s" % ", ".join(distro['distro_tags']) print "-"*70 else: sys.stderr.write("Nothing Matches\n") if not distros: sys.exit(1)
def run(self, *args, **kwargs): family = kwargs.pop('family', None) tag = kwargs.pop('tag', None) product = kwargs.pop('product', None) complete_days = kwargs.pop('completeDays', None) owner = kwargs.pop('owner', None) whiteboard = kwargs.pop('whiteboard', None) mine = kwargs.pop('mine', None) limit = kwargs.pop('limit', None) format = kwargs['format'] # Process Job IDs if specified and sanity checking minid = kwargs.pop('min_id', None) maxid = kwargs.pop('max_id', None) if minid or maxid: if minid and minid <= 0 or maxid and maxid <= 0: self.parser.error('Please specify a non zero positive Job ID') if minid and maxid: if maxid < minid: self.parser.error( 'Max Job ID should be greater than or equal to min Job ID' ) if complete_days is not None and complete_days < 1: self.parser.error('Please pass a positive integer to completeDays') if complete_days is None and tag is None and family is None and product is None\ and owner is None and mine is None and whiteboard is None: self.parser.error( 'Please pass either the completeDays time delta, a tag, product, family, or owner' ) if args: self.parser.error('This command does not accept any arguments') self.set_hub(**kwargs) if mine: self.hub._login() jobs = self.hub.jobs.filter( dict(tag=tag, daysComplete=complete_days, family=family, product=product, owner=owner, whiteboard=whiteboard, mine=mine, minid=minid, maxid=maxid, limit=limit)) if format == 'list': for job_id in jobs: print job_id if format == 'json': print json.dumps(jobs)
def run(self,*args, **kwargs): family = kwargs.pop('family', None) tags = kwargs.pop('tag', None) product = kwargs.pop('product', None) complete_days = kwargs.pop('completeDays', None) owner = kwargs.pop('owner', None) whiteboard = kwargs.pop('whiteboard', None) mine = kwargs.pop('mine', None) limit = kwargs.pop('limit', None) format = kwargs['format'] # Process Job IDs if specified and sanity checking minid = kwargs.pop('min_id', None) maxid = kwargs.pop('max_id', None) if minid or maxid: if minid and minid<=0 or maxid and maxid <= 0: self.parser.error('Please specify a non zero positive Job ID') if minid and maxid: if maxid < minid: self.parser.error('Max Job ID should be greater than or equal to min Job ID') if complete_days is not None and complete_days < 1: self.parser.error('Please pass a positive integer to completeDays') if complete_days is None and tags is None and family is None and product is None\ and owner is None and mine is None and whiteboard is None: self.parser.error('Please pass either the completeDays time delta, a tag, product, family, or owner') if args: self.parser.error('This command does not accept any arguments') self.set_hub(**kwargs) if mine: self.hub._login() jobs = self.hub.jobs.filter(dict(tags=tags, daysComplete=complete_days, family=family, product=product, owner=owner, whiteboard=whiteboard, mine=mine, minid=minid, maxid=maxid, limit=limit)) if format == 'list': for job_id in jobs: print job_id if format == 'json': print json.dumps(jobs)
def request(self, method, url, **kwargs): # callers can pass in a relative URL and we will figure it out for them url = urljoin(base_url, url) # turn 'json' parameter into a suitably formatted request if 'json' in kwargs: kwargs['data'] = json.dumps(kwargs.pop('json')) kwargs.setdefault('headers', {}).update({'Content-Type': 'application/json'}) return super(BeakerClientRequestsSession, self).request(method, url, **kwargs) #pylint: disable=bad-super-call
def request(self, method, url, **kwargs): # callers can pass in a relative URL and we will figure it out for them url = urljoin(base_url, url) # turn 'json' parameter into a suitably formatted request if 'json' in kwargs: kwargs['data'] = json.dumps(kwargs.pop('json')) kwargs.setdefault('headers', {}).update({'Content-Type': 'application/json'}) return super(BeakerClientRequestsSession, self).request(method, url, **kwargs)
def run(self, *args, **kwargs): if len(args) != 1: self.parser.error('Exactly one pool name must be specified') pool_name = args[0] self.set_hub(**kwargs) requests_session = self.requests_session() response = requests_session.get('pools/%s' % pool_name, headers={'Accept': 'application/json'}) response.raise_for_status() attributes = response.json() systems = attributes['systems'] if kwargs['format'] == 'json': print json.dumps(systems) else: for system in systems: print(system)
def run(self, *args, **kwargs): if len(args) != 1: self.parser.error('Exactly one group name must be specified.') format = kwargs['format'] group = args[0] self.set_hub(**kwargs) members = self.hub.groups.members(group) if format == 'list': for m in members: if m['owner']: output_tuple = (m['username'],m['email'], 'Owner') else: output_tuple = (m['username'],m['email'], 'Member') print '%s %s %s' % output_tuple if format == 'json': print json.dumps(members)
def test_dumps(self): self.assertEquals(json_compat.dumps({}), '{}') self.assertEquals(json_compat.dumps({}, indent=4), '{}')