本文整理汇总了Python中omero.gateway.BlitzGateway.seppuku方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.seppuku方法的具体用法?Python BlitzGateway.seppuku怎么用?Python BlitzGateway.seppuku使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.seppuku方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: group_exists
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import seppuku [as 别名]
def group_exists(self, user, group):
if not self.user_exists(user):
return False
else:
if group in self.known_users[user]:
print "in Group:", group
return True
try:
try:
conn = BlitzGateway(user, "ome", host='localhost')
conn.connect()
groups = conn.getGroupsMemberOf()
except:
return False
if group in [g.name for g in groups]:
print "in Group:", group
self.known_users[user].append(group)
return True
else:
print "is not in Group:", group, "- ignoring."
return False
finally:
conn.seppuku()
示例2: user_exists
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import seppuku [as 别名]
def user_exists(self, user):
if user in self.known_users.keys():
print "User:", user,
return True
try:
try:
conn = BlitzGateway("root", "omero", host='localhost')
conn.connect()
params = omero.sys.Parameters()
params.theFilter = omero.sys.Filter()
u = conn.getObject("Experimenter", attributes={'omeName': user}, params=params)
except:
print "Error getting user - ignoring."
return False
if u is None:
print "User:", user, "does not exist - ignoring."
return False
else:
print "User:", user,
self.known_users[user] = []
return True
finally:
conn.seppuku()
示例3: createTagGroup
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import seppuku [as 别名]
groupData = terms[pid]
groupName = groupData['name']
groupDesc = groupData['def']
tg = createTagGroup(groupName, groupDesc)
childNames = []
childDescs = []
for cid in groupData['children']:
cData = terms[cid]
childNames.append(cData['name'])
childDescs.append(cData['def'])
createAndSaveTags(childNames, childDescs, tg)
f.close()
conn.seppuku()
# -------- IF we just want to create Tags without Tag-Groups, we can do this... ---------
# names = []
# defs = []
# f = open("gene_ontology.1_2.obo.txt", "r")
# for l in f.readlines():
# if l.startswith("name:"):
# names.append(l.strip()[6:])
# elif l.startswith("def:"):
# defs.append(l.strip()[5:])
# f.close()
# # names = names[:20]
# # defs = defs[:20]
示例4: TestConfig
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import seppuku [as 别名]
class TestConfig(lib.ITest):
def setup_method(self, method):
# prepare session
self.r = RequestFactory().get('/rand')
middleware = SessionMiddleware()
middleware.process_request(self.r)
self.r.session.save()
self.rs = self.root.sf.getConfigService()
self.conn = BlitzGateway(client_obj=self.new_client())
def teardown_method(self, method):
self.conn.seppuku()
self.r.session.flush()
def testDefaultConfig(self):
""" Test loading default config """
deprecated = [
'omero.client.ui.menu.dropdown.everyone',
'omero.client.ui.menu.dropdown.leaders',
'omero.client.ui.menu.dropdown.colleagues'
]
default = self.rs.getClientConfigDefaults()
login_required(default_view).load_server_settings(self.conn, self.r)
s = {"omero": {"client": self.r.session.get('server_settings', {})}}
ss = self.r.session['server_settings']
# assert if alias gives the same value as deprecated
# rather then ${property}
for d in deprecated:
ds = d.split(".")
assert ss['ui']['menu']['dropdown'][ds[-1]]['label'] == default[d]
# workaround for alias as getClientConfigDefaults returns
# ${property} rather then value
assert ss['ui']['menu']['dropdown'][ds[-1]]['label'] == \
self.conn.getConfigService().getConfigValue(
default['%s.label' % d][2:-1])
# compare keys in default and config loaded by decorator
a = filter(lambda x: x not in (
set(default.keys()) - set(deprecated)),
set(flattenProperties(s).keys()))
assert a == ['omero.client.email']
def testDefaultConfigConversion(self):
default = self.rs.getClientConfigDefaults()
# bool
key1 = 'omero.client.ui.tree.orphans.enabled'
self.rs.setConfigValue(key1, default[key1])
key11 = 'omero.client.ui.tree.orphans.name'
self.rs.setConfigValue(key11, default[key11])
# digit
key2 = 'omero.client.viewer.roi_limit'
self.rs.setConfigValue(key2, default[key2])
login_required(default_view).load_server_settings(self.conn, self.r)
ss = self.r.session['server_settings']
assert isinstance(ss['ui']['tree']['orphans']['enabled'], bool)
assert ss['ui']['tree']['orphans']['enabled'] == bool(default[key1])
assert isinstance(ss['ui']['tree']['orphans']['name'], str)
assert ss['ui']['tree']['orphans']['name'] == default[key11]
assert isinstance(ss['viewer']['roi_limit'], int)
assert ss['viewer']['roi_limit'] == json.loads(default[key2])
@pytest.mark.parametrize("prop", ["colleagues", "leaders", "everyone",
"colleagues.label", "leaders.label",
"everyone.label"])
@pytest.mark.parametrize("label", ["foo"])
def testUpgradeDropdownMenuConfig(self, prop, label):
""" Test if alias loads deprecated property value """
d = self.rs.getClientConfigDefaults()
key = "omero.client.ui.menu.dropdown.%s" % prop
try:
self.rs.setConfigValue(key, label)
# test load_server_settings directly
login_required(default_view).load_server_settings(
self.conn, self.r)
s = self.r.session.get('server_settings', {})
prop = prop.replace(".label", "")
assert s['ui']['menu']['dropdown'][prop]['label'] == label
finally:
self.rs.setConfigValue(key, d[key])
def mock_getClientSettings(self, monkeypatch, default):
def get_clientSettings(*args, **kwargs):
not_exist = [
'omero.client.ui.menu.dropdown.everyone.label',
'omero.client.ui.menu.dropdown.leaders.label',
'omero.client.ui.menu.dropdown.colleagues.label',
'omero.client.ui.tree.orphans.enabled',
'omero.client.viewer.initial_zoom_level'
]
for n in not_exist:
if n in default:
del default[n]
#.........这里部分代码省略.........