本文整理汇总了Python中connector.Connector.create_connection方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.create_connection方法的具体用法?Python Connector.create_connection怎么用?Python Connector.create_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connector.Connector
的用法示例。
在下文中一共展示了Connector.create_connection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loginFromForm
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import create_connection [as 别名]
def test_loginFromForm(self):
params = {
'username': 'root',
'password': self.root_password,
'server':self.server_id,
'ssl':'on'
}
request = fakeRequest(method="post", params=params)
server_id = request.REQUEST.get('server')
form = LoginForm(data=request.REQUEST.copy())
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']
server_id = form.cleaned_data['server']
is_secure = toBoolean(form.cleaned_data['ssl'])
connector = Connector(server_id, is_secure)
conn = connector.create_connection('OMERO.web', username, password)
if conn is None:
self.fail('Cannot connect')
conn.seppuku()
if conn.isConnected() and conn.keepAlive():
self.fail('Connection was not closed')
else:
errors = form.errors.as_text()
self.fail(errors)
示例2: setUp
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import create_connection [as 别名]
def setUp (self):
c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
try:
self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
omero_host = c.ic.getProperties().getProperty('omero.host')
finally:
c.__del__()
blitz = Server.find(host=omero_host)
if blitz is None:
Server.reset()
for s in settings.SERVER_LIST:
server = (len(s) > 2) and unicode(s[2]) or None
Server(host=unicode(s[0]), port=int(s[1]), server=server)
Server.freeze()
blitz = Server.find(server=omero_host)
if len(blitz):
self.server_id = blitz[0].id
connector = Connector(self.server_id, True)
self.rootconn = connector.create_connection('TEST.webadmin', 'root', self.root_password)
if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive():
raise exceptions.Exception("Cannot connect")
else:
raise exceptions.Exception("'%s' is not on omero.web.server_list" % omero_host)
示例3: loginAsUser
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import create_connection [as 别名]
def loginAsUser(self, username, password):
blitz = Server.get(pk=self.server_id)
if blitz is not None:
connector = Connector(self.server_id, True)
conn = connector.create_connection('TEST.webadmin', username, password)
if conn is None or not conn.isConnected() or not conn.keepAlive():
raise Exception("Cannot connect")
return conn
else:
raise Exception("'%s' is not on omero.web.server_list" % self.omero_host)
示例4: setUp
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import create_connection [as 别名]
def setUp (self):
c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
try:
self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
self.omero_host = c.ic.getProperties().getProperty('omero.host')
self.omero_port = c.ic.getProperties().getProperty('omero.port')
Server.reset()
Server(host=self.omero_host, port=self.omero_port)
finally:
c.__del__()
self.server_id = 1
connector = Connector(self.server_id, True)
self.rootconn = connector.create_connection('TEST.webadmin', 'root', self.root_password)
if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive():
raise Exception("Cannot connect")
示例5: test_loginFromRequest
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import create_connection [as 别名]
def test_loginFromRequest(self):
params = {
'username': 'root',
'password': self.root_password,
'server':self.server_id,
'ssl':'on'
}
request = fakeRequest(method="post", path="/webadmin/login", params=params)
server_id = request.REQUEST.get('server')
username = request.REQUEST.get('username')
password = request.REQUEST.get('password')
is_secure = toBoolean(request.REQUEST.get('ssl'))
connector = Connector(server_id, is_secure)
conn = connector.create_connection('TEST.webadmin', username, password)
if conn is None:
self.fail('Cannot connect')
conn.seppuku()
if conn.isConnected() and conn.keepAlive():
self.fail('Connection was not closed')
示例6: test_loginFailure
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import create_connection [as 别名]
def test_loginFailure(self):
params = {
'username': 'notauser',
'password': 'nonsence',
'server':self.server_id
}
request = fakeRequest(method="post", params=params)
server_id = request.REQUEST.get('server')
form = LoginForm(data=request.REQUEST.copy())
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']
server_id = form.cleaned_data['server']
is_secure = toBoolean(form.cleaned_data['ssl'])
connector = Connector(server_id, is_secure)
conn = connector.create_connection('OMERO.web', username, password)
if conn is not None:
self.fail('This user does not exist. Login failure error!')
else:
errors = form.errors.as_text()
self.fail(errors)