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


Python r_client.get函数代码示例

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


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

示例1: test_sample_template_patch_request

    def test_sample_template_patch_request(self):
        # Wrong operation operation
        obs = sample_template_patch_request("[email protected]", "add", "/1/columns/season_environment/")
        exp = {"status": "error", "message": 'Operation "add" not supported. ' "Current supported operations: remove"}
        self.assertEqual(obs, exp)
        # Wrong path parameter
        obs = sample_template_patch_request("[email protected]", "remove", "/columns/season_environment/")
        exp = {"status": "error", "message": "Incorrect path parameter"}
        self.assertEqual(obs, exp)
        # No access
        obs = sample_template_patch_request("[email protected]", "remove", "/1/columns/season_environment/")
        exp = {"status": "error", "message": "User does not have access to study"}
        self.assertEqual(obs, exp)
        # Success
        obs = sample_template_patch_request("[email protected]", "remove", "/1/columns/season_environment/")
        exp = {"status": "success", "message": ""}
        self.assertEqual(obs, exp)

        # This is needed so the clean up works - this is a distributed system
        # so we need to make sure that all processes are done before we reset
        # the test database
        obs = r_client.get("sample_template_1")
        self.assertIsNotNone(obs)
        redis_info = loads(r_client.get(loads(obs)["job_id"]))
        while redis_info["status_msg"] == "Running":
            sleep(0.05)
            redis_info = loads(r_client.get(loads(obs)["job_id"]))

        ST = qdb.metadata_template.sample_template.SampleTemplate
        self.assertNotIn("season_environment", ST(1).categories())
开发者ID:josenavas,项目名称:QiiTa,代码行数:30,代码来源:test_sample_template.py

示例2: test_delete_artifact

 def test_delete_artifact(self):
     response = self.post('/artifact/',
                          {'artifact_id': 2})
     self.assertEqual(response.code, 200)
     # This is needed so the clean up works - this is a distributed system
     # so we need to make sure that all processes are done before we reset
     # the test database
     obs = r_client.get('prep_template_1')
     self.assertIsNotNone(obs)
     redis_info = loads(r_client.get(loads(obs)['job_id']))
     while redis_info['status_msg'] == 'Running':
         sleep(0.05)
         redis_info = loads(r_client.get(loads(obs)['job_id']))
开发者ID:carlyboyd,项目名称:qiita,代码行数:13,代码来源:test_artifact.py

示例3: test_artifact_delete_req

    def test_artifact_delete_req(self):
        obs = artifact_delete_req(3, '[email protected]')
        exp = {'status': 'success', 'message': ''}
        self.assertEqual(obs, exp)

        # This is needed so the clean up works - this is a distributed system
        # so we need to make sure that all processes are done before we reset
        # the test database
        obs = r_client.get('prep_template_1')
        self.assertIsNotNone(obs)
        redis_info = loads(r_client.get(loads(obs)['job_id']))
        while redis_info['status_msg'] == 'Running':
            sleep(0.05)
            redis_info = loads(r_client.get(loads(obs)['job_id']))
开发者ID:carlyboyd,项目名称:qiita,代码行数:14,代码来源:test_artifact.py

示例4: test_sample_template_delete_req

    def test_sample_template_delete_req(self):
        obs = sample_template_delete_req(1, "[email protected]")
        exp = {"status": "success", "message": ""}
        self.assertEqual(obs, exp)

        obs = r_client.get("sample_template_1")
        self.assertIsNotNone(obs)

        # This is needed so the clean up works - this is a distributed system
        # so we need to make sure that all processes are done before we reset
        # the test database
        redis_info = loads(r_client.get(loads(obs)["job_id"]))
        while redis_info["status_msg"] == "Running":
            sleep(0.05)
            redis_info = loads(r_client.get(loads(obs)["job_id"]))
开发者ID:josenavas,项目名称:QiiTa,代码行数:15,代码来源:test_sample_template.py

示例5: unlisten_to_node

    def unlisten_to_node(self, id_):
        """Stop listening to a job

        Parameters
        ----------
        id_ : str
            An ID to remove

        Returns
        --------
        str or None
            The ID removed or None if the ID was not removed
        """
        id_pubsub = _pubsub_key(id_)

        if id_pubsub in self._listening_to:
            del self._listening_to[id_pubsub]
            self.toredis.unsubscribe(id_pubsub)

            parent = json_decode(r_client.get(id_)).get('parent', None)
            if parent is not None:
                r_client.srem(_children_key(parent), id_)
            r_client.srem(self.group_children, id_)

            return id_
