コード例 #1
0
def populate_shape(o, set_unit_attributes=True):
    o.fillColor = rint(0xFFFFFFFF)
    o.fillRule = rstring("solid")
    o.fontFamily = rstring("cursive")
    if set_unit_attributes:
        o.fontSize = LengthI(12, UnitsLength.POINT)
    o.fontStyle = rstring("italic")
    o.locked = rbool(False)
    o.strokeColor = rint(0xFFFF0000)
    o.strokeDashArray = rstring("inherit")
    if SCHEMA_VERSION == "2015-01":
        o.visibility = rbool(True)
        o.strokeLineCap = rstring("round")
    if set_unit_attributes:
        o.strokeWidth = LengthI(4, UnitsLength.PIXEL)
    o.textValue = rstring("the_text")
    o.theC = rint(1)
    o.theT = rint(2)
    o.theZ = rint(3)
    t = identity_transform()
    if SCHEMA_VERSION == "2015-01":
        o.transform = t.svg_transform
    else:
        o.transform = t
    return o
コード例 #2
0
def populate_shape(o, set_unit_attributes=True):
    o.fillColor = rint(0xffffffff)
    o.fillRule = rstring('solid')
    o.fontFamily = rstring('cursive')
    if set_unit_attributes:
        o.fontSize = LengthI(12, UnitsLength.POINT)
    o.fontStyle = rstring('italic')
    o.locked = rbool(False)
    o.strokeColor = rint(0xffff0000)
    o.strokeDashArray = rstring('inherit')
    if SCHEMA_VERSION == '2015-01':
        o.visibility = rbool(True)
        o.strokeLineCap = rstring('round')
    if set_unit_attributes:
        o.strokeWidth = LengthI(4, UnitsLength.PIXEL)
    o.textValue = rstring('the_text')
    o.theC = rint(1)
    o.theT = rint(2)
    o.theZ = rint(3)
    t = identity_transform()
    if SCHEMA_VERSION == '2015-01':
        o.transform = t.svg_transform
    else:
        o.transform = t
    return o
コード例 #3
0
    def testGroupOwners(self):
        # this is the test of creating private group and updating it
        # including changes in #1434
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # create group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        p = PermissionsI()
        p.setUserRead(True)
        p.setUserWrite(True)
        p.setGroupRead(True)
        p.setGroupAnnotate(False)
        p.setGroupWrite(False)
        p.setWorldRead(False)
        p.setWorldAnnotate(False)
        p.setWorldWrite(False)
        new_gr1.details.permissions = p
        g1_id = admin.createGroup(new_gr1)
        gr1 = admin.getGroup(g1_id)

        # create user1
        new_exp1 = ExperimenterI()
        new_exp1.omeName = rstring("user1_%s" % uuid)
        new_exp1.firstName = rstring("New")
        new_exp1.lastName = rstring("Test")
        new_exp1.ldap = rbool(False)
        new_exp1.email = rstring("*****@*****.**")

        uuid = self.uuid()
        uuidGroup = ExperimenterGroupI()
        uuidGroup.name = rstring(uuid)
        uuidGroup.ldap = rbool(False)
        uuidGroupId = admin.createGroup(uuidGroup)
        uuidGroup = ExperimenterGroupI(uuidGroupId, False)
        listOfGroups = list()
        listOfGroups.append(admin.lookupGroup("user"))
        eid1 = admin.createExperimenterWithPassword(
            new_exp1, rstring("ome"), uuidGroup, listOfGroups)
        exp1 = admin.getExperimenter(eid1)

        # set owner of the group (user is not a member of)
        admin.addGroupOwners(gr1, [exp1])
        # chech if is the leader
        leaderOfGroups = admin.getLeaderOfGroupIds(exp1)
        assert gr1.id.val in leaderOfGroups

        # remove group owner
        admin.removeGroupOwners(gr1, [exp1])
        # chech if no longer is the leader
        leaderOfGroups = admin.getLeaderOfGroupIds(exp1)
        assert gr1.id.val not in leaderOfGroups

        """
コード例 #4
0
    def testGroupOwners(self):
        # this is the test of creating private group and updating it
        # including changes in #1434
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # create group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        p = PermissionsI()
        p.setUserRead(True)
        p.setUserWrite(True)
        p.setGroupRead(True)
        p.setGroupAnnotate(False)
        p.setGroupWrite(False)
        p.setWorldRead(False)
        p.setWorldAnnotate(False)
        p.setWorldWrite(False)
        new_gr1.details.permissions = p
        g1_id = admin.createGroup(new_gr1)
        gr1 = admin.getGroup(g1_id)

        # create user1
        new_exp1 = ExperimenterI()
        new_exp1.omeName = rstring("user1_%s" % uuid)
        new_exp1.firstName = rstring("New")
        new_exp1.lastName = rstring("Test")
        new_exp1.ldap = rbool(False)
        new_exp1.email = rstring("*****@*****.**")

        uuid = self.uuid()
        uuidGroup = ExperimenterGroupI()
        uuidGroup.name = rstring(uuid)
        uuidGroup.ldap = rbool(False)
        uuidGroupId = admin.createGroup(uuidGroup)
        uuidGroup = ExperimenterGroupI(uuidGroupId, False)
        listOfGroups = list()
        listOfGroups.append(admin.lookupGroup("user"))
        eid1 = admin.createExperimenterWithPassword(new_exp1, rstring("ome"),
                                                    uuidGroup, listOfGroups)
        exp1 = admin.getExperimenter(eid1)

        # set owner of the group (user is not a member of)
        admin.addGroupOwners(gr1, [exp1])
        # chech if is the leader
        leaderOfGroups = admin.getLeaderOfGroupIds(exp1)
        assert gr1.id.val in leaderOfGroups

        # remove group owner
        admin.removeGroupOwners(gr1, [exp1])
        # chech if no longer is the leader
        leaderOfGroups = admin.getLeaderOfGroupIds(exp1)
        assert gr1.id.val not in leaderOfGroups
        """
コード例 #5
0
 def create_settings(self):
     settings = omero.grid.ImportSettings()
     settings.doThumbnails = rbool(True)
     settings.noStatsInfo = rbool(False)
     settings.userSpecifiedTarget = None
     settings.userSpecifiedName = None
     settings.userSpecifiedDescription = None
     settings.userSpecifiedAnnotationList = None
     settings.userSpecifiedPixels = None
     settings.checksumAlgorithm = omero.model.ChecksumAlgorithmI()
     settings.checksumAlgorithm.value = omero.rtypes.rstring("SHA1-160")
     return settings
コード例 #6
0
 def create_settings(self):
     settings = omero.grid.ImportSettings()
     settings.doThumbnails = rbool(True)
     settings.noStatsInfo = rbool(False)
     settings.userSpecifiedTarget = None
     settings.userSpecifiedName = None
     settings.userSpecifiedDescription = None
     settings.userSpecifiedAnnotationList = None
     settings.userSpecifiedPixels = None
     settings.checksumAlgorithm = omero.model.ChecksumAlgorithmI()
     settings.checksumAlgorithm.value = omero.rtypes.rstring("SHA1-160")
     return settings
コード例 #7
0
def create_settings(name=None):
    """Create ImportSettings and set some values."""
    settings = omero.grid.ImportSettings()
    settings.doThumbnails = rbool(True)
    settings.noStatsInfo = rbool(False)
    settings.userSpecifiedTarget = None
    settings.userSpecifiedName = None if not name else rstring(name)
    settings.userSpecifiedDescription = None
    settings.userSpecifiedAnnotationList = None
    settings.userSpecifiedPixels = None
    settings.checksumAlgorithm = ChecksumAlgorithmI()
    s = rstring(ChecksumAlgorithmSHA1160)
    settings.checksumAlgorithm.value = s
    return settings
コード例 #8
0
ファイル: scripts.py プロジェクト: chris-allan/omero-py
def parse_input(input_string, params):
    """
    Parse a single input_string. The params
    """
    parts = input_string.split("=")
    if len(parts) == 1:
        parts.append("")
    key = parts[0]
    val = parts[1]

    param = params.inputs.get(key)
    if param is None:
        return {}
    elif isinstance(param.prototype, omero.RBool):
        if val.lower() in ("false", "False", "0", ""):
            val = rbool(False)
        else:
            val = rbool(True)
    elif isinstance(
        param.prototype,
        (omero.RLong, omero.RString, omero.RInt,
         omero.RTime, omero.RDouble, omero.RFloat)):
        val = param.prototype.__class__(val)
    elif isinstance(param.prototype, (omero.RList, omero.RSet)):
        rmethod = omero.rtypes.rlist
        rwrap = omero.rtypes.wrap
        if isinstance(param.prototype, omero.RSet):
            rmethod = omero.rtypes.rset
        if len(param.prototype.val) > 0:
            rwrap = param.prototype.val[0].__class__
        items = val.split(",")
        val = rmethod([rwrap(x) for x in items])
    elif isinstance(param.prototype, omero.RObject):
        try:
            parts2 = val.split(":")
            kls = parts2[0]
            _id = int(parts2[1])
            if not kls.endswith("I"):
                kls = "%sI" % kls
            kls = getattr(omero.model, kls)
        except:
            raise ValueError(
                "Format for objects: Class:id or ClassI:id. Not:%s" % val)
        val = omero.rtypes.robject(kls(_id, False))
    else:
        raise ValueError("No converter for: %s (type=%s)"
                         % (key, param.prototype.__class__))

    return {key: val}
