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

Source Code for Module omero.plugins.download

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  """ 
 4     download plugin 
 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 2007 Glencoe Software, Inc. All rights reserved. 
10     Use is subject to license terms supplied in LICENSE.txt 
11   
12  """ 
13   
14  import sys 
15  from omero.cli import BaseControl, CLI 
16   
17  HELP = """Download the given file id to the given filename""" 
18   
19   
20 -class DownloadControl(BaseControl):
21
22 - def _configure(self, parser):
23 parser.add_argument("id", help="OriginalFile id") 24 parser.add_argument( 25 "filename", help="Local filename to be saved to. '-' for stdout") 26 parser.set_defaults(func=self.__call__) 27 parser.add_login_arguments()
28
29 - def __call__(self, args):
30 from omero_model_OriginalFileI import OriginalFileI as OFile 31 32 orig_file = OFile(long(args.id)) 33 target_file = str(args.filename) 34 client = self.ctx.conn(args) 35 if target_file == "-": 36 client.download(orig_file, filehandle=sys.stdout) 37 sys.stdout.flush() 38 else: 39 client.download(orig_file, target_file)
40 41 try: 42 register("download", DownloadControl, HELP) 43 except NameError: 44 if __name__ == "__main__": 45 cli = CLI() 46 cli.register("download", DownloadControl, HELP) 47 cli.invoke(sys.argv[1:]) 48