当前位置: 首页>>代码示例>>Python>>正文


Python gateway.BlitzGateway类代码示例

本文整理汇总了Python中omero.gateway.BlitzGateway的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway类的具体用法?Python BlitzGateway怎么用?Python BlitzGateway使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BlitzGateway类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_as_program

def run_as_program():
    """
    Testing function to allow the script to be called outside of the OMERO
    scripting environment. The connection details and image ID must be valid.
    """
    import getpass
    HOST = 'localhost'
    PORT = 4064
    USERNAME = raw_input("OMERO username: ")
    PASSWORD = getpass.getpass("OMERO password: ")
    h = raw_input("OMERO host (%s): " % HOST)
    if h:
        HOST = h
    p = raw_input("OMERO port (%d): " % PORT)
    if p:
        PORT = p

    conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT)
    conn.connect()
    conn.keepAlive()

    params = create_script_defaults()
    params[PARAM_DATATYPE] = 'Image'
    params[PARAM_IDS] = [51]
    # params[PARAM_DATATYPE] = 'Dataset'
    # params[PARAM_IDS] = [2]
    params[PARAM_UPLOAD_RESULTS] = True
    params[PARAM_EMAIL_RESULTS] = True
    params[PARAM_EMAIL] = ADMIN_EMAIL

    count = run(conn, params)

    if count >= 0:
        print ("Processed %d image%s" %
               (count, count != 1 and 's' or ''))
开发者ID:aherbert,项目名称:omero-user-scripts,代码行数:35,代码来源:Colocalisation_Analyser.py

示例2: main

def main(argv):
    parser = make_parser()
    args = parser.parse_args(argv[1:])
    if not args.out_file:
        args.out_file = "map_screen_%d.tsv" % args.screen_id
    passwd = getpass.getpass()
    conn = BlitzGateway(
        args.user, passwd, host=args.host, port=args.port, group=args.group
    )
    conn.connect()
    screen = conn.getObject("Screen", args.screen_id)
    print "writing to %s" % args.out_file
    print "SCREEN: %s" % screen.name
    with open(args.out_file, "w") as fo:
        fo.write("PLATE\tSERIES\tWELL\tFIELD\tImageID\tWellID\n")
        for p in screen.listChildren():
            rows = []
            print "  plate: %s" % p.name
            for w in p.listChildren():
                n_fields = sum(1 for _ in w.listChildren())
                for i in xrange(n_fields):
                    img = w.getImage(i)
                    well_tag = "%s%02d" % (LETTERS[w.row], w.column + 1)
                    rows.append((
                        p.name, img.getSeries(), well_tag, i + 1, img.id, w.id
                    ))
            rows.sort(key=itemgetter(1))
            rows.sort()
            for r in rows:
                fo.write("%s\t%d\t%s\t%d\t%d\t%d\n" % r)
开发者ID:simleo,项目名称:pydoop-features,代码行数:30,代码来源:map_series.py

示例3: __init__

 def __init__(self, conn=None, user=None, passwd=None,
              server=SERVER, port=PORT, skey=None):
     """
     Requires active Blitz connection OR username plus password or sesskey
     """
     if conn is None and (user is None or (passwd is None and skey is None)):
         raise ValueError("Bad parameters," + self.__init__.__doc__)
     if conn is not None:
         if conn.isConnected():
             self.conn = conn
         else:
             raise ValueError("Cannot initialize with closed connection!")
     else:
         if passwd is not None:
             self.conn = BlitzGateway(user, passwd, host=server, port=port)
             self.conn.connect()
         else:
             self.conn = BlitzGateway(user, host=server, port=port)
             self.conn.connect(skey)
     if self.conn.isConnected():
         self._server = self.conn.host
         self._port = self.conn.port
         self._user = self.conn.getUser().getName()
         self._key = self.conn.getSession().getUuid().getValue()
         print("Connected to {0} (port {1}) as {2}, session key={3}".format(
               self._server, self._port, self._user, self._key))
     else:
         print("Failed to open connection :-(")
开发者ID:graemeball,项目名称:omero_scripts,代码行数:28,代码来源:iomero.py

示例4: run_as_program

def run_as_program():
    """
    Testing function to allow the script to be called outside of the OMERO
    scripting environment. The connection details and image ID must be valid.
    """
    import getpass
    HOST = 'localhost'
    PORT = 4064
    USERNAME = raw_input("OMERO username: ")
    PASSWORD = getpass.getpass("OMERO password: ")
    h = raw_input("OMERO host (%s): " % HOST)
    if h:
        HOST = h
    p = raw_input("OMERO port (%d): " % PORT)
    if p:
        PORT = p

    conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT)
    conn.connect()

    params = {}
    params[PARAM_IDS] = [1]
    params[PARAM_DATATYPE] = "Image"
    params[PARAM_ALL_IMAGES] = True
    params[PARAM_READABLE] = True

    (count, ok) = run(conn, params)

    print (summary(count, ok))