コード例 #9
0
ファイル: test_rtypes.py プロジェクト: mtbc/omero-py
 def testGetAttrWorks(self):
     rbool(True).val
     rdouble(0.0).val
     rfloat(0.0).val
     rint(0).val
     rlong(0).val
     rtime(0).val
     rinternal(None).val
     robject(None).val
     rstring("").val
     rclass("").val
     rarray().val
     rlist().val
     rset().val
     rmap().val
コード例 #10
0
 def testGetAttrWorks(self):
     rbool(True).val
     rdouble(0.0).val
     rfloat(0.0).val
     rint(0).val
     rlong(0).val
     rtime(0).val
     rinternal(None).val
     robject(None).val
     rstring("").val
     rclass("").val
     rarray().val
     rlist().val
     rset().val
     rmap().val
コード例 #11
0
ファイル: scripts.py プロジェクト: patrick330602/fomf3dbd
def parse_input(input_string, params):
    """
    Parse a single input_string. The params
    """
    parts = input_string.split("=")
    if len(parts) == 1:
        parts.append("")
    key = parts[0]
    val = parts[1]

    param = params.inputs.get(key)
    if param is None:
        return {}
    elif isinstance(param.prototype, omero.RBool):
        if val.lower() in ("false", "False", "0", ""):
            val = rbool(False)
        else:
            val = rbool(True)
    elif isinstance(param.prototype,
                    (omero.RLong, omero.RString, omero.RInt, omero.RTime,
                     omero.RDouble, omero.RFloat)):
        val = param.prototype.__class__(val)
    elif isinstance(param.prototype, omero.RList):
        items = val.split(",")
        if len(param.prototype.val) == 0:
            # Don't know what needs to be added here, so calling wrap
            # which will produce an rlist of rstrings.
            val = omero.rtypes.wrap(items)
        else:
            p = param.prototype.val[0]
            val = omero.rtypes.rlist([p.__class__(x) for x in items])
    elif isinstance(param.prototype, omero.RObject):
        try:
            parts2 = val.split(":")
            kls = parts2[0]
            _id = long(parts2[1])
            if not kls.endswith("I"):
                kls = "%sI" % kls
            kls = getattr(omero.model, kls)
        except:
            raise ValueError(
                "Format for objects: Class:id or ClassI:id. Not:%s" % val)
        val = omero.rtypes.robject(kls(_id, False))
    else:
        raise ValueError("No converter for: %s (type=%s)" %
                         (key, param.prototype.__class__))

    return {key: val}
コード例 #12
0
    def new_user(self, group=None, perms=None,
                 admin=False, system=False):
        """
        admin: If user is to be an admin of the created group
        system: If user is to be a system admin
        """

        if not self.root:
            raise Exception('No root client. Cannot create user')

        adminService = self.root.getSession().getAdminService()
        name = self.uuid()

        # Create group if necessary
        if not group:
            g = self.new_group(perms=perms)
        else:
            g = group

        # Create user
        e = omero.model.ExperimenterI()
        e.omeName = rstring(name)
        e.firstName = rstring(name)
        e.lastName = rstring(name)
        e.ldap = rbool(False)
        uid = adminService.createExperimenterWithPassword(
            e, rstring(name), g, [g, adminService.lookupGroup('user')])
        e = adminService.lookupExperimenter(name)
        if admin:
            adminService.setGroupOwner(g, e)
        if system:
            adminService.addGroups(e,
                                   [omero.model.ExperimenterGroupI(0, False)])

        return adminService.getExperimenter(uid)
コード例 #13
0
    def new_user(self, group=None, perms=None, admin=False, system=False):
        """
        admin: If user is to be an admin of the created group
        system: If user is to be a system admin
        """

        if not self.root:
            raise Exception("No root client. Cannot create user")

        adminService = self.root.getSession().getAdminService()
        name = self.uuid()

        # Create group if necessary
        if not group:
            g = self.new_group(perms=perms)
        else:
            g = group

        # Create user
        e = omero.model.ExperimenterI()
        e.omeName = rstring(name)
        e.firstName = rstring(name)
        e.lastName = rstring(name)
        e.ldap = rbool(False)
        uid = adminService.createExperimenterWithPassword(e, rstring(name), g, [g, adminService.lookupGroup("user")])
        e = adminService.lookupExperimenter(name)
        if admin:
            adminService.setGroupOwner(g, e)
        if system:
            adminService.addGroups(e, [omero.model.ExperimenterGroupI(0, False)])

        return adminService.getExperimenter(uid)
コード例 #14
0
ファイル: ldap.py プロジェクト: joansmith/openmicroscopy
    def setdn(self, args):
        c = self.ctx.conn(args)
        iupdate = c.sf.getUpdateService()
        iadmin = c.sf.getAdminService()

        obj = None

        if args.user_name:
            [uid, obj] = self.find_user_by_name(iadmin,
                                                args.user_name,
                                                fatal=True)
        elif args.user_id:
            [uid, obj] = self.find_user_by_id(iadmin, args.user_id, fatal=True)
        elif args.group_name:
            [gid, obj] = self.find_group_by_name(iadmin,
                                                 args.group_name,
                                                 fatal=True)
        elif args.group_id:
            [gid, obj] = self.find_group_by_id(iadmin,
                                               args.group_id,
                                               fatal=True)

        if obj is not None:
            obj.setLdap(rbool(args.choice.lower() in ("yes", "true", "t",
                                                      "1")))
            iupdate.saveObject(obj)
コード例 #15
0
    def testCreatAndUpdatePublicGroup(self):
        # this is the test of creating public group and updating it
        # including changes in #1434
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # create group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        p = PermissionsI()
        p.setUserRead(True)
        p.setUserWrite(True)
        p.setGroupRead(True)
        p.setGroupWrite(True)
        p.setWorldRead(False)
        p.setWorldAnnotate(False)
        p.setWorldWrite(False)
        new_gr1.details.permissions = p
        g1_id = admin.createGroup(new_gr1)

        # update name of group1
        gr1 = admin.getGroup(g1_id)
        assert 'rwrw--' == str(gr1.details.permissions)
        new_name = "changed_name_group1_%s" % uuid
        gr1.name = rstring(new_name)
        admin.updateGroup(gr1)
        gr1_u = admin.getGroup(g1_id)
        assert new_name == gr1_u.name.val
コード例 #16
0
    def setdn(self, args):
        c = self.ctx.conn(args)
        iupdate = c.sf.getUpdateService()
        iadmin = c.sf.getAdminService()

        obj = None

        if args.user_name:
            [uid, obj] = self.find_user_by_name(iadmin,
                                                args.user_name,
                                                fatal=True)
        elif args.user_id:
            [uid, obj] = self.find_user_by_id(iadmin, args.user_id, fatal=True)
        elif args.group_name:
            [gid, obj] = self.find_group_by_name(iadmin,
                                                 args.group_name,
                                                 fatal=True)
        elif args.group_id:
            [gid, obj] = self.find_group_by_id(iadmin,
                                               args.group_id,
                                               fatal=True)

        if obj is not None:
            from omero.model import Experimenter, ExperimenterGroup
            obj.setLdap(rbool(args.choice.lower() in ("yes", "true", "t",
                                                      "1")))
            if isinstance(obj, ExperimenterGroup):
                self.update_group(iupdate, obj)
            elif isinstance(obj, Experimenter):
                self.update_user(iupdate, obj)
コード例 #17
0
    def testCreatAndUpdatePublicGroup(self):
        # this is the test of creating public group and updating it
        # including changes in #1434
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # create group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        p = PermissionsI()
        p.setUserRead(True)
        p.setUserWrite(True)
        p.setGroupRead(True)
        p.setGroupWrite(True)
        p.setWorldRead(False)
        p.setWorldAnnotate(False)
        p.setWorldWrite(False)
        new_gr1.details.permissions = p
        g1_id = admin.createGroup(new_gr1)

        # update name of group1
        gr1 = admin.getGroup(g1_id)
        assert 'rwrw--' == str(gr1.details.permissions)
        new_name = "changed_name_group1_%s" % uuid
        gr1.name = rstring(new_name)
        admin.updateGroup(gr1)
        gr1_u = admin.getGroup(g1_id)
        assert new_name == gr1_u.name.val
