I’m trying to connect to a demo OMERO server I’ve setup, but I can’t seem to connect with Python. I’ve tested both the web client and OMERO.Insight, and both are able to connect. The server is running Ubuntu 18.04 with the latest OMERO server/web installed via Docker. I’m following the documentation here.
from omero.gateway import BlitzGateway
from getpass import getpass
def connect(hostname, username, password):
"""
Connect to an OMERO server
:param hostname: Host name
:param username: User
:param password: Password
:return: Connected BlitzGateway
"""
conn = BlitzGateway(username, password,
host=hostname, secure=True)
conn.connect()
conn.c.enableKeepAlive(60)
return conn
HOST = 'xx.xx.xx.xxx'
conn = connect(HOST, input("Username: "),
getpass("OMERO Password: "))
print("Connected as {}".format(conn.getUser().getName()))
I get the following error after entering the username and password to connect within a Jupyter Notebook:
Username: xxxxxxx
OMERO Password: ········
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-34-de55f7b2c5a6> in <module>
16 conn = connect(HOST, input("Username: "),
17 getpass("OMERO Password: "))
---> 18 print("Connected as {}".format(conn.getUser().getName()))
~\Anaconda3\envs\omeropy\lib\site-packages\omero\gateway\__init__.py in getUser(self)
2350 """
2351 if self._user is None:
-> 2352 uid = self.getUserId()
2353 if uid is not None:
2354 self._user = self.getObject(
~\Anaconda3\envs\omeropy\lib\site-packages\omero\gateway\__init__.py in getUserId(self)
2332 """
2333 if self._userid is None:
-> 2334 self._userid = self.getEventContext().userId
2335 return self._userid
2336
~\Anaconda3\envs\omeropy\lib\site-packages\omero\gateway\__init__.py in getEventContext(self)
2320 :rtype: :class:`omero.sys.EventContext`
2321 """
-> 2322 if self._ctx is None:
2323 self._ctx = self._proxies['admin'].getEventContext()
2324 return self._ctx
AttributeError: '_BlitzGateway' object has no attribute '_ctx'
Is there a configuration setting that I’m missing to enable CLI connections?