1
2 """
3 Plugin for viewing and controlling active sessions via the
4 jgroups-based ome.services.blitz.fire.Ring class
5
6 Plugin read by omero.cli.Cli during initialization. The method(s)
7 defined here will be added to the Cli class for later use.
8
9 Copyright 2008 Glencoe Software, Inc. All rights reserved.
10 Use is subject to license terms supplied in LICENSE.txt
11
12 """
13
14 import subprocess, optparse, os, sys
15 import getpass, pickle
16 import omero.java
17 from omero.cli import Arguments, BaseControl, VERSION
18 from path import path
19
21
22 - def help(self, args = None):
23 self.ctx.out("table -- print table of session data")
24
31
34
43
50
53
54
55
56
58 defuser = getpass.getuser()
59 return raw_input("Username: [%s]" % defuser)
60
62 return getpass.getpass()
63
64 - def _session(self, username, password, other):
68
70 sess_file = self.ctx.userdir() / "sessionid"
71 if sess:
72 f = open(str(sess_file), "w")
73 try:
74 f.write(str(sess))
75 print "Created session: %s" % sess
76 finally:
77 f.close()
78 return True
79 else:
80 if sess_file.exists():
81 f = open(str(sess_file), "r")
82 try:
83 old_sess = f.readline()
84 finally:
85 f.close()
86 sess_file.remove()
87 self.ctx.out("Cleared session: %s" % old_sess)
88 return old_sess
89 else:
90 self.ctx.out("No active session")
91 return None
92
93 try:
94 register("sessions", SessionsControl)
95 except NameError:
96 SessionsControl()._main()
97