コード例 #18
0
ファイル: test_rtypes.py プロジェクト: fireofearth/omero-py
 def testConversionMethod(self):
     assert None == rtype(None)
     assert rlong(1) == rtype(rlong(1))  # Returns self
     assert rbool(True) == rtype(True)
     # Unsupported
     # assert rdouble(0) == rtype(Double.valueOf(0))
     assert rfloat(0) == rtype(float(0))
     if sys.version_info < (3, 0, 0):
         assert rlong(0) == rtype(long(0))
     else:
         assert rint(0) == rtype(long(0))
     assert rint(0) == rtype(int(0))
     assert rstring("string") == rtype("string")
     # Unsupported
     # assert rtime(time) == rtype(new Timestamp(time))
     rtype(omero.model.ImageI())
     rtype(omero.grid.JobParams())
     rtype(set([rlong(1)]))
     rtype(list([rlong(2)]))
     rtype({})
     # Unsupported
     # rtype(array)
     try:
         rtype(())
         assert False, "Shouldn't be able to handle this yet"
     except omero.ClientError:
         pass
コード例 #19
0
ファイル: conftest.py プロジェクト: chris-allan/omero-marshal
def populate_shape(o):
    o.fillColor = rint(0xffffffff)
    o.fillRule = rstring('solid')
    o.fontFamily = rstring('cursive')
    o.fontSize = LengthI(12, UnitsLength.POINT)
    o.fontStyle = rstring('italic')
    o.locked = rbool(False)
    o.strokeColor = rint(0xffff0000)
    o.strokeDashArray = rstring('inherit')
    o.strokeLineCap = rstring('round')
    o.strokeWidth = LengthI(4, UnitsLength.PIXEL)
    o.textValue = rstring('the_text')
    o.theC = rint(1)
    o.theT = rint(2)
    o.theZ = rint(3)
    o.visibility = rbool(True)
    return o
コード例 #20
0
ファイル: scripts.py プロジェクト: kok26th/openmicroscopy
def parse_input(input_string, params):
    """
    Parse a single input_string. The params
    """
    parts = input_string.split("=")
    if len(parts) == 1:
        parts.append("")
    key = parts[0]
    val = parts[1]

    param = params.inputs.get(key)
    if param is None:
        return {}
    elif isinstance(param.prototype, omero.RBool):
        if val.lower() in ("false", "False", "0", ""):
            val = rbool(False)
        else:
            val = rbool(True)
    elif isinstance(
        param.prototype, (omero.RLong, omero.RString, omero.RInt, omero.RTime, omero.RDouble, omero.RFloat)
    ):
        val = param.prototype.__class__(val)
    elif isinstance(param.prototype, omero.RList):
        items = val.split(",")
        if len(param.prototype.val) == 0:
            # Don't know what needs to be added here, so calling wrap
            # which will produce an rlist of rstrings.
            val = omero.rtypes.wrap(items)
        else:
            p = param.prototype.val[0]
            val = omero.rtypes.rlist([p.__class__(x) for x in items])
    elif isinstance(param.prototype, omero.RObject):
        try:
            parts2 = val.split(":")
            kls = parts2[0]
            _id = long(parts2[1])
            if not kls.endswith("I"):
                kls = "%sI" % kls
            kls = getattr(omero.model, kls)
        except:
            raise ValueError("Format for objects: Class:id or ClassI:id. Not:%s" % val)
        val = omero.rtypes.robject(kls(_id, False))
    else:
        raise ValueError("No converter for: %s (type=%s)" % (key, param.prototype.__class__))

    return {key: val}
コード例 #21
0
def populate_shape(o):
    o.fillColor = rint(0xffffffff)
    o.fillRule = rstring('solid')
    o.fontFamily = rstring('cursive')
    o.fontSize = LengthI(12, UnitsLength.POINT)
    o.fontStyle = rstring('italic')
    o.locked = rbool(False)
    o.strokeColor = rint(0xffff0000)
    o.strokeDashArray = rstring('inherit')
    o.strokeLineCap = rstring('round')
    o.strokeWidth = LengthI(4, UnitsLength.PIXEL)
    o.textValue = rstring('the_text')
    o.theC = rint(1)
    o.theT = rint(2)
    o.theZ = rint(3)
    o.visibility = rbool(True)
    return o
コード例 #22
0
def addBooleanAnnotation(updateService,
                         parent,
                         boolean,
                         ns=None,
                         description=None):
    """ Adds a Boolean Annotation. """
    child = omero.model.BooleanAnnotationI()
    child.setBoolValue(rbool(boolean))
    saveAndLinkAnnotation(updateService, parent, child, ns, description)
コード例 #23
0
 def new_group(self, experimenters=None, perms=None):
     admin = self.root.sf.getAdminService()
     gname = self.uuid()
     group = omero.model.ExperimenterGroupI()
     group.name = rstring(gname)
     group.ldap = rbool(False)
     if perms:
         group.details.permissions = omero.model.PermissionsI(perms)
     gid = admin.createGroup(group)
     group = admin.getGroup(gid)
     self.add_experimenters(group, experimenters)
     return group
コード例 #24
0
    def test_objective_settings(self):

        iid = self.create_test_image(size_c=2, session=self.sf).id.val
        conn = omero.gateway.BlitzGateway(client_obj=self.client)
        image = conn.getObject("Image", iid)

        # Create Objective
        update = conn.getUpdateService()
        objective = omero.model.ObjectiveI()
        objective.model = rstring("SuperZoom ABC")
        objective.manufacturer = rstring("ImageCo")
        objective.lensNA = rdouble(1.4)
        objective.nominalMagnification = rdouble(100)
        objective.calibratedMagnification = rdouble(100.1)
        objective.lotNumber = rstring("123")
        objective.serialNumber = rstring("abcdefX")
        objective.iris = rbool(True)

        immersions = list(conn.getEnumerationEntries("ImmersionI"))
        corrections = list(conn.getEnumerationEntries("CorrectionI"))
        objective.correction = corrections[0]._obj
        objective.immersion = immersions[0]._obj
        objective.instrument = update.saveAndReturnObject(
            omero.model.InstrumentI())
        objective = update.saveAndReturnObject(objective)

        settings = omero.model.ObjectiveSettingsI()
        settings.objective = objective
        settings = update.saveAndReturnObject(settings)

        image._obj.objectiveSettings = settings
        update.saveAndReturnObject(image._obj)

        # reload...
        image = conn.getObject("Image", iid)
        json_data = acquisitionMetadataMarshal(image)
        print(json_data)
        assert json_data["objectiveSettings"] == {
            "id": settings.id.val,
            "objective": {
                "id": objective.id.val,
                "model": "SuperZoom ABC",
                "manufacturer": "ImageCo",
                "lensNA": 1.4,
                "nominalMagnification": 100,
                "calibratedMagnification": 100.1,
                "lotNumber": "123",
                "serialNumber": "abcdefX",
                "immersion": immersions[0].value,
                "correction": corrections[0].value,
                "iris": True
            }
        }
コード例 #25
0
 def new_group(self, experimenters=None, perms=None):
     admin = self.root.sf.getAdminService()
     gname = self.uuid()
     group = omero.model.ExperimenterGroupI()
     group.name = rstring(gname)
     group.ldap = rbool(False)
     if perms:
         group.details.permissions = omero.model.PermissionsI(perms)
     gid = admin.createGroup(group)
     group = admin.getGroup(gid)
     self.add_experimenters(group, experimenters)
     return group
コード例 #26
0
 def testMapStringField(self):
     uuid = self.uuid()
     queryService = self.root.getSession().getQueryService()
     updateService = self.root.getSession().getUpdateService()
     group = ExperimenterGroupI()
     group.setName(rstring(uuid))
     group.setLdap(rbool(False))
     group.setConfig([NV("language", "python")])
     group = updateService.saveAndReturnObject(group)
     group = queryService.findByQuery(
         ("select g from ExperimenterGroup g join fetch g.config "
          "where g.id = %s" % group.getId().getValue()), None)
     self.assertNV(group.getConfig()[0], "language", "python")
コード例 #27
0
    def testLinkViaLink(self):
        user = ExperimenterI()
        user.setFirstName(rstring("test"))
        user.setLastName(rstring("user"))
        user.setOmeName(rstring("UUID"))
        user.setLdap(rbool(False))

        # possibly setOmeName() and setOmeName(string) ??
        # and then don't need omero/types.h

        group = ExperimenterGroupI()
        # TODOuser.linkExperimenterGroup(group)
        link = GroupExperimenterMapI()
        link.parent = group
        link.child = user