开发者ID:biocore,项目名称:mustached-octo-ironman,代码行数:25,代码来源:group.py

示例6: get

    def get(self, job_id):
        details = loads(r_client.get(job_id))

        if details["status_msg"] == "Failed":
            # TODO: something smart
            pass

        self.redirect("/")
开发者ID:mivamo1214,项目名称:qiita,代码行数:8,代码来源:compute.py

示例7: listen_to_node

 def listen_to_node(self, id_):
     """Attach a callback on the job pubsub if it exists"""
     if r_client.get(id_) is None:
         return
     else:
         self.toredis.subscribe(_pubsub_key(id_), callback=self.callback)
         self._listening_to[_pubsub_key(id_)] = id_
         return id_
开发者ID:biocore,项目名称:mustached-octo-ironman,代码行数:8,代码来源:group.py

示例8: safe_submit

def safe_submit(*args, **kwargs):
    """Safe wraper for the submit function

    There are cases in which a race condition may occur: submit returns the
    job id but moi hasn't submitted the job. In some cases this is not
    acceptable, so this wrapper makes sure that the job_id
    is returned only once the job has already been submitted.

    From previous tests, the while loop is executed ~2 times, so there is not
    much time lost in here
    """
    job_id = submit(*args, **kwargs)
    payload = r_client.get(job_id)
    while not payload:
        sleep(0.005)
        payload = r_client.get(job_id)

    return job_id
开发者ID:carlyboyd,项目名称:qiita,代码行数:18,代码来源:context.py

示例9: test_sample_template_post_req

    def test_sample_template_post_req(self):
        obs = sample_template_post_req(1, '[email protected]', '16S',
                                       'uploaded_file.txt')
        exp = {'status': 'success',
               'message': '',
               'file': 'uploaded_file.txt'}
        self.assertEqual(obs, exp)

        obs = r_client.get('sample_template_1')
        self.assertIsNotNone(obs)

        # This is needed so the clean up works - this is a distributed system
        # so we need to make sure that all processes are done before we reset
        # the test database
        redis_info = loads(r_client.get(loads(obs)['job_id']))
        while redis_info['status_msg'] == 'Running':
            sleep(0.05)
            redis_info = loads(r_client.get(loads(obs)['job_id']))
开发者ID:robertoalvarezm,项目名称:qiita,代码行数:18,代码来源:test_sample_template.py

示例10: test_status_change

    def test_status_change(self):
        new_status = 'new status'

        r_client.set(self.test_id, json.dumps(self.test_job_info))

        # _status_change will return the old status
        obs = _status_change(self.test_id, new_status)
        self.assertEqual(obs, self.test_job_info['status'])

        obs = json.loads(r_client.get(self.test_id))
        self.assertEqual(obs['status'], new_status)
开发者ID:biocore,项目名称:mustached-octo-ironman,代码行数:11,代码来源:test_job.py

示例11: test__submit

    def test__submit(self):
        ctx = ctxs.values()[0]
        cmd = 'echo "hello"'
        id_, pid_ = _submit(ctx, 'no parent', 'test', '/', system_call, cmd)
        self.test_keys.append(id_)
        self.test_keys.append(pid_)
        sleep(2)

        obs = json.loads(r_client.get(id_))
        self.assertEqual(obs['result'], [u"hello\n", u"", 0])
        self.assertEqual(obs['status'], 'Success')
        self.assertNotEqual(obs['date_start'], None)
        self.assertNotEqual(obs['date_end'], None)
开发者ID:squirrelo,项目名称:mustached-octo-ironman,代码行数:13,代码来源:test_job.py

示例12: test_redis_wrap_except

    def test_redis_wrap_except(self):
        def foo(a, b, **kwargs):
            return a+b

        with self.assertRaises(TypeError):
            _redis_wrap(self.test_job_info, foo, 1)

        obs = json.loads(r_client.get(self.test_job_info['id']))
        self.assertEqual(obs['result'][0],
                         u'Traceback (most recent call last):\n')
        self.assertEqual(obs['status'], 'Failed')
        self.assertNotEqual(obs['date_start'], None)
        self.assertNotEqual(obs['date_end'], None)
开发者ID:biocore,项目名称:mustached-octo-ironman,代码行数:13,代码来源:test_job.py

