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

Source Code for Module omero.plugins.chgrp

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  # 
 5  # Copyright (C) 2011 Glencoe Software, Inc. All Rights Reserved. 
 6  # Use is subject to license terms supplied in LICENSE.txt 
 7  # 
 8   
 9  """ 
10     chgrp plugin 
11   
12     Plugin read by omero.cli.Cli during initialization. The method(s) 
13     defined here will be added to the Cli class for later use. 
14  """ 
15   
16  from omero.cli import CLI, GraphControl, ExperimenterGroupArg 
17  import sys 
18   
19  HELP = """Move data between groups 
20   
21  Example Usage: 
22   
23    omero chgrp 101 /Image:1                     # Move all of Image 1 to \ 
24  group 101 
25    omero chgrp Group:101 /Image:1               # Move all of Image 1 to \ 
26  group 101 
27    omero chgrp ExperimenterGroup:101 /Image:1   # Move all of Image 1 to \ 
28  group 101 
29    omero chgrp "My Lab" /Image:1                # Move all of Image 1 to \ 
30  group "myLab" 
31   
32    omero chgrp --edit 101 /Image:1              # Open an editor with all \ 
33  the chgrp 
34                                                 # options filled out with \ 
35  defaults. 
36   
37    omero chgrp --opt /Image:KEEP /Plate:1       # Calls chgrp on Plate, \ 
38  leaving all 
39                                                 # images in the previous group. 
40   
41    What data is moved is the same as that which would be deleted by a similar 
42    call to "omero delete /Image:1" 
43   
44  """ 
45   
46   
47 -class ChgrpControl(GraphControl):
48
49 - def cmd_type(self):
50 import omero 51 import omero.all 52 return omero.cmd.Chgrp
53
54 - def _pre_objects(self, parser):
55 parser.add_argument( 56 "grp", nargs="?", type=ExperimenterGroupArg, 57 help="""Group to move objects to""")
58
59 - def _process_request(self, req, args, client):
60 req.grp = args.grp.lookup(client) 61 if req.grp is None: 62 self.ctx.die(196, "Failed to find group: %s" % args.grp.orig) 63 super(ChgrpControl, self)._process_request(req, args, client)
64 65 try: 66 register("chgrp", ChgrpControl, HELP) 67 except NameError: 68 if __name__ == "__main__": 69 cli = CLI() 70 cli.register("chgrp", ChgrpControl, HELP) 71 cli.invoke(sys.argv[1:]) 72