コード例 #28
0
ファイル: __init__.py プロジェクト: joansmith/openmicroscopy
    def new_user(self,
                 group=None,
                 perms=None,
                 owner=False,
                 system=False,
                 uname=None,
                 email=None):
        """
        :owner: If user is to be an owner of the created group
        :system: If user is to be a system admin
        """

        if not self.root:
            raise Exception("No root client. Cannot create user")

        adminService = self.root.getSession().getAdminService()
        if uname is None:
            uname = self.uuid()

        # Create group if necessary
        if not group:
            g = self.new_group(perms=perms)
            group = g.name.val
        else:
            g, group = self.group_and_name(group)

        # Create user
        e = ExperimenterI()
        e.omeName = rstring(uname)
        e.firstName = rstring(uname)
        e.lastName = rstring(uname)
        e.ldap = rbool(False)
        e.email = rstring(email)
        listOfGroups = list()
        listOfGroups.append(adminService.lookupGroup('user'))
        uid = adminService.createExperimenterWithPassword(
            e, rstring(uname), g, listOfGroups)
        e = adminService.lookupExperimenter(uname)
        if owner:
            adminService.setGroupOwner(g, e)
        if system:
            adminService.addGroups(e, [ExperimenterGroupI(0, False)])

        return adminService.getExperimenter(uid)
コード例 #29
0
ファイル: group.py プロジェクト: tlambert-forks/omero-py
    def add(self, args):

        import omero
        from omero.rtypes import rbool, rstring
        from omero_model_ExperimenterGroupI import ExperimenterGroupI as Grp

        perms = self.parse_perms(args)
        c = self.ctx.conn(args)
        g = Grp()
        g.name = rstring(args.name)
        g.ldap = rbool(False)
        g.details.permissions = perms
        admin = c.getSession().getAdminService()
        try:
            grp = admin.lookupGroup(args.name)
            if grp:
                if args.ignore_existing:
                    self.ctx.out("Group exists: %s (id=%s)" %
                                 (args.name, grp.id.val))
                    return
                else:
                    self.ctx.die(
                        3,
                        "Group exists: %s (id=%s)" % (args.name, grp.id.val))
        except omero.ApiUsageException:
            pass  # Apparently no such group exists

        try:
            id = admin.createGroup(g)
            self.ctx.out("Added group %s (id=%s) with permissions %s" %
                         (args.name, id, perms))
        except omero.ValidationException as ve:
            # Possible, though unlikely after previous check
            if self.exc.is_constraint_violation(ve):
                self.ctx.die(66, "Group already exists: %s" % args.name)
            else:
                self.ctx.die(67,
                             "Unknown ValidationException: %s" % ve.message)
        except omero.SecurityViolation as se:
            self.ctx.die(68, "Security violation: %s" % se.message)
        except omero.ServerError as se:
            self.ctx.die(4, "%s: %s" % (type(se), se.message))
コード例 #30
0
    def testLoginToPublicGroupTicket1940(self):
        # As root create a new group
        uuid = self.uuid()
        g = ExperimenterGroupI()
        g.name = rstring(uuid)
        g.ldap = rbool(False)
        g.details.permissions = PermissionsI("rwrwrw")
        self.root.sf.getAdminService().createGroup(g)

        # As a regular user, login to that group
        rv = self.root.getPropertyMap()
        ec = self.client.sf.getAdminService().getEventContext()
        public_client = omero.client(rv)
        public_client.getImplicitContext().put("omero.group", uuid)
        sf = public_client.createSession(ec.userName, ec.userName)
        ec = sf.getAdminService().getEventContext()
        assert uuid == ec.groupName

        # But can the user write anything?
        tag = TagAnnotationI()
        sf.getUpdateService().saveObject(tag)
コード例 #31
0
    def new_user(self, group=None, perms=None,
                 owner=False, system=False, uname=None,
                 email=None):
        """
        :owner: If user is to be an owner of the created group
        :system: If user is to be a system admin
        """

        if not self.root:
            raise Exception("No root client. Cannot create user")

        adminService = self.root.getSession().getAdminService()
        if uname is None:
            uname = self.uuid()

        # Create group if necessary
        if not group:
            g = self.new_group(perms=perms)
            group = g.name.val
        else:
            g, group = self.group_and_name(group)

        # Create user
        e = ExperimenterI()
        e.omeName = rstring(uname)
        e.firstName = rstring(uname)
        e.lastName = rstring(uname)
        e.ldap = rbool(False)
        e.email = rstring(email)
        listOfGroups = list()
        listOfGroups.append(adminService.lookupGroup('user'))
        uid = adminService.createExperimenterWithPassword(
            e, rstring(uname), g, listOfGroups)
        e = adminService.lookupExperimenter(uname)
        if owner:
            adminService.setGroupOwner(g, e)
        if system:
            adminService.addGroups(e, [ExperimenterGroupI(0, False)])

        return adminService.getExperimenter(uid)
コード例 #32
0
ファイル: ldap.py プロジェクト: Daniel-Walther/openmicroscopy
    def setdn(self, args):
        c = self.ctx.conn(args)
        iupdate = c.sf.getUpdateService()
        iadmin = c.sf.getAdminService()

        obj = None

        if args.user_name:
            [uid, obj] = self.find_user_by_name(iadmin, args.user_name,
                                                fatal=True)
        elif args.user_id:
            [uid, obj] = self.find_user_by_id(iadmin, args.user_id, fatal=True)
        elif args.group_name:
            [gid, obj] = self.find_group_by_name(iadmin, args.group_name,
                                                 fatal=True)
        elif args.group_id:
            [gid, obj] = self.find_group_by_id(iadmin, args.group_id,
                                               fatal=True)

        if obj is not None:
            obj.setLdap(rbool(args.choice.lower()
                              in ("yes", "true", "t", "1")))
            iupdate.saveObject(obj)
コード例 #33
0
ファイル: group.py プロジェクト: stelfrich/openmicroscopy
    def add(self, args):

        import omero
        from omero.rtypes import rbool, rstring
        from omero_model_ExperimenterGroupI import ExperimenterGroupI as Grp

        perms = self.parse_perms(args)
        c = self.ctx.conn(args)
        g = Grp()
        g.name = rstring(args.name)
        g.ldap = rbool(False)
        g.details.permissions = perms
        admin = c.getSession().getAdminService()
        try:
            grp = admin.lookupGroup(args.name)
            if grp:
                if args.ignore_existing:
                    self.ctx.out("Group exists: %s (id=%s)"
                                 % (args.name, grp.id.val))
                    return
                else:
                    self.ctx.die(3, "Group exists: %s (id=%s)"
                                 % (args.name, grp.id.val))
        except omero.ApiUsageException:
            pass  # Apparently no such group exists

        try:
            id = admin.createGroup(g)
            self.ctx.out("Added group %s (id=%s) with permissions %s"
                         % (args.name, id, perms))
        except omero.ValidationException, ve:
            # Possible, though unlikely after previous check
            if self.exc.is_constraint_violation(ve):
                self.ctx.die(66, "Group already exists: %s" % args.name)
            else:
                self.ctx.die(67, "Unknown ValidationException: %s"
                             % ve.message)
コード例 #34
0
    def testLoginToPublicGroupTicket1940(self):
        # As root create a new group
        uuid = self.uuid()
        g = ExperimenterGroupI()
        g.name = rstring(uuid)
        g.ldap = rbool(False)
        g.details.permissions = PermissionsI("rwrwrw")
        self.root.sf.getAdminService().createGroup(g)

        # As a regular user, login to that group
        rv = self.root.getPropertyMap()
        ec = self.client.sf.getAdminService().getEventContext()
        public_client = omero.client(rv)
        public_client.getImplicitContext().put("omero.group", uuid)
        sf = public_client.createSession(ec.userName, ec.userName)
        ec = sf.getAdminService().getEventContext()
        assert uuid == ec.groupName

        # But can the user write anything?
        tag = TagAnnotationI()
        tag = sf.getUpdateService().saveAndReturnObject(tag)
        # And link?
        # And edit? cF. READ-ONLY & READ-LINK
        sf.getUpdateService().deleteObject(tag)
コード例 #35
0
 def testConversionMethod(self):
     assert None == rtype(None)
     assert rlong(1) == rtype(rlong(1))  # Returns self
     assert rbool(True) == rtype(True)
     # Unsupported
     # assert rdouble(0) == rtype(Double.valueOf(0))
     assert rfloat(0) == rtype(float(0))
     assert rlong(0) == rtype(long(0))
     assert rint(0) == rtype(int(0))
     assert rstring("string") == rtype("string")
     # Unsupported
     # assert rtime(time) == rtype(new Timestamp(time))
     rtype(omero.model.ImageI())
     rtype(omero.grid.JobParams())
     rtype(set([rlong(1)]))
     rtype(list([rlong(2)]))
     rtype({})
     # Unsupported
     # rtype(array)
     try:
         rtype(())
         assert False, "Shouldn't be able to handle this yet"
     except omero.ClientError:
         pass