示例13: test_get_sample_template_processing_status

    def test_get_sample_template_processing_status(self):
        key = SAMPLE_TEMPLATE_KEY_FORMAT % 1

        obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
        self.assertFalse(obs_proc)
        self.assertEqual(obs_at, "")
        self.assertEqual(obs_am, "")

        # Without job id
        r_client.set(key, dumps({"job_id": None, "status": "success", "message": ""}))
        obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
        self.assertFalse(obs_proc)
        self.assertEqual(obs_at, "success")
        self.assertEqual(obs_am, "")

        # With job id and processing
        r_client.set(key, dumps({"job_id": "test_job_id"}))
        r_client.set("test_job_id", dumps({"status_msg": "Running"}))
        obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
        self.assertTrue(obs_proc)
        self.assertEqual(obs_at, "info")
        self.assertEqual(obs_am, "This sample template is currently being processed")

        # With job id and success
        r_client.set(key, dumps({"job_id": "test_job_id"}))
        r_client.set(
            "test_job_id", dumps({"status_msg": "Success", "return": {"status": "success", "message": "Some\nwarning"}})
        )
        obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
        self.assertFalse(obs_proc)
        self.assertEqual(obs_at, "success")
        self.assertEqual(obs_am, "Some</br>warning")
        obs = loads(r_client.get(key))
        self.assertEqual(obs, {"job_id": None, "status": "success", "message": "Some</br>warning"})

        # With job and not success
        r_client.set(key, dumps({"job_id": "test_job_id"}))
        r_client.set(
            "test_job_id", dumps({"status_msg": "Failed", "return": {"status": "error", "message": "Some\nerror"}})
        )
        obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
        self.assertFalse(obs_proc)
        self.assertEqual(obs_at, "error")
        self.assertEqual(obs_am, "Some</br>error")

        # With job expired
        r_client.set(key, dumps({"job_id": "non_existent_job"}))
        obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
        self.assertFalse(obs_proc)
        self.assertEqual(obs_at, "")
        self.assertEqual(obs_am, "")
开发者ID:josenavas,项目名称:QiiTa,代码行数:51,代码来源:test_sample_template.py

示例14: wrapper

    def wrapper(handler, *args, **kwargs):
        header = handler.request.headers.get('Authorization', None)
        if header is None:
            _oauth_error(handler, 'Oauth2 error: invalid access token',
                         'invalid_request')
            return
        token_info = header.split()
        # Based on RFC6750 if reply is not 2 elements in the format of:
        # ['Bearer', token] we assume a wrong reply
        if len(token_info) != 2 or token_info[0] != 'Bearer':
            _oauth_error(handler, 'Oauth2 error: invalid access token',
                         'invalid_grant')
            return

        token = token_info[1]
        db_token = r_client.hgetall(token)
        if not db_token:
            # token has timed out or never existed
            _oauth_error(handler, 'Oauth2 error: token has timed out',
                         'invalid_grant')
            return
        # Check daily rate limit for key if password style key
        if db_token['grant_type'] == 'password':
            limit_key = '%s_%s_daily_limit' % (db_token['client_id'],
                                               db_token['user'])
            limiter = r_client.get(limit_key)
            if limiter is None:
                # Set limit to 5,000 requests per day
                r_client.setex(limit_key, 5000, 86400)
            else:
                r_client.decr(limit_key)
                if int(r_client.get(limit_key)) <= 0:
                    _oauth_error(
                        handler, 'Oauth2 error: daily request limit reached',
                        'invalid_grant')
                    return

        return f(handler, *args, **kwargs)
开发者ID:carlyboyd,项目名称:qiita,代码行数:38,代码来源:oauth2.py

示例15: test_post_artifact

    def test_post_artifact(self):
        args = {
            'artifact-type': 'FASTQ',
            'name': 'New Artifact Handler test',
            'prep-template-id': self.prep.id,
            'raw_forward_seqs': [self.fwd_fp],
            'raw_barcodes': [self.barcodes_fp],
            'raw_reverse_seqs': [],
            'import-artifact': ''}
        response = self.post('/study/new_artifact/', args)
        self.assertEqual(response.code, 200)

        # make sure new artifact created
        obs = r_client.get('prep_template_%s' % self.prep.id)
        self.assertIsNotNone(obs)
        redis_info = loads(r_client.get(loads(obs)['job_id']))
        while redis_info['status_msg'] == 'Running':
            sleep(0.05)
            redis_info = loads(r_client.get(loads(obs)['job_id']))
        new_artifact_id = get_count('qiita.artifact')
        artifact = Artifact(new_artifact_id)
        self.assertEqual(artifact.name, 'New Artifact Handler test')
        self._files_to_remove.extend([fp for _, fp, _ in artifact.filepaths])
开发者ID:carlyboyd,项目名称:qiita,代码行数:23,代码来源:test_artifact.py


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