示例#1
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        sub = parser.sub()

        active = parser.add(
            sub,
            self.active,
            help="Return code shows if LDAP is configured (admins-only)")

        list = parser.add(sub, self.list, help="List all OMERO users with DNs")
        list.add_style_argument()

        getdn = parser.add(sub, self.getdn, help="Get DN for user on stdout")
        setdn = parser.add(
            sub,
            self.setdn,
            help="""Enable or disable LDAP login for user (admins only)

Once LDAP login is enabled for a user, the password set via OMERO is
ignored, and any attempt to change it will result in an error. When
you disable LDAP login, the previous password will be in effect, but if the
user never had a password, one will need to be set!""")

        for x in (getdn, setdn):
            self.add_user_and_group_arguments(x)
        setdn.add_argument("choice",
                           action="store",
                           help="Enable/disable LDAP login (true/false)")

        discover = parser.add(
            sub,
            self.discover,
            help="""Discover DNs for existing OMERO users or groups

This command works in the context of users or groups. Specifying
--groups will only discover groups, that is check which group exists in
the LDAP server and OMERO and has the "ldap" flag disabled - such groups
will be presented to the user. Omitting --groups will apply the same logic
to users.""")
        discover.add_argument("--commands",
                              action="store_true",
                              default=False,
                              help="Print setdn commands on standard out")
        discover.add_argument("--groups",
                              action="store_true",
                              default=False,
                              help="Discover LDAP groups, not users.")

        create = parser.add(
            sub,
            self.create,
            help="Create a local user based on LDAP username (admins only)")
        create.add_argument("username",
                            help="LDAP username of user to be created")

        for x in (active, list, getdn, setdn, discover, create):
            x.add_login_arguments()
示例#2
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        sub = parser.sub()

        active = parser.add(
            sub,
            self.active,
            help="Return code shows if LDAP is configured (admins-only)")

        list = parser.add(sub, self.list, help="List all OMERO users with DNs")
        list.add_style_argument()

        getdn = parser.add(sub, self.getdn, help="Get DN for user on stdout")
        setdn = parser.add(sub,
                           self.setdn,
                           help="""Set DN for user (admins only)

Once the DN is set for a user, the password set via OMERO is
ignored, and any attempt to change it will result in an error. When
you remove the DN, the previous password will be in effect, but if the
user never had a password, one will need to be set!""")

        for x in (getdn, setdn):
            x.add_argument("username", help="User's OMERO login name")
        setdn.add_argument(
            "dn",
            help="User's LDAP distinguished name. If empty, LDAP will"
            " be disabled for the user")

        discover = parser.add(
            sub,
            self.discover,
            help="Discover distinguished names for existing OMERO users")
        discover.add_argument("--commands",
                              action="store_true",
                              default=False,
                              help="Print setdn commands on standard out")
        discover.add_argument("--urls",
                              help="Override OMERO omero.ldap.urls setting")
        discover.add_argument("--base",
                              help="Override OMERO omero.ldap.base setting")

        create = parser.add(
            sub,
            self.create,
            help="Create a local user based on LDAP username (admins only)")
        create.add_argument("username",
                            help="LDAP username of user to be created")

        for x in (active, list, getdn, setdn, discover, create):
            x.add_login_arguments()
示例#3
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        sub = parser.sub()

        add = parser.add(sub, self.add, help="Add users")
        add.add_argument("--ignore-existing",
                         action="store_true",
                         default=False,
                         help="Do not fail if user already exists")
        add.add_argument("-m",
                         "--middlename",
                         help="Middle name, if available")
        add.add_argument("-e", "--email")
        add.add_argument("-i", "--institution")
        # Capitalized since conflict with main values
        add.add_argument("-P", "--userpassword", help="Password for user")
        add.add_argument("-a",
                         "--admin",
                         action="store_true",
                         help="Whether the user should be an admin")
        add.add_argument("username", help="User's login name")
        add.add_argument("firstname", help="User's given name")
        add.add_argument("lastname", help="User's surname name")
        add.add_argument("member_of",
                         nargs="+",
                         help="Groups which the user is to be a member of")

        list = parser.add(sub, self.list, help="List current users")

        password = parser.add(sub, self.password, help="Set user's password")
        password.add_argument("username",
                              nargs="?",
                              help="Username if not the current user")

        email = parser.add(sub, self.email, help="List users' email addresses")
        email.add_argument("-n",
                           "--names",
                           action="store_true",
                           default=False,
                           help="Print user names along with email addresses")
        email.add_argument("-1",
                           "--one",
                           action="store_true",
                           default=False,
                           help="Print one user per line")
        email.add_argument("-i",
                           "--ignore",
                           action="store_true",
                           default=False,
                           help="Ignore users without email addresses")