コード例 #36
0
ファイル: test_rtypes.py プロジェクト: mtbc/omero-py
    def testObjectCreationEqualsAndHash(self):

        # RBool
        true1 = rbool(True)
        true2 = rbool(True)
        false1 = rbool(False)
        false2 = rbool(False)
        assert true1 == true2
        assert false1 == false2
        assert true1.getValue()
        assert not false1.getValue()
        assert true1 == true2
        assert true1 != false1

        # RDouble
        double_zero1 = rdouble(0.0)
        double_zero2 = rdouble(0.0)
        double_notzero1 = rdouble(1.1)
        double_notzero1b = rdouble(1.1)
        double_notzero2 = rdouble(2.2)
        assert double_zero1.getValue() == 0.0
        assert double_notzero1.getValue() == 1.1
        assert double_zero1 == double_zero2
        assert double_zero1 != double_notzero1
        assert double_notzero1 == double_notzero1b
        assert double_notzero1 != double_notzero2

        # RFloat
        float_zero1 = rfloat(0.0)
        float_zero2 = rfloat(0.0)
        float_notzero1 = rfloat(1.1)
        float_notzero1b = rfloat(1.1)
        float_notzero2 = rfloat(2.2)
        assert float_zero1.getValue() == 0.0
        assert float_notzero1.getValue() == 1.1
        assert float_zero1 == float_zero2
        assert float_zero1 != float_notzero1
        assert float_notzero1 == float_notzero1b
        assert float_notzero1 != float_notzero2

        # RInt
        int_zero1 = rint(0)
        int_zero2 = rint(0)
        int_notzero1 = rint(1)
        int_notzero1b = rint(1)
        int_notzero2 = rint(2)
        assert int_zero1.getValue() == 0
        assert int_notzero1.getValue() == 1
        assert int_zero1 == int_zero2
        assert int_zero1 != int_notzero1
        assert int_notzero1 == int_notzero1b
        assert int_notzero1 != int_notzero2

        # RLong
        long_zero1 = rlong(0)
        long_zero2 = rlong(0)
        long_notzero1 = rlong(1)
        long_notzero1b = rlong(1)
        long_notzero2 = rlong(2)
        assert long_zero1.getValue() == 0
        assert long_notzero1.getValue() == 1
        assert long_zero1 == long_zero2
        assert long_zero1 != long_notzero1
        assert long_notzero1 == long_notzero1b
        assert long_notzero1 != long_notzero2

        # RTime
        time_zero1 = rtime(0)
        time_zero2 = rtime(0)
        time_notzero1 = rtime(1)
        time_notzero1b = rtime(1)
        time_notzero2 = rtime(2)
        assert time_zero1.getValue() == 0
        assert time_notzero1.getValue() == 1
        assert time_zero1 == time_zero2
        assert time_zero1 != time_notzero1
        assert time_notzero1 == time_notzero1b
        assert time_notzero1 != time_notzero2

        # RInternal
        internal_null1 = rinternal(None)
        internal_null2 = rinternal(None)
        internal_notnull1 = rinternal(omero.grid.JobParams())
        internal_notnull2 = rinternal(omero.grid.JobParams())
        assert internal_null1 == internal_null2
        assert internal_null1 == internal_null2
        assert internal_null1 != internal_notnull2
        assert internal_notnull1 == internal_notnull1
        assert internal_notnull1 != internal_notnull2

        # RObject
        object_null1 = robject(None)
        object_null2 = robject(None)
        object_notnull1 = robject(omero.model.ImageI())
        object_notnull2 = robject(omero.model.ImageI())
        assert object_null1 == object_null2
        assert object_null1 == object_null2
        assert object_null1 != object_notnull2
        assert object_notnull1 == object_notnull1
        assert object_notnull1 != object_notnull2

        # RString
        string_null1 = rstring(None)
        string_null2 = rstring(None)
        string_notnull1 = rstring("str1")
        string_notnull1b = rstring("str1")
        string_notnull2 = rstring("str2")
        assert string_null1 == string_null2
        assert string_null1 == string_null2
        assert string_null1 != string_notnull2
        assert string_notnull1 == string_notnull1
        assert string_notnull1 != string_notnull2
        assert string_notnull1 == string_notnull1b

        # RClass
        class_null1 = rclass(None)
        class_null2 = rclass(None)
        class_notnull1 = rclass("str1")
        class_notnull1b = rclass("str1")
        class_notnull2 = rclass("str2")
        assert class_null1 == class_null2
        assert class_null1 == class_null2
        assert class_null1 != class_notnull2
        assert class_notnull1 == class_notnull1
        assert class_notnull1 != class_notnull2
        assert class_notnull1 == class_notnull1b
コード例 #37
0
 def noAcquisitionData(self):
     if not self.theOptions:
         self.theOptions = omero.sys.Options()
     self.theOptions.acquisitionData = rbool(False)
     return self
コード例 #38
0
 def noOrphan(self):
     if not self.theOptions:
         self.theOptions = omero.sys.Options()
     self.theOptions.orphan = rbool(False)
     return self
コード例 #39
0
    def test1109(self):
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # Replace defaultGroup with something new
        defaultGroup = self.new_group()

        # create data
        # group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        gid = admin.createGroup(new_gr1)

        # new user1
        new_exp = ExperimenterI()
        new_exp.omeName = rstring("user_%s" % uuid)
        new_exp.firstName = rstring("New")
        new_exp.lastName = rstring("Test")
        new_exp.ldap = rbool(False)
        new_exp.email = rstring("*****@*****.**")

        listOfGroups = list()
        # defaultGroup = admin.lookupGroup("default") Removed in 4.2
        listOfGroups.append(admin.getGroup(gid))
        listOfGroups.append(admin.lookupGroup("user"))

        eid = admin.createExperimenter(new_exp, defaultGroup, listOfGroups)

        # test
        exp = admin.getExperimenter(eid)
        # print "exp: ", exp.id.val, " his default group is: ",
        # admin.getDefaultGroup(exp.id.val).id.val

        gr1 = admin.getGroup(2)
        indefault = admin.containedExperimenters(gr1.id.val)
        # print "members of group %s %i" % (gr1.name.val, gr1.id.val)
        for m in indefault:
            if m.id.val == exp.id.val:
                assert m.copyGroupExperimenterMap()[0].parent.id.val == \
                    admin.getDefaultGroup(exp.id.val).id.val
                # print "exp: id=", m.id.val, "; GEM[0]: ",
                # type(m.copyGroupExperimenterMap()[0].parent),
                # m.copyGroupExperimenterMap()[0].parent.id.val

        gr2 = admin.getGroup(gid)
        members2 = admin.containedExperimenters(gr2.id.val)
        # print "members of group %s %i" % (gr2.name.val, gr2.id.val)
        for m in members2:
            if m.id.val == exp.id.val:
                copied_id = m.copyGroupExperimenterMap()[0].parent.id.val
                got_id = admin.getDefaultGroup(exp.id.val).id.val
                contained = admin.containedGroups(m.id.val)
                assert copied_id == got_id, \
                    """
                    %s != %s. Groups for experimenter %s = %s
                     (graph) or %s (contained)
                    """ % (
                        copied_id, got_id, exp.id.val,
                        [x.parent.id.val for x in
                            m.copyGroupExperimenterMap()],
                        [y.id.val for y in contained])
コード例 #40
0
    def test1109(self):
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # Replace defaultGroup with something new
        defaultGroup = self.new_group()

        # create data
        # group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        gid = admin.createGroup(new_gr1)

        # new user1
        new_exp = ExperimenterI()
        new_exp.omeName = rstring("user_%s" % uuid)
        new_exp.firstName = rstring("New")
        new_exp.lastName = rstring("Test")
        new_exp.ldap = rbool(False)
        new_exp.email = rstring("*****@*****.**")

        listOfGroups = list()
        # defaultGroup = admin.lookupGroup("default") Removed in 4.2
        listOfGroups.append(admin.getGroup(gid))
        listOfGroups.append(admin.lookupGroup("user"))

        eid = admin.createExperimenter(new_exp, defaultGroup, listOfGroups)

        # test
        exp = admin.getExperimenter(eid)
        # print "exp: ", exp.id.val, " his default group is: ",
        # admin.getDefaultGroup(exp.id.val).id.val

        gr1 = admin.getGroup(2)
        indefault = admin.containedExperimenters(gr1.id.val)
        # print "members of group %s %i" % (gr1.name.val, gr1.id.val)
        for m in indefault:
            if m.id.val == exp.id.val:
                assert m.copyGroupExperimenterMap()[0].parent.id.val == \
                    admin.getDefaultGroup(exp.id.val).id.val
                # print "exp: id=", m.id.val, "; GEM[0]: ",
                # type(m.copyGroupExperimenterMap()[0].parent),
                # m.copyGroupExperimenterMap()[0].parent.id.val

        gr2 = admin.getGroup(gid)
        members2 = admin.containedExperimenters(gr2.id.val)
        # print "members of group %s %i" % (gr2.name.val, gr2.id.val)
        for m in members2:
            if m.id.val == exp.id.val:
                copied_id = m.copyGroupExperimenterMap()[0].parent.id.val
                got_id = admin.getDefaultGroup(exp.id.val).id.val
                contained = admin.containedGroups(m.id.val)
                assert copied_id == got_id, \
                    """
                    %s != %s. Groups for experimenter %s = %s
                     (graph) or %s (contained)
                    """ % (
                        copied_id, got_id, exp.id.val,
                        [x.parent.id.val for x in
                            m.copyGroupExperimenterMap()],
                        [y.id.val for y in contained])