开发者ID:aherbert,项目名称:omero-user-scripts,代码行数:29,代码来源:Check_Images.py

示例5: connect_to_omero

def connect_to_omero(uname, passwd):
    conn = BlitzGateway(uname, passwd, host=HOST, port=PORT)
    connected = conn.connect()
    if not connected:
        sys.stderr.write("Error : Connection not available, please check your user name and password.\n")
        return None
    return conn
开发者ID:0ncorhynchus,项目名称:omero_importer,代码行数:7,代码来源:omero_tools.py

示例6: test_unicode_password

 def test_unicode_password(self):
     with pytest.raises(Ice.ConnectionRefusedException):
         gateway = BlitzGateway(
             username='user', passwd=u'ążźćółę',
             host='localhost', port=65535
         )
         gateway.connect()
开发者ID:sbesson,项目名称:openmicroscopy,代码行数:7,代码来源:test_gateway.py

示例7: runAsScript

def runAsScript():
    """
    The main entry point of the script, as called by the client via the
    scripting service, passing the required parameters.
    """

    client = scripts.client('CLI Test.py', "Test script/CLI interactions")

    try:
        conn = BlitzGateway(client_obj=client)

        cli = omero.cli.CLI()
        cli.loadplugins()

        cmd = []
        cmd.extend(["login"])
        cmd.extend(["-s", "localhost"])
        # cmd.extend(["-g", conn.getGroupFromContext().getName()])
        cmd.extend(["-p", "4064"])
        cmd.extend(["-k", conn._getSessionId()])

        cli.invoke(cmd, strict=True)

    finally:
        client.closeSession()
开发者ID:sbesson,项目名称:omero-user-scripts,代码行数:25,代码来源:test.py

示例8: testChgrpAsync

    def testChgrpAsync(self):
        """
        Try to reproduce "race condition" bugs seen in web #8037 (fails to reproduce)
        """
        image = self.image
        ctx = self.gateway.getAdminService().getEventContext()
        uuid = ctx.sessionUuid

        self.loginAsAdmin()
        gid = self.gateway.createGroup("chgrp-test-%s" % uuid, member_Ids=[ctx.userId], perms=COLLAB)
        self.loginAsAuthor()
        original_group = ctx.groupId
        self.assertNotEqual(None, self.gateway.getObject("Image", image.id))

        # Do the Chgrp
        rsp = self.doChange("Image", image.getId(), gid, return_complete=False)
        
        while rsp.getResponse() is None:
            # while waiting, try various things to reproduce race condition seen in web.
            img = self.gateway.getObject("Image", image.id)
            c = BlitzGateway()
            c.connect(sUuid=uuid)
            #self.gateway.setGroupForSession(gid)

        # Image should no-longer be available in current group
        self.assertEqual(None, self.gateway.getObject("Image", image.id), "Image should not be available in original group")

        # Switch to new group - confirm that image is there.
        self.gateway.setGroupForSession(gid)
        img = self.gateway.getObject("Image", image.id)
        self.assertNotEqual(None, img, "Image should be available in new group")
        self.assertEqual(img.getDetails().getGroup().id, gid, "Image group.id should match new group")
开发者ID:,项目名称:,代码行数:32,代码来源:

示例9: testFakeImport

    def testFakeImport(self):

        # TODO: should likely be in the "fs" namespace
        req = omero.cmd.OriginalMetadataRequest()

        client = self.new_client()
        rsp = self.fullImport(client) # Note: fake test produces no metadata!
        image = rsp.objects[0]

        req.imageId = image.id.val

        gateway = BlitzGateway(client_obj=client)

        # Load via the gateway
        image = gateway.getObject("Image", image.id.val)
        assert 3 ==  len(image.loadOriginalMetadata())

        # Load via raw request
        handle = client.sf.submit(req)
        try:
            gateway._waitOnCmd(handle, failonerror=True)
            rsp = handle.getResponse()
            assert dict ==  type(rsp.globalMetadata)
            assert dict ==  type(rsp.seriesMetadata)
        finally:
            handle.close()
开发者ID:emilroz,项目名称:openmicroscopy,代码行数:26,代码来源:test_repository.py

示例10: check

    def check(self):

        from omero.cli import CLI
        from omero.gateway import BlitzGateway

        cli = CLI()
        cli.loadplugins()
        cli.onecmd('login -q')

        try:
            gateway = BlitzGateway(client_obj=cli.get_client())
            for experiment in self.m["experiments"]:
                self.check_object(gateway, experiment, "Project")
            for experiment in self.m["screens"]:
                self.check_object(gateway, experiment, "Screen")
            if "map" in self.m:
                if self.m["experiments"]:
                    study_type = "Project"
                else:
                    study_type = "Screen"
                self.check_object(gateway, self.m, study_type)
        finally:
            if cli:
                cli.close()
            gateway.close()
