本文整理汇总了Python中intermine.webservice.Service._get_json方法的典型用法代码示例。如果您正苦于以下问题:Python Service._get_json方法的具体用法?Python Service._get_json怎么用?Python Service._get_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intermine.webservice.Service
的用法示例。
在下文中一共展示了Service._get_json方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attack
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import _get_json [as 别名]
def attack(self):
username = "user-weapon-{0}@noreply.intermine.org".format(self.ident)
password = "yolo"
try:
s = Service(self.service.root, username, password)
s.deregister(s.get_deregistration_token())
self.counter.add(3)
except:
pass
s = self.service.register(username, password)
self.LOG.debug("Registered user " + username)
self.counter.add(1)
c = 0
classes = s.model.classes.values()
self.counter.add(1)
classkeys = s._get_json('/classkeys')['classes']
self.counter.add(1)
while c == 0:
table = random.choice(classes)
if not (table.has_id and table.name in classkeys):
continue
query = s.query(table.name).select(classkeys[table.name][0])
c = query.count()
self.counter.add(1)
n = random.randint(1, min(100, c))
members = random.sample(map(lambda r: r[0], query.rows()), n)
self.counter.add(1)
self.LOG.debug("Will construct list of %s with: %r", table.name, members)
with s.list_manager() as lm:
l = lm.create_list(members, table.name)
self.LOG.debug('Created list %s, size: %d', l.name, l.size)
self.counter.add(1)
try:
s.deregister(s.get_deregistration_token())
self.counter.add(2)
except:
pass