コード例 #41
0
    def testCreatGroupAndchangePermissions(self):
        # this is the test of updating group permissions
        # including changes in #1434
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # create group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        p = PermissionsI()
        p.setUserRead(True)
        p.setUserWrite(True)
        p.setGroupRead(False)
        p.setGroupAnnotate(False)
        p.setGroupWrite(False)
        p.setWorldRead(False)
        p.setWorldAnnotate(False)
        p.setWorldWrite(False)
        new_gr1.details.permissions = p
        g1_id = admin.createGroup(new_gr1)

        # increase permissions of group1 to rwr---
        p1 = PermissionsI()
        p1.setUserRead(True)
        p1.setUserWrite(True)
        p1.setGroupRead(True)
        p1.setGroupAnnotate(False)
        p1.setGroupWrite(False)
        p1.setWorldRead(False)
        p1.setWorldAnnotate(False)
        p1.setWorldWrite(False)
        self.change_permissions(g1_id, str(p1), self.root)
        gr2 = admin.getGroup(g1_id)
        assert 'rwr---' == str(gr2.details.permissions)

        # increase permissions of group1 to rwra--
        gr2 = admin.getGroup(g1_id)
        p2 = PermissionsI()
        p2.setUserRead(True)
        p2.setUserWrite(True)
        p2.setGroupRead(True)
        p2.setGroupAnnotate(True)
        p2.setGroupWrite(False)
        p2.setWorldRead(False)
        p2.setWorldAnnotate(False)
        p2.setWorldWrite(False)
        self.change_permissions(g1_id, str(p2), self.root)
        gr3 = admin.getGroup(g1_id)
        assert 'rwra--' == str(gr3.details.permissions)

        # increase permissions of group1 to rwrw--
        gr3 = admin.getGroup(g1_id)
        p3 = PermissionsI()
        p3.setUserRead(True)
        p3.setUserWrite(True)
        p3.setGroupRead(True)
        p3.setGroupWrite(True)
        p3.setWorldRead(False)
        p3.setWorldAnnotate(False)
        p3.setWorldWrite(False)
        self.change_permissions(g1_id, str(p3), self.root)
        gr4 = admin.getGroup(g1_id)
        assert 'rwrw--' == str(gr4.details.permissions)
コード例 #42
0
 def noLeaves(self):
     if not self.theOptions:
         self.theOptions = omero.sys.Options()
     self.theOptions.leaves = rbool(False)
     return self
コード例 #43
0
 def noAcquisitionData(self):
     if not self.theOptions:
         self.theOptions = omero.sys.Options()
     self.theOptions.acquisitionData = rbool(False)
     return self
コード例 #44
0
 def noUnique(self):
     if not self.theFilter:
         self.theFilter = omero.sys.Filter()
     self.theFilter.unique = rbool(False)
     return self
コード例 #45
0
    def testCreatGroupAndchangePermissions(self):
        # this is the test of updating group permissions
        # including changes in #1434
        uuid = self.uuid()
        admin = self.root.sf.getAdminService()

        # create group1
        new_gr1 = ExperimenterGroupI()
        new_gr1.name = rstring("group1_%s" % uuid)
        new_gr1.ldap = rbool(False)
        p = PermissionsI()
        p.setUserRead(True)
        p.setUserWrite(True)
        p.setGroupRead(False)
        p.setGroupAnnotate(False)
        p.setGroupWrite(False)
        p.setWorldRead(False)
        p.setWorldAnnotate(False)
        p.setWorldWrite(False)
        new_gr1.details.permissions = p
        g1_id = admin.createGroup(new_gr1)

        # increase permissions of group1 to rwr---
        p1 = PermissionsI()
        p1.setUserRead(True)
        p1.setUserWrite(True)
        p1.setGroupRead(True)
        p1.setGroupAnnotate(False)
        p1.setGroupWrite(False)
        p1.setWorldRead(False)
        p1.setWorldAnnotate(False)
        p1.setWorldWrite(False)
        self.change_permissions(g1_id, str(p1), self.root)
        gr2 = admin.getGroup(g1_id)
        assert 'rwr---' == str(gr2.details.permissions)

        # increase permissions of group1 to rwra--
        gr2 = admin.getGroup(g1_id)
        p2 = PermissionsI()
        p2.setUserRead(True)
        p2.setUserWrite(True)
        p2.setGroupRead(True)
        p2.setGroupAnnotate(True)
        p2.setGroupWrite(False)
        p2.setWorldRead(False)
        p2.setWorldAnnotate(False)
        p2.setWorldWrite(False)
        self.change_permissions(g1_id, str(p2), self.root)
        gr3 = admin.getGroup(g1_id)
        assert 'rwra--' == str(gr3.details.permissions)

        # increase permissions of group1 to rwrw--
        gr3 = admin.getGroup(g1_id)
        p3 = PermissionsI()
        p3.setUserRead(True)
        p3.setUserWrite(True)
        p3.setGroupRead(True)
        p3.setGroupWrite(True)
        p3.setWorldRead(False)
        p3.setWorldAnnotate(False)
        p3.setWorldWrite(False)
        self.change_permissions(g1_id, str(p3), self.root)
        gr4 = admin.getGroup(g1_id)
        assert 'rwrw--' == str(gr4.details.permissions)
コード例 #46
0
 def testOptionsAcquisitionData(self):
     p = ParametersI()
     self.assertNull(p.getAcquisitionData())
     assert rbool(True) == p.acquisitionData().getAcquisitionData()
     assert rbool(False) == p.noAcquisitionData().getAcquisitionData()
     self.assertNotNull(p.getAcquisitionData())
コード例 #47
0
def add_annotations(o):
    '''
    Annotation
        BasicAnnotation
            BooleanAnnotation
                BooleanAnnotationI
            NumericAnnotation
                DoubleAnnotation
                    DoubleAnnotationI
                LongAnnotation
                    LongAnnotationI
            TermAnnotation
                TermAnnotationI
            TimestampAnnotation
                TimestampAnnotationI
        ListAnnotation
            ListAnnotationI
        MapAnnotation
            MapAnnotationI
        TextAnnotation
            CommentAnnotation
                CommentAnnotationI
            TagAnnotation
                TagAnnotationI
            XmlAnnotation
                XmlAnnotationI
        TypeAnnotation
            FileAnnotation
                FileAnnotationI
    '''
    annotation = BooleanAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('boolean_annotation')
    annotation.boolValue = rbool(True)
    o.linkAnnotation(annotation)
    annotation = CommentAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('comment_annotation')
    annotation.textValue = rstring('text_value')
    o.linkAnnotation(annotation)
    annotation = DoubleAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('double_annotation')
    annotation.doubleValue = rdouble(1.0)
    o.linkAnnotation(annotation)
    annotation = LongAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('long_annotation')
    annotation.longValue = rlong(1L)
    o.linkAnnotation(annotation)
    annotation = MapAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('map_annotation')
    annotation.setMapValue([NamedValue('a', '1'), NamedValue('b', '2')])
    o.linkAnnotation(annotation)
    annotation = TagAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('tag_annotation')
    annotation.textValue = rstring('tag_value')
    o.linkAnnotation(annotation)
    annotation = TermAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('term_annotation')
    annotation.termValue = rstring('term_value')
    o.linkAnnotation(annotation)
    annotation = TimestampAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('timestamp_annotation')
    annotation.timeValue = rtime(1)
    o.linkAnnotation(annotation)
    annotation = XmlAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('xml_annotation')
    annotation.textValue = rstring('<xml_value></xml_value>')
    o.linkAnnotation(annotation)
コード例 #48
0
 def testOptionsOrphan(self):
     p = ParametersI()
     self.assertNull(p.getOrphan())
     assert rbool(True) == p.orphan().getOrphan()
     assert rbool(False) == p.noOrphan().getOrphan()
     self.assertNotNull(p.getOrphan())
コード例 #49
0
 def noOrphan(self):
     if not self.theOptions:
         self.theOptions = omero.sys.Options()
     self.theOptions.orphan = rbool(False)
     return self
コード例 #50
0
 def testOptionsLeaves(self):
     p = ParametersI()
     self.assertNull(p.getLeaves())
     assert rbool(True) == p.leaves().getLeaves()
     assert rbool(False) == p.noLeaves().getLeaves()
     self.assertNotNull(p.getLeaves())