示例#4
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()
        parser.add_login_arguments()
        parser.add_argument("--file", help=SUPPRESS)
        parser.add_argument("command",
                            nargs="?",
                            choices=("new", "update", "null", "map-get",
                                     "map-set", "get"),
                            help="operation to be performed")
        parser.add_argument("Class",
                            nargs="?",
                            help="OMERO model object name, e.g. Project")
        parser.add_argument("fields",
                            nargs="*",
                            help="fields to be set, e.g. name=foo")
        parser.set_defaults(func=self.process)
示例#5
0
    def _configure(self, parser):
        # Add an exception handler
        self.exc = ExceptionHandler()

        # Add default login arguments, prompting the user for
        # server login credentials
        parser.add_login_arguments()

        # Add some 'commands', i.e. operations the plugin can perform
        parser.add_argument(
            "command", nargs="?",
            choices=("foo", "bar"),
            help="Some operation to be performed")

        # Add an additional argument
        parser.add_argument(
            "--some_argument", help="An additional argument")

        parser.set_defaults(func=self.process)
示例#6
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        PERM_TXT = """

Group permissions come in several styles:

    * private       (rw----)   [DEFAULT]
    * read-only     (rwr---)
    * read-annotate (rwra--)   [Previously known as 'collaborative']

In private groups, only group and system administrators will be able
to view someone else's data. In read-only groups, other group members
can see data but not annotate or modify it. In read-annotate groups,
annotation is permitted by group members.

More information is available at:

    https://www.openmicroscopy.org/site/support/omero4/sysadmins/server-permissions.html
        """

        OWNER_TXT = """

Your group may have one or more owners. The group owner has some additional
rights within each group than a standard group member, including the ability
to add other members to the group.

More information is available at:

    https://www.openmicroscopy.org/site/support/omero4/sysadmins/server-permissions.html
        """

        parser.add_login_arguments()
        sub = parser.sub()
        add = parser.add(sub, self.add,
                         "Add a new group with given permissions " + PERM_TXT)
        add.add_argument("--ignore-existing",
                         action="store_true",
                         default=False,
                         help="Do not fail if user already exists")
        add.add_argument("name", help="Name of the group")
        self.add_permissions_arguments(add)

        perms = parser.add(sub, self.perms,
                           "Modify a group's permissions " + PERM_TXT)
        self.add_group_arguments(perms)
        self.add_permissions_arguments(perms)

        list = parser.add(sub, self.list, "List current groups")
        printgroup = list.add_mutually_exclusive_group()
        printgroup.add_argument(
            "--count",
            action="store_true",
            help="Print count of all users and owners (default)",
            default=True)
        printgroup.add_argument(
            "--long",
            action="store_true",
            help="Print comma-separated list of all users and owners",
            default=False)
        sortgroup = list.add_mutually_exclusive_group()
        sortgroup.add_argument("--sort-by-id",
                               action="store_true",
                               default=True,
                               help="Sort groups by ID (default)")
        sortgroup.add_argument("--sort-by-name",
                               action="store_true",
                               default=False,
                               help="Sort groups by name")

        copyusers = parser.add(sub, self.copyusers,
                               "Copy the users of one group to another group")
        copyusers.add_argument(
            "from_group",
            help="ID or name of the source group whose users will be copied")
        copyusers.add_argument(
            "to_group",
            help=
            "ID or name of the target group which will have new users added")
        copyusers.add_argument("--as-owner",
                               action="store_true",
                               default=False,
                               help="Copy the group owners only")

        adduser = parser.add(sub, self.adduser,
                             "Add one or more users to a group")
        self.add_group_arguments(adduser)
        group = self.add_user_arguments(adduser, "add to the group")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Add the users as owners of the group")

        removeuser = parser.add(sub, self.removeuser,
                                "Remove one or more users from a group")
        self.add_group_arguments(removeuser)
        group = self.add_user_arguments(removeuser, "remove from the group")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Remove the users from the group owner list")

        for x in (add, perms, list, copyusers, adduser, removeuser):
            x.add_login_arguments()
