Guest User

Untitled

a guest
Aug 12th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. # This script shows a simple connection to OMERO, printing details of the connection.
  2. # NB: You will need to edit the 'host', 'user' and 'password' fields before running.
  3.  
  4. # Connect to the Python Blitz Gateway
  5.  
  6. # See OmeroPy/Gateway for more info
  7.  
  8. # import the libraries we need
  9. from omero.gateway import BlitzGateway
  10. from omero.rtypes import *
  11. # use these login details:
  12. host = 'localhost'
  13. user = 'will'
  14. password = 'ome'
  15. # create a connection
  16. conn = BlitzGateway(user, password, host=host, port=4064)
  17. conn.connect()
  18.  
  19.  
  20. # Current session details
  21.  
  22. # By default, you will have logged into your 'current' group in OMERO. This can be changed by
  23. # switching group in the OMERO insight or web clients.
  24.  
  25. user = conn.getUser()
  26. print "Current user:"
  27. print " ID:", user.getId()
  28. print " Username:", user.getName()
  29. print " Full Name:", user.getFullName()
  30. print "Member of:"
  31. for g in conn.getGroupsMemberOf():
  32. print " ID:", g.getName(), " Name:", g.getId()
  33. group = conn.getGroupFromContext()
  34. print "Current group: ", group.getName()
  35. print "Current group Members:"
  36. for groupExpLink in group.copyGroupExperimenterMap():
  37. print " ID:", groupExpLink.child.id.val, " Username:", groupExpLink.child.omeName.val
  38. # The 'context' of our current session
  39. ctx = conn.getEventContext()
  40. # print ctx # for more info
  41.  
  42. conn._closeSession()
Add Comment
Please, Sign In to add comment