コード例 #51
0
 def testUnique(self):
     p = ParametersI()
     self.assertNull(p.getUnique())
     assert rbool(True) == p.unique().getUnique()
     assert rbool(False) == p.noUnique().getUnique()
     self.assertNotNull(p.getUnique())
コード例 #52
0
 def unique(self):
     if not self.theFilter:
         self.theFilter = omero.sys.Filter()
     self.theFilter.unique = rbool(True)
     return self
コード例 #53
0
def add_annotations(o):
    '''
    Annotation
        BasicAnnotation
            BooleanAnnotation
                BooleanAnnotationI
            NumericAnnotation
                DoubleAnnotation
                    DoubleAnnotationI
                LongAnnotation
                    LongAnnotationI
            TermAnnotation
                TermAnnotationI
            TimestampAnnotation
                TimestampAnnotationI
        ListAnnotation
            ListAnnotationI
        MapAnnotation
            MapAnnotationI
        TextAnnotation
            CommentAnnotation
                CommentAnnotationI
            TagAnnotation
                TagAnnotationI
            XmlAnnotation
                XmlAnnotationI
        TypeAnnotation
            FileAnnotation
                FileAnnotationI
    '''
    annotation = BooleanAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('boolean_annotation')
    annotation.boolValue = rbool(True)
    o.linkAnnotation(annotation)
    annotation = CommentAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('comment_annotation')
    annotation.textValue = rstring('text_value')
    o.linkAnnotation(annotation)
    annotation = DoubleAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('double_annotation')
    annotation.doubleValue = rdouble(1.0)
    o.linkAnnotation(annotation)
    annotation = LongAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('long_annotation')
    annotation.longValue = rlong(1L)
    o.linkAnnotation(annotation)
    annotation = MapAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('map_annotation')
    annotation.setMapValue([NamedValue('a', '1'), NamedValue('b', '2')])
    o.linkAnnotation(annotation)
    annotation = TagAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('tag_annotation')
    annotation.textValue = rstring('tag_value')
    o.linkAnnotation(annotation)
    annotation = TermAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('term_annotation')
    annotation.termValue = rstring('term_value')
    o.linkAnnotation(annotation)
    annotation = TimestampAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('timestamp_annotation')
    annotation.timeValue = rtime(1)
    o.linkAnnotation(annotation)
    annotation = XmlAnnotationI()
    annotation.description = rstring('the_description')
    annotation.ns = rstring('xml_annotation')
    annotation.textValue = rstring('<xml_value></xml_value>')
    o.linkAnnotation(annotation)
コード例 #54
0
ファイル: test_rtypes.py プロジェクト: mtbc/omero-py
 def testPassThroughNoneAndRTypes(self):
     """
     To prevent having to check for isintance(int,...) or
     isintance(RInt,...) all over the place, the static methods
     automatically check for acceptable
     types and simply pass them through. Similarly, the primitive types all
     check for None and return a null RType if necessary.
     """
     # Bool
     assert None == rbool(None)
     assert rbool(True) == rbool(rbool(True))
     assert rbool(True) == rbool(1)
     assert rbool(False) == rbool(0)
     # Double
     assert None == rdouble(None)
     assert rdouble(0.0) == rdouble(rdouble(0.0))
     assert rdouble(0.0) == rdouble(rdouble(0))
     assert rdouble(0.0) == rdouble(rdouble("0.0"))
     pytest.raises(ValueError, lambda: rdouble("string"))
     # Float
     assert None == rfloat(None)
     assert rfloat(0.0) == rfloat(rfloat(0.0))
     assert rfloat(0.0) == rfloat(rfloat(0))
     assert rfloat(0.0) == rfloat(rfloat("0.0"))
     pytest.raises(ValueError, lambda: rfloat("string"))
     # Long
     assert None == rlong(None)
     assert rlong(0) == rlong(rlong(0))
     assert rlong(0) == rlong(rlong(0.0))
     assert rlong(0) == rlong(rlong("0"))
     pytest.raises(ValueError, lambda: rlong("string"))
     # Time
     assert None == rtime(None)
     assert rtime(0) == rtime(rtime(0))
     assert rtime(0) == rtime(rtime(0.0))
     assert rtime(0) == rtime(rtime("0"))
     pytest.raises(ValueError, lambda: rtime("string"))
     # Int
     assert None == rint(None)
     assert rint(0) == rint(rint(0))
     assert rint(0) == rint(rint(0.0))
     assert rint(0) == rint(rint("0"))
     pytest.raises(ValueError, lambda: rint("string"))
     #
     # Starting here handling of null is different.
     #
     # String
     assert rstring("") == rstring(None)
     assert rstring("a") == rstring(rstring("a"))
     assert rstring("0") == rstring(0)
     # Class
     assert rclass("") == rclass(None)
     assert rclass("c") == rclass(rclass("c"))
     pytest.raises(ValueError, lambda: rclass(0))
     # Internal
     internal = omero.Internal()
     assert rinternal(None) == rinternal(None)
     assert rinternal(internal) == rinternal(rinternal(internal))
     pytest.raises(ValueError, lambda: rinternal("string"))
     # Object
     obj = omero.model.ImageI()
     assert robject(None) == robject(None)
     assert robject(obj) == robject(robject(obj))
     pytest.raises(ValueError, lambda: robject("string"))
     #
     # Same does not hold for collections
     #
     # Array
     assert rarray([]) == rarray(None)
     # assert rarray(obj) == rarray(rarray(obj))
     # pytest.raises(ValueError, lambda : rarray("string"))
     # List
     assert rlist([]) == rlist(None)
     # assert rlist(obj) == rlist(rlist(obj))
     # pytest.raises(ValueError, lambda : rlist("string"))
     # Set
     assert rset([]) == rset(None)
     # assert rset(obj) == rset(rset(obj))
     # pytest.raises(ValueError, lambda : rset("string"))
     # Map
     assert rmap({}) == rmap(None)
コード例 #55
0
def add_annotations(o):
    """
    Annotation
        BasicAnnotation
            BooleanAnnotation
                BooleanAnnotationI
            NumericAnnotation
                DoubleAnnotation
                    DoubleAnnotationI
                LongAnnotation
                    LongAnnotationI
            TermAnnotation
                TermAnnotationI
            TimestampAnnotation
                TimestampAnnotationI
        ListAnnotation
            ListAnnotationI
        MapAnnotation
            MapAnnotationI
        TextAnnotation
            CommentAnnotation
                CommentAnnotationI
            TagAnnotation
                TagAnnotationI
            XmlAnnotation
                XmlAnnotationI
        TypeAnnotation
            FileAnnotation
                FileAnnotationI
    """
    annotation = BooleanAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("boolean_annotation")
    annotation.boolValue = rbool(True)
    o.linkAnnotation(annotation)
    annotation = CommentAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("comment_annotation")
    annotation.textValue = rstring("text_value")
    o.linkAnnotation(annotation)
    annotation = DoubleAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("double_annotation")
    annotation.doubleValue = rdouble(1.0)
    o.linkAnnotation(annotation)
    annotation = LongAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("long_annotation")
    annotation.longValue = rlong(1L)
    o.linkAnnotation(annotation)
    annotation = MapAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("map_annotation")
    annotation.setMapValue([NamedValue("a", "1"), NamedValue("b", "2")])
    o.linkAnnotation(annotation)
    annotation = TagAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("tag_annotation")
    annotation.textValue = rstring("tag_value")
    o.linkAnnotation(annotation)
    annotation = TermAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("term_annotation")
    annotation.termValue = rstring("term_value")
    o.linkAnnotation(annotation)
    annotation = TimestampAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("timestamp_annotation")
    annotation.timeValue = rtime(1)
    o.linkAnnotation(annotation)
    annotation = XmlAnnotationI()
    annotation.description = rstring("the_description")
    annotation.ns = rstring("xml_annotation")
    annotation.textValue = rstring("<xml_value></xml_value>")
    o.linkAnnotation(annotation)