示例#7
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        parser.add_login_arguments()
        sub = parser.sub()

        add = parser.add(sub, self.add, help="Add user")
        add.add_argument("--ignore-existing",
                         action="store_true",
                         default=False,
                         help="Do not fail if user already exists")
        add.add_argument("-m",
                         "--middlename",
                         help="Middle name, if available")
        add.add_argument("-e", "--email")
        add.add_argument("-i", "--institution")
        # Capitalized since conflict with main values
        add.add_argument("-a",
                         "--admin",
                         action="store_true",
                         help="Whether the user should be an admin")
        add.add_argument("username", help="User's login name")
        add.add_argument("firstname", help="User's first name")
        add.add_argument("lastname", help="User's last name")
        self.add_group_arguments(add, " to join")

        password_group = add.add_mutually_exclusive_group()
        password_group.add_argument("-P",
                                    "--userpassword",
                                    help="Password for user")
        password_group.add_argument("--no-password",
                                    action="store_true",
                                    default=False,
                                    help="Create user with empty password")

        list = parser.add(sub,
                          self.list,
                          help="List information about all users")

        info = parser.add(
            sub, self.info,
            "List information about the user(s). Default to the context user")
        self.add_user_arguments(info)

        for x in (list, info):
            x.add_style_argument()
            x.add_group_print_arguments()
            x.add_user_sorting_arguments()

        listgroups = parser.add(
            sub, self.listgroups,
            "List the groups of the user. Default to the context user")
        self.add_user_arguments(listgroups)
        listgroups.add_style_argument()
        listgroups.add_user_print_arguments()
        listgroups.add_group_sorting_arguments()

        password = parser.add(sub, self.password, help="Set user's password")
        password.add_argument("username",
                              nargs="?",
                              help="Username if not the current user")

        email = parser.add(sub, self.email, help="List users' email addresses")
        email.add_argument("-n",
                           "--names",
                           action="store_true",
                           default=False,
                           help="Print user names along with email addresses")
        email.add_argument("-1",
                           "--one",
                           action="store_true",
                           default=False,
                           help="Print one user per line")
        email.add_argument("-i",
                           "--ignore",
                           action="store_true",
                           default=False,
                           help="Ignore users without email addresses")
        email.add_argument(
            "--all",
            action="store_true",
            default=False,
            help="Include all users, including deactivated accounts")

        joingroup = parser.add(sub, self.joingroup, "Join one or more groups")
        self.add_id_name_arguments(joingroup,
                                   "user. Default to the current user")
        group = self.add_group_arguments(joingroup, " to join")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Join the group(s) as an owner")

        leavegroup = parser.add(sub, self.leavegroup,
                                "Leave one or more groups")
        self.add_id_name_arguments(leavegroup,
                                   "user. Default to the current user")
        group = self.add_group_arguments(leavegroup, " to leave")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Leave the owner list of the group(s)")

        for x in (email, password, list, add, joingroup, leavegroup):
            x.add_login_arguments()
示例#8
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        PERM_TXT = """

Group permissions come in several styles:

    * private       (rw----)   [DEFAULT]
    * read-only     (rwr---)
    * read-annotate (rwra--)   [Previously known as 'collaborative']
    * read-write    (rwrw--)

In private groups, only group owners and system administrators will be
able to view someone else's data. In read-only groups, other group members
can see data but not annotate or modify it. In read-annotate groups,
annotation is permitted by group members. In read-write groups, all
group members can behave as if they co-own all the data.

Changing a group to private unlinks data from other users' containers and
unlinks other users' annotations from data. The change to private will
fail if different users' data is too closely related to be separated.

More information is available at:
https://docs.openmicroscopy.org/latest/omero/sysadmins/\
server-permissions.html
        """

        parser.add_login_arguments()
        sub = parser.sub()
        add = parser.add(sub, self.add,
                         "Add a new group with given permissions " + PERM_TXT)
        add.add_argument("--ignore-existing",
                         action="store_true",
                         default=False,
                         help="Do not fail if user already exists")
        add.add_argument("name", help="Name of the group")
        self.add_permissions_arguments(add)

        perms = parser.add(sub, self.perms,
                           "Modify a group's permissions " + PERM_TXT)
        self.add_id_name_arguments(perms, "group")
        self.add_permissions_arguments(perms)

        list = parser.add(sub,
                          self.list,
                          help="List information about all groups")

        info = parser.add(
            sub, self.info,
            "List information about the group(s). Default to the context"
            " group")
        self.add_group_arguments(info)

        for x in (list, info):
            x.add_style_argument()
            x.add_user_print_arguments()
            x.add_group_sorting_arguments()

        listusers = parser.add(sub, self.listusers,
                               "List users of the current group")
        self.add_group_arguments(listusers)
        listusers.add_style_argument()
        listusers.add_group_print_arguments()
        listusers.add_user_sorting_arguments()

        copyusers = parser.add(
            sub, self.copyusers, "Copy the users of one"
            " group to another group")
        copyusers.add_argument("from_group",
                               help="ID or name of the source"
                               " group whose users will be copied")
        copyusers.add_argument("to_group",
                               help="ID or name of the target"
                               " group which will have new users added")
        copyusers.add_argument("--as-owner",
                               action="store_true",
                               default=False,
                               help="Copy the group owners only")

        adduser = parser.add(sub, self.adduser,
                             "Add one or more users to a group")
        self.add_id_name_arguments(adduser, "group")
        group = self.add_user_arguments(adduser, action=" to add to the group")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Add the users as owners of the group")

        removeuser = parser.add(sub, self.removeuser,
                                "Remove one or more users from a group")
        self.add_id_name_arguments(removeuser, "group")
        group = self.add_user_arguments(removeuser,
                                        action=" to remove from the group")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Remove the users from the group owner list")

        for x in (add, perms, list, copyusers, adduser, removeuser):
            x.add_login_arguments()