开发者ID:IDR,项目名称:idr-metadata,代码行数:25,代码来源:study_parser.py

示例11: testSimpleDelete

    def testSimpleDelete(self):
        filename = self.unique_dir + "/file.txt"
        mrepo = self.getManagedRepo()
        ofile = self.createFile(mrepo, filename)
        gateway = BlitzGateway(client_obj=self.client)

        # Assert contents of file
        rfs = mrepo.fileById(ofile.id.val)
        try:
            assert "hi" ==  rfs.read(0, 2)
        finally:
            rfs.close()

        handle = gateway.deleteObjects("/OriginalFile", [ofile.id.val])
        try:
            gateway._waitOnCmd(handle)
        finally:
            handle.close()

        # Trying to open the file should not throw an UnregisteredFileException
        # But should just be an empty file.
        rfs = mrepo.file(filename, "rw")
        try:
            assert "\x00\x00" ==  rfs.read(0, 2)
        finally:
            rfs.close()
开发者ID:emilroz,项目名称:openmicroscopy,代码行数:26,代码来源:test_repository.py

示例12: processImages

def processImages(client, scriptParams):
    message = ''

    # for params with default values, we can get the value directly
    dataType = scriptParams['Data_Type']
    ids = scriptParams['IDs']

    # Get the datasets
    conn = BlitzGateway(client_obj = client)
    objects, logMessage = script_utils.getObjects(conn, scriptParams)
    message += logMessage

    if not objects:
        return message

    datasets = conn.getObjects(dataType, ids)

    good, chNames, msg = checkChannels(datasets)
    message += msg
    if not good:
        raise omero.ServerError(
            'Channel check failed, ' +
            'all images must have the same channels: %s' % message)

    return message
开发者ID:colettace,项目名称:omero-pychrm,代码行数:25,代码来源:Wndcharm_Multichannel_Check.py

示例13: get_connection

def get_connection(user, group_id=None):
    """Get a BlitzGateway connection for the given user's client."""
    connection = BlitzGateway(client_obj=user[0])
    # Refresh the session context
    connection.getEventContext()
    if group_id is not None:
        connection.SERVICE_OPTS.setOmeroGroup(group_id)
    return connection
开发者ID:ome,项目名称:figure,代码行数:8,代码来源:test_figure_files.py

示例14: connect_to_omero

def connect_to_omero():
	conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT)
	connected = conn.connect()
	if not connected:
		import sys
		sys.stderr.write("Error : Connection not available, please check your user name and password.\n")
		return None
	return conn
开发者ID:0ncorhynchus,项目名称:omero_importer,代码行数:8,代码来源:Connct_To_OMERO.py

示例15: test_chgrp_new_container

    def test_chgrp_new_container(self, dataset, credentials):
        """
        Performs a chgrp POST, polls the activities json till done,
        then checks that Dataset has moved to new group and has new
        Project as parent.
        """

        django_client = self.get_django_client(credentials)
        request_url = reverse('chgrp')
        projectName = "chgrp-project%s" % (self.uuid())
        data = {
            "group_id": self.group2.id.val,
            "Dataset": dataset.id.val,
            "new_container_name": projectName,
            "new_container_type": "project",
        }
        data = _csrf_post_response_json(django_client, request_url, data)
        expected = {"update": {"childless": {"project": [],
                                             "orphaned": False,
                                             "dataset": []},
                               "remove": {"project": [],
                                          "plate": [],
                                          "screen": [],
                                          "image": [],
                                          "dataset": [dataset.id.val]}}}
        assert data == expected

        activities_url = reverse('activities_json')

        data = _get_response_json(django_client, activities_url, {})

        # Keep polling activities until no jobs in progress
        while data['inprogress'] > 0:
            time.sleep(0.5)
            data = _get_response_json(django_client, activities_url, {})

        # individual activities/jobs are returned as dicts within json data
        for k, o in data.items():
            if hasattr(o, 'values'):    # a dict
                if 'report' in o:
                    print o['report']
                assert o['status'] == 'finished'
                assert o['job_name'] == 'Change group'
                assert o['to_group_id'] == self.group2.id.val

        # Dataset should now be in new group, contained in new Project
        conn = BlitzGateway(client_obj=self.client)
        userId = conn.getUserId()
        conn.SERVICE_OPTS.setOmeroGroup('-1')
        d = conn.getObject("Dataset", dataset.id.val)
        assert d is not None
        assert d.getDetails().group.id.val == self.group2.id.val
        p = d.getParent()
        assert p is not None
        assert p.getName() == projectName
        # Project owner should be current user
        assert p.getDetails().owner.id.val == userId
开发者ID:Daniel-Walther,项目名称:openmicroscopy,代码行数:57,代码来源:test_chgrp.py


注:本文中的omero.gateway.BlitzGateway类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。