1
2 """
3 download 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 import sys
14 from omero.cli import BaseControl, CLI
15
16 HELP = """Download the given file id to the given filename"""
17
19
24
26 from omero_model_OriginalFileI import OriginalFileI as OFile
27
28 orig_file = OFile(long(args.id))
29 target_file = str(args.filename)
30 client = self.ctx.conn(args)
31 if target_file == "-":
32 client.download(orig_file, filehandle = sys.stdout)
33 sys.stdout.flush()
34 else:
35 client.download(orig_file, target_file)
36
37 try:
38 register("download", DownloadControl, HELP)
39 except NameError:
40 if __name__ == "__main__":
41 cli = CLI()
42 cli.register("download", DownloadControl, HELP)
43 cli.invoke(sys.argv[1:])
44