示例#9
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        parser.add_login_arguments()
        sub = parser.sub()

        add = parser.add(sub, self.add, help="Add user")
        add.add_argument("--ignore-existing",
                         action="store_true",
                         default=False,
                         help="Do not fail if user already exists")
        add.add_argument("-m",
                         "--middlename",
                         help="Middle name, if available")
        add.add_argument("-e", "--email")
        add.add_argument("-i", "--institution")
        # Capitalized since conflict with main values
        add.add_argument("-a",
                         "--admin",
                         action="store_true",
                         help="Whether the user should be an admin")
        add.add_argument("username", help="User's login name")
        add.add_argument("firstname", help="User's given name")
        add.add_argument("lastname", help="User's surname name")
        self.add_group_arguments(add, "join", "the group as an owner")

        password_group = add.add_mutually_exclusive_group()
        password_group.add_argument("-P",
                                    "--userpassword",
                                    help="Password for user")
        password_group.add_argument("--no-password",
                                    action="store_true",
                                    default=False,
                                    help="Create user with empty password")

        list = parser.add(sub, self.list, help="List current users")
        list.add_style_argument()

        printgroup = list.add_mutually_exclusive_group()
        printgroup.add_argument(
            "--long",
            action="store_true",
            default=True,
            help="Print comma-separated list of all groups (default)")
        printgroup.add_argument("--count",
                                action="store_true",
                                default=False,
                                help="Print count of all groups")

        sortgroup = list.add_mutually_exclusive_group()
        sortgroup.add_argument("--sort-by-id",
                               action="store_true",
                               default=True,
                               help="Sort users by ID (default)")
        sortgroup.add_argument("--sort-by-login",
                               action="store_true",
                               default=False,
                               help="Sort users by login")
        sortgroup.add_argument("--sort-by-first-name",
                               action="store_true",
                               default=False,
                               help="Sort users by first name")
        sortgroup.add_argument("--sort-by-last-name",
                               action="store_true",
                               default=False,
                               help="Sort users by last name")
        sortgroup.add_argument("--sort-by-email",
                               action="store_true",
                               default=False,
                               help="Sort users by email")

        password = parser.add(sub, self.password, help="Set user's password")
        password.add_argument("username",
                              nargs="?",
                              help="Username if not the current user")

        email = parser.add(sub, self.email, help="List users' email addresses")
        email.add_argument("-n",
                           "--names",
                           action="store_true",
                           default=False,
                           help="Print user names along with email addresses")
        email.add_argument("-1",
                           "--one",
                           action="store_true",
                           default=False,
                           help="Print one user per line")
        email.add_argument("-i",
                           "--ignore",
                           action="store_true",
                           default=False,
                           help="Ignore users without email addresses")
        email.add_argument(
            "--all",
            action="store_true",
            default=False,
            help="Include all users, including deactivated accounts")

        joingroup = parser.add(sub, self.joingroup, "Join one or more groups")
        self.add_user_arguments(joingroup)
        group = self.add_group_arguments(joingroup, "join")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Join the group(s) as an owner")

        leavegroup = parser.add(sub, self.leavegroup,
                                "Leave one or more groups")
        self.add_user_arguments(leavegroup)
        group = self.add_group_arguments(leavegroup, "leave")
        group.add_argument("--as-owner",
                           action="store_true",
                           default=False,
                           help="Leave the owner list of the group(s)")

        for x in (email, password, list, add, joingroup, leavegroup):
            x.add_login_arguments()
