Hi Josh,
your last suggestion for the users worked well. Thanks.
Now the script is working but I want to improve it. So far all connection details are hard coded and I wanted a more flexible solution. Therefore I added a settings page, where details are entered, such as:
omerouser (to run the commands, and ssh connect)
omerouserpw
omeroserverip
omeroserverport
inplace user
....
These entries are then stored into a dictionary and dumped using Pickle.
Then the main script imports these settings and I tried to replace the hard coded connection details. Here I faced a problem:
When I try to run the conn = BlitzGateway with variables I get an error and no connection.
So hard coded:
- Code: Select all
conn = BlitzGateway('username','userpw',host='130.83.98.66', port=4064)
conn.connect()
ctx = conn.getEventContext()
print (ctx)
conn.close()
works well and I get:
- Code: Select all
object #0 (::omero::sys::EventContext)
{
shareId = -1
sessionId = 3879
sessionUuid = 68b3de8b-removed
userId = 3
userName = username
sudoerId = <nil>
sudoerName = <nil>
groupId = 53
groupName = user_group
isAdmin = True
adminPrivileges =
{
[0] = ReadSession
[1] = DeleteScriptRepo
[2] = ModifyUser
[3] = WriteOwned
[4] = WriteFile
[5] = Sudo
[6] = ModifyGroup
[7] = DeleteManagedRepo
[8] = ModifyGroupMembership
[9] = WriteScriptRepo
[10] = WriteManagedRepo
[11] = DeleteFile
[12] = DeleteOwned
[13] = Chgrp
[14] = Chown
}
eventId = -1
eventType = Internal
memberOfGroups =
{
[0] = 53
[1] = 1
[2] = 0
}
leaderOfGroups =
{
[0] = 53
}
groupPermissions = object #1 (::omero::model::Permissions)
{
_restrictions =
{
}
_extendedRestrictions =
{
}
_perm1 = -40
}
}
But when I want to replace it with the variable retrieved from my stored dictionary:
- Code: Select all
read_settings = pickle.load( open( "ipisettings.p", "rb" ) )
I can access all the values with e.g.:
read_settings["OMEROUSER"]
read_settings["OMEROIP"]
...
I checked the variable type and they are all strings.
So I tried to include them in the command like this:
- Code: Select all
conn = BlitzGateway(read_settings["OMEROUSER"],read_settings["OMEROPW"],host = read_settings["OMEROIP"], port = read_settings["OMEROPORT"])
conn.connect()
But get the error:
- Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/alexrapp/Documents/OMERO.server-5.4.5-ice36-b83/lib/python/omero/gateway/__init__.py", line 1560, in __init__
self._resetOmeroClient()
File "/Users/alexrapp/Documents/OMERO.server-5.4.5-ice36-b83/lib/python/omero/gateway/__init__.py", line 2085, in _resetOmeroClient
args=['--Ice.Config='+','.join(self.ice_config)])
File "/Users/alexrapp/Documents/OMERO.server-5.4.5-ice36-b83/lib/python/omero/__init__.py", line 67, in client
return omero.clients.BaseClient(*args, **kwargs)
File "/Users/alexrapp/Documents/OMERO.server-5.4.5-ice36-b83/lib/python/omero/clients.py", line 140, in __init__
self._initData(id)
File "/Users/alexrapp/Documents/OMERO.server-5.4.5-ice36-b83/lib/python/omero/clients.py", line 272, in _initData
raise omero.ClientError(msg)
omero.ClientError: No host specified. Use omero.client(HOSTNAME), ICE_CONFIG, or similar.
I also tried to first pass the dictionary entries to variables and then pass them to the conn = BlitzGateway like this:
connUser = read_settings["OMERORUSER"]
connUser = read_settings["OMERORUSER"]
...
then :
conn = BlitzGateway(connUser, connPW, host = connIP, port = connPort)
conn.connect()
with no success.
Am I missing something here, or can I not pass variables to the BlitzConnect()?
Thanks
Alex