Package omero :: Package plugins :: Module submit
[hide private]
[frames] | no frames]

Source Code for Module omero.plugins.submit

 1  #!/usr/bin/env python 
 2  """ 
 3     submit plugin 
 4   
 5     Plugin read by omero.cli.Cli during initialization. The method(s) 
 6     defined here will be added to the Cli class for later use. 
 7   
 8     Copyright 2007 Glencoe Software, Inc. All rights reserved. 
 9     Use is subject to license terms supplied in LICENSE.txt 
10   
11  """ 
12   
13  from omero.cli import CLI, BaseControl 
14  import cmd, sys, exceptions 
15  import sys 
16   
17  prompt = "omero submit [%s]> " 
18   
19 -class Save(exceptions.Exception):
20 pass
21
22 -class Cancel(exceptions.Exception):
23 pass
24
25 -class SubmitCLI(CLI):
26
27 - def __init__(self):
28 CLI.__init__(self) 29 self.queue = [] 30 self.prompt = prompt % str(0)
31
32 - def postcmd(self, stop, line):
33 self.queue.append(line) 34 self.prompt = prompt % str(len(self.queue)) 35 return CLI.postcmd(self, stop, line)
36
37 - def do_save(self, arg):
38 raise Save()
39
40 - def do_cancel(self, arg):
41 raise Cancel()
42
43 - def execute(self):
44 print "Uploading" 45 print submit.queue
46
47 -class SubmitControl(BaseControl):
48
49 - def help(self, args = None):
50 self.ctx.out(""" 51 Syntax: %(program_name)s submit single command with args 52 submit 53 54 When run without arguments, submit shell is opened 55 which takes commands without executing them. On save, 56 the file is trasferred to the server, and executed. 57 """)
58
59 - def __call__(self, *args):
60 args = Arguments(*args) 61 submit = SubmitCLI() 62 if arg and len(arg) > 0: 63 submit.invoke(arg) 64 submit.execute() 65 else: 66 try: 67 submit.invokeloop() 68 except Save, s: 69 submit.execute() 70 except Cancel, c: 71 l = len(submit.queue) 72 if l > 0: 73 print l," items queued. Really cancel? [Yn]"
74 75 try: 76 register("submit", SubmitControl) 77 except NameError: 78 SubmitControl()._main() 79