示例#10
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        parser.add_login_arguments()
        sub = parser.sub()

        listtags = parser.add(sub,
                              self.list,
                              help="List all the tags, grouped by tagset")
        self.add_standard_params(listtags)
        listtags.add_argument("--tagset",
                              nargs="+",
                              type=int,
                              help="One or more tagset IDs")
        self.add_tag_common_params(listtags)
        listtags.add_login_arguments()

        listsets = parser.add(sub, self.listsets, help="List tag sets")
        self.add_standard_params(listsets)
        listsets.add_argument(
            "--tag",
            nargs="+",
            type=int,
            help="List only tagsets containing the following tag ID(s)")
        self.add_tag_common_params(listsets)
        listsets.add_login_arguments()

        create = parser.add(sub, self.create, help="Create a new tag")
        self.add_newtag_params(create)
        create.add_login_arguments()

        createset = parser.add(sub,
                               self.createset,
                               help="Create a new tag set")
        createset.add_argument(
            "--tag",
            nargs="+",
            required=True,
            type=int,
            help="ID(s) of the tag(s) to include in this set")
        self.add_newtag_params(createset)
        createset.add_login_arguments()

        loadj = sub.add_parser(
            self.load.__func__.__name__,
            help="Import new tag(s) and tagset(s) from JSON file",
            description="Import new tag(s) and tagset(s) from JSON file",
            epilog="""
JSON File Format:
  The format of the JSON file should be as follows:

  [{
    "name" : "Name of the tagset",
    "desc" : "Description of the tagset",
    "set" : [{
        "name" : "Name of tag",
        "desc" : "Description of tag"
    },{
        "name" : "Name of tag",
        "desc" : "Description of tag"
    },{
        ....
  },{
    ....
  }]
            """)
        loadj.set_defaults(func=self.load)
        loadj.add_argument("filename",
                           nargs="?",
                           help="The filename containing tag JSON")
        loadj.add_login_arguments()

        links = parser.add(sub, self.link, help="Link annotation to an object")
        links.add_argument("object",
                           help="The object to link to. Should be of form"
                           " <object_type>:<object_id>")
        links.add_argument('tag_id', type=int, help="The tag annotation ID")
        self.add_standard_params(links)
        links.add_login_arguments()
示例#11
0
    def _configure(self, parser):

        self.exc = ExceptionHandler()

        PERM_TXT = """Group permissions come in several styles:

    * private (rw----)   [DEFAULT]
    * read-only (rwr---)
    * read-annotate (rwra--)   [Previously known as 'collaborative']

In private groups, only group and system administrators will be able
to view someone else's data. In read-only groups, other group members
can see data but not annotate or modify it. In read-annotate groups,
annotation is permitted by group members.

More information is available at:

    http://www.openmicroscopy.org/site/support/omero4/server/permissions
        """
        sub = parser.sub()
        add = parser.add(sub, self.add,
                         "Add a new group with given permissions. " + PERM_TXT)
        add.add_argument("--ignore-existing",
                         action="store_true",
                         default=False,
                         help="Do not fail if user already exists")
        add.add_argument("name", help="ExperimenterGroup.name value")

        perms = parser.add(sub, self.perms,
                           "Modify a group's permissions. " + PERM_TXT)
        perms.add_argument("id_or_name", help="ExperimenterGroup's id or name")

        for x in (add, perms):
            group = x.add_mutually_exclusive_group()
            group.add_argument(
                "--perms",
                help="Group permissions set as string, e.g. 'rw----' ")
            group.add_argument("--type",
                               help="Group permission set symbollically",
                               default="private",
                               choices=("private", "read-only",
                                        "read-annotate", "collaborative"))

        list = parser.add(sub, self.list, "List current groups")
        list.add_argument(
            "--long",
            action="store_true",
            help="Print comma-separated list of all groups, not just counts")

        copy = parser.add(sub, self.copy,
                          "Copy the members of one group to another group")
        copy.add_argument(
            "from_group",
            help="Source group ID or NAME whose members will be copied")
        copy.add_argument(
            "to_group",
            help="Target group ID or NAME which will have new members added")

        insert = parser.add(sub, self.insert,
                            "Insert one or more users into a group")
        insert.add_argument(
            "GROUP",
            metavar="group",
            help="ID or NAME of the group which is to have users added")
        insert.add_argument("USER",
                            metavar="user",
                            nargs="+",
                            help="ID or NAME of user to be inserted")

        remove = parser.add(sub, self.remove,
                            "remove one or more users from a group")
        remove.add_argument(
            "GROUP",
            metavar="group",
            help="ID or NAME of the group which is to have users removed")
        remove.add_argument("USER",
                            metavar="user",
                            nargs="+",
                            help="ID or NAME of user to be removed")