1
2
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
21
28
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