コード例 #56
0
ファイル: test_rtypes.py プロジェクト: mtbc/omero-py
    def testUnwrap(self):
        # NUMS plain
        assert 0 == unwrap(0)
        assert 1 == unwrap(1)
        assert 0.0 == unwrap(0.0)
        assert 1.0 == unwrap(1.0)
        # NUMS rtyped
        assert 0 == unwrap(rint(0))
        assert 0 == unwrap(rlong(0))
        assert 1 == unwrap(rint(1))
        assert 1 == unwrap(rlong(1))
        assert 0.0 == unwrap(rfloat(0.0))
        assert 0.0 == unwrap(rdouble(0.0))
        assert 1.0 == unwrap(rfloat(1.0))
        assert 1.0 == unwrap(rdouble(1.0))

        # STRINGS
        assert "" == unwrap("")
        assert "str" == unwrap("str")

        # BOOL
        assert True == unwrap(True)
        assert False == unwrap(False)
        assert True == unwrap(rbool(True))
        assert False == unwrap(rbool(False))

        # TIME
        # Bit odd, do we want the long for time, or transformed?
        assert 0 == unwrap(rtime(0))
        assert 1 == unwrap(rtime(1))

        # CLASS
        # same for class, should we map it?
        assert "k" == unwrap(rclass("k"))

        # INTERNAL
        color = omero.Color()
        assert color == unwrap(rinternal(color))

        # OBJECT
        image = omero.model.ImageI()
        assert image == unwrap(robject(image))

        # COLLECTIONS
        # empty
        assert [] == unwrap([])
        assert {} == unwrap({})
        assert set() == unwrap(set())
        # plain in collection
        assert [1] == unwrap([1])
        # rtype in collection
        assert [1] == unwrap([rint(1)])
        assert {"a": 1} == unwrap({"a": 1})
        # plain in rcollection ILLEGAL
        # assert [1] == unwrap(rlist([1]))
        # assert {"a":1} == unwrap(rmap({"a":1}))
        # rtype in rcollection
        assert [1] == unwrap(rlist([rint(1)]))
        assert {"a": 1} == unwrap(rmap({"a": rint(1)}))
        # rtype keys ILLEGAL
        # assert {"a":1} == unwrap(rmap({rstring("a"):rint(1)}))
        # recursion, ticket:1977
        m1 = rmap({"a": rint(1)})
        m1.val["m1"] = m1
        m2 = {"a": 1}
        m2["m1"] = m2
        unwrap(m1)
        assert m2["a"] == unwrap(m1)["a"]
        # Can't compare directly "maximum recursion depth exceeded in cmp"
        assert type(m2["m1"]) == type(unwrap(m1)["m1"])
コード例 #57
0
def create_image(image_id, with_pixels=False):
    image_format = FormatI(1L)
    image_format.value = rstring("PNG")

    image = ImageI()
    image.id = rlong(image_id)
    image.acquisitionDate = rtime(1L)
    image.archived = rbool(False)
    image.description = rstring("image_description_%d" % image_id)
    image.name = rstring("image_name_%d" % image_id)
    image.partial = rbool(False)
    image.series = rint(0)
    image.format = image_format
    if not with_pixels:
        return image
    dimension_order = DimensionOrderI(1L)
    dimension_order.value = rstring("XYZCT")
    pixels_type = PixelsTypeI(1L)
    pixels_type.value = "bit"

    pixels = PixelsI(1L)
    pixels.methodology = rstring("methodology")
    pixels.physicalSizeX = LengthI(1.0, UnitsLength.MICROMETER)
    pixels.physicalSizeY = LengthI(2.0, UnitsLength.MICROMETER)
    pixels.physicalSizeZ = LengthI(3.0, UnitsLength.MICROMETER)
    pixels.sha1 = rstring("61ee8b5601a84d5154387578466c8998848ba089")
    pixels.significantBits = rint(16)
    pixels.sizeX = rint(1)
    pixels.sizeY = rint(2)
    pixels.sizeZ = rint(3)
    pixels.sizeC = rint(4)
    pixels.sizeT = rint(5)
    pixels.timeIncrement = TimeI(1.0, UnitsTime.MILLISECOND)
    pixels.waveIncrement = rdouble(2.0)
    pixels.waveStart = rint(1)
    pixels.dimensionOrder = dimension_order
    pixels.pixelsType = pixels_type
    image.addPixels(pixels)

    contrast_method = ContrastMethodI(8L)
    contrast_method.value = rstring("Fluorescence")
    illumination = IlluminationI(1L)
    illumination.value = rstring("Transmitted")
    acquisition_mode = AcquisitionModeI(1L)
    acquisition_mode.value = rstring("WideField")
    photometric_interpretation = PhotometricInterpretationI(1L)
    photometric_interpretation.value = rstring("RGB")

    channel_1 = ChannelI(1L)
    channel_1.alpha = rint(255)
    channel_1.blue = rint(0)
    channel_1.green = rint(255)
    channel_1.red = rint(0)
    channel_1.lookupTable = rstring("rainbow")
    logical_channel_1 = LogicalChannelI(1L)
    logical_channel_1.emissionWave = LengthI(509.0, UnitsLength.NANOMETER)
    logical_channel_1.excitationWave = LengthI(488.0, UnitsLength.NANOMETER)
    logical_channel_1.fluor = rstring("GFP")
    logical_channel_1.name = rstring("GFP/488")
    logical_channel_1.ndFilter = rdouble(1.0)
    logical_channel_1.pinHoleSize = LengthI(1.0, UnitsLength.NANOMETER)
    logical_channel_1.pockelCellSetting = rint(0)
    logical_channel_1.samplesPerPixel = rint(2)
    logical_channel_1.contrastMethod = contrast_method
    logical_channel_1.illumination = illumination
    logical_channel_1.mode = acquisition_mode
    logical_channel_1.photometricInterpretation = photometric_interpretation
    channel_1.logicalChannel = logical_channel_1

    channel_2 = ChannelI(2L)
    channel_2.alpha = rint(255)
    channel_2.blue = rint(255)
    channel_2.green = rint(0)
    channel_2.red = rint(0)
    channel_2.lookupTable = rstring("rainbow")
    logical_channel_2 = LogicalChannelI(2L)
    logical_channel_2.emissionWave = LengthI(470.0, UnitsLength.NANOMETER)
    logical_channel_2.excitationWave = LengthI(405.0, UnitsLength.NANOMETER)
    logical_channel_2.fluor = rstring("DAPI")
    logical_channel_2.name = rstring("DAPI/405")
    logical_channel_2.ndFilter = rdouble(1.0)
    logical_channel_2.pinHoleSize = LengthI(2.0, UnitsLength.NANOMETER)
    logical_channel_2.pockelCellSetting = rint(0)
    logical_channel_2.samplesPerPixel = rint(2)
    logical_channel_2.contrastMethod = contrast_method
    logical_channel_2.illumination = illumination
    logical_channel_2.mode = acquisition_mode
    logical_channel_2.photometricInterpretation = photometric_interpretation
    channel_2.logicalChannel = logical_channel_2

    pixels.addChannel(channel_1)
    pixels.addChannel(channel_2)
    return image
コード例 #58
0
    def add(self, args):
        email = args.email
        login = args.username
        first = args.firstname
        middle = args.middlename
        last = args.lastname
        inst = args.institution
        pasw = args.userpassword

        import omero
        from omero.rtypes import rbool, rstring
        from omero_model_ExperimenterI import ExperimenterI as Exp
        from omero_model_ExperimenterGroupI import ExperimenterGroupI as Grp
        c = self.ctx.conn(args)
        e = Exp()
        e.omeName = rstring(login)
        e.firstName = rstring(first)
        e.lastName = rstring(last)
        e.middleName = rstring(middle)
        e.email = rstring(email)
        e.institution = rstring(inst)
        e.ldap = rbool(False)

        # Fail-fast if no-password is passed and the server does not accept
        # empty passwords
        configService = c.getSession().getConfigService()
        password_required = configService.getConfigValue(
            "omero.security.password_required").lower()
        if args.no_password and password_required != 'false':
            self.ctx.die(
                502, "Server does not allow user creation with empty"
                " passwords")

        # Check user existence
        admin = c.getSession().getAdminService()
        try:
            usr = admin.lookupExperimenter(login)
            if usr:
                if args.ignore_existing:
                    self.ctx.out("User exists: %s (id=%s)" %
                                 (login, usr.id.val))
                    return
                else:
                    self.ctx.die(
                        3, "User exists: %s (id=%s)" % (login, usr.id.val))
        except omero.ApiUsageException:
            pass  # Apparently no such user exists

        [gid, groups] = self.list_groups(admin, args, use_context=False)

        roles = admin.getSecurityRoles()
        groups.append(Grp(roles.userGroupId, False))
        if args.admin:
            groups.append(Grp(roles.systemGroupId, False))

        group = groups.pop(0)

        try:
            if args.no_password:
                id = admin.createExperimenter(e, group, groups)
                self.ctx.out("Added user %s (id=%s) without password" %
                             (login, id))
            else:
                if pasw is None:
                    pasw = self._ask_for_password(" for your new user (%s)" %
                                                  login,
                                                  strict=True)
                id = admin.createExperimenterWithPassword(
                    e, rstring(pasw), group, groups)
                self.ctx.out("Added user %s (id=%s) with password" %
                             (login, id))
        except omero.ValidationException as ve:
            # Possible, though unlikely after previous check
            if self.exc.is_constraint_violation(ve):
                self.ctx.die(66, "User already exists: %s" % login)
            else:
                self.ctx.die(67,
                             "Unknown ValidationException: %s" % ve.message)
        except omero.SecurityViolation as se:
            self.ctx.die(68, "Security violation: %s" % se.message)