• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python jsonutils.dumps函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

    def setUp(self):
        self.body = {'worker_status': 'online'}
        self.body_disk = {
            "disk_usage": {
                "/dev/sda1": {
                    "total": 313764528,
                    "used": 112512436
                }
            }
        }
        self.body_load = {
            "load_average": {
                "1": 0.24755859375,
                "5": 1.0751953125,
                "15": 0.9365234375
            }
        }

        self.body_bad = {'not_status': 'bad_status'}
        self.status = jsonutils.dumps(self.body)
        self.disk = jsonutils.dumps(self.body_disk)
        self.load = jsonutils.dumps(self.body_load)
        self.status = jsonutils.dumps(self.body)
        self.req = MagicMock()
        self.resp = MagicMock()
        self.registration = WorkerRegistration('correlation').format()
        self.worker_dict = Worker(**self.registration).format()
        self.worker_not_found = None
        self.db_handler = MagicMock()
        self.resource = WorkerUpdateResource(self.db_handler)
        self.worker_id = '51375fc4eea50d53066292b6'
开发者ID:dmend,项目名称:meniscus,代码行数:31,代码来源:resources_test.py


示例2: set_tenant

 def set_tenant(self, tenant):
     if self.cache.cache_exists(tenant.tenant_id, CACHE_TENANT):
         self.cache.cache_update(
             tenant.tenant_id, jsonutils.dumps(tenant.format()),
             DEFAULT_EXPIRES, CACHE_TENANT)
     else:
         self.cache.cache_set(
             tenant.tenant_id, jsonutils.dumps(tenant.format()),
             DEFAULT_EXPIRES, CACHE_TENANT)
开发者ID:jbenito,项目名称:meniscus,代码行数:9,代码来源:cache_handler.py


示例3: set_token

    def set_token(self, tenant_id, token):

        if self.cache.cache_exists(tenant_id, CACHE_TOKEN):
            self.cache.cache_update(
                tenant_id, jsonutils.dumps(token.format()),
                DEFAULT_EXPIRES, CACHE_TOKEN)
        else:
            self.cache.cache_set(
                tenant_id, jsonutils.dumps(token.format()),
                DEFAULT_EXPIRES, CACHE_TOKEN)
开发者ID:jbenito,项目名称:meniscus,代码行数:10,代码来源:cache_handler.py


示例4: set_routes

 def set_routes(self, pipeline_workers):
     if self.cache.cache_exists('routes', CACHE_CONFIG):
         self.cache.cache_update(
             'routes',
             jsonutils.dumps(pipeline_workers),
             CONFIG_EXPIRES, CACHE_CONFIG)
     else:
         self.cache.cache_set(
             'routes',
             jsonutils.dumps(pipeline_workers),
             CONFIG_EXPIRES, CACHE_CONFIG)
开发者ID:dmend,项目名称:meniscus,代码行数:11,代码来源:cache_handler.py


示例5: set_config

 def set_config(self, worker_config):
     if self.cache.cache_exists('worker_configuration', CACHE_CONFIG):
         self.cache.cache_update(
             'worker_configuration',
             jsonutils.dumps(worker_config.format()),
             CONFIG_EXPIRES, CACHE_CONFIG)
     else:
         self.cache.cache_set(
             'worker_configuration',
             jsonutils.dumps(worker_config.format()),
             CONFIG_EXPIRES, CACHE_CONFIG)
开发者ID:jbenito,项目名称:meniscus,代码行数:11,代码来源:cache_handler.py


示例6: setUp

 def setUp(self):
     self.tenant_id = "12673247623548752387452378"
     self.tenant_dict = {
         "tenant_id": self.tenant_id,
         "tenant_name": "TenantName",
         "_id": "507f1f77bcf86cd799439011",
         "event_producers": [
             {
                 "id": 123,
                 "name": "apache",
                 "pattern": "apache2.cee",
                 "durable": False,
                 "encrypted": False,
                 "sinks": ["elasticsearch"]
             },
             {
                 "id": 124,
                 "name": "system.auth",
                 "pattern": "auth_log.cee",
                 "durable": False,
                 "encrypted": False,
                 "sinks": ["elasticsearch", "hdfs"]
             }
         ],
         "token": {
             "valid": "c8a4db32-635a-46b6-94ed-04b1bd533f41",
             "previous": None,
             "last_changed": "2013-03-19T18:16:48.411029Z"
         }
     }
     self.producer_id = "234"
     self.event_producer = EventProducer(
         _id=self.producer_id, name="nginx", pattern="nginx")
     self.ds_handler = MagicMock()
     self.ds_handler.find_one.return_value = self.tenant_dict
     self.tenant_obj = tenant_util.load_tenant_from_dict(self.tenant_dict)
     self.tenant_cache = MagicMock()
     self.tenant_cache.cache_get.return_value = jsonutils.dumps(
         self.tenant_dict)
     self.tenant_cache.cache_exists.return_value = True
     self.tenant_cache.cache_update = MagicMock()
     self.token_cache = MagicMock()
     self.token_cache.cache_get.return_value = jsonutils.dumps(
         self.tenant_dict['token'])
     self.token_cache.cache_exists.return_value = True
     self.cache_empty = MagicMock()
     self.cache_empty.cache_exists.return_value = False
     self.cache_empty.cache_set = MagicMock()
开发者ID:abhishekroyn,项目名称:meniscus,代码行数:48,代码来源:tenant_util_test.py


示例7: setUp

    def setUp(self):

        self.tenant = {
            "tenant_id": "12345",
            "tenant_name": "TenantName",
            "_id": "507f1f77bcf86cd799439011",
            "event_producers": [
                {
                    "id": 123,
                    "name": "apache",
                    "pattern": "apache2.cee",
                    "durable": False,
                    "encrypted": False,
                    "sinks": ["elasticsearch"]
                },
                {
                    "id": 124,
                    "name": "system.auth",
                    "pattern": "auth_log.cee",
                    "durable": False,
                    "encrypted": False,
                    "sinks": ["elasticsearch", "hdfs"]
                }
            ],
            "token": {
                "valid": "c8a4db32-635a-46b6-94ed-04b1bd533f41",
                "previous": None,
                "last_changed": "2013-03-19T18:16:48.411029Z"
            }
        }
        self.ds_handler = MagicMock()
        self.ds_handler.find_one.return_value = self.tenant
        self.ds_handler_empty = MagicMock()
        self.ds_handler_empty.find_one.return_value = None
        self.ds_handler_no_tenant = MagicMock()
        self.ds_handler_no_tenant.put = MagicMock()
        self.ds_handler_no_tenant.find_one.side_effect = [None, self.tenant]
        self.tenant_cache = MagicMock()
        self.tenant_cache.cache_get.return_value = jsonutils.dumps(self.tenant)
        self.tenant_cache.cache_exists.return_value = True
        self.tenant_cache.cache_update = MagicMock()
        self.token_cache = MagicMock()
        self.token_cache.cache_get.return_value = jsonutils.dumps(
            self.tenant['token'])
        self.token_cache.cache_exists.return_value = True
        self.cache_empty = MagicMock()
        self.cache_empty.cache_exists.return_value = False
        self.cache_empty.cache_set = MagicMock()
开发者ID:jbenito,项目名称:meniscus,代码行数:48,代码来源:util_test.py


示例8: format

    def format(self, record):
        message = {'message': record.getMessage(),
                   'asctime': self.formatTime(record, self.datefmt),
                   'name': record.name,
                   'msg': record.msg,
                   'args': record.args,
                   'levelname': record.levelname,
                   'levelno': record.levelno,
                   'pathname': record.pathname,
                   'filename': record.filename,
                   'module': record.module,
                   'lineno': record.lineno,
                   'funcname': record.funcName,
                   'created': record.created,
                   'msecs': record.msecs,
                   'relative_created': record.relativeCreated,
                   'thread': record.thread,
                   'thread_name': record.threadName,
                   'process_name': record.processName,
                   'process': record.process,
                   'traceback': None}

        if hasattr(record, 'extra'):
            message['extra'] = record.extra

        if record.exc_info:
            message['traceback'] = self.formatException(record.exc_info)

        return jsonutils.dumps(message)
开发者ID:ProjectMeniscus,项目名称:meniscus,代码行数:29,代码来源:log.py


示例9: test_return_201_for_multiple_supported_sink

    def test_return_201_for_multiple_supported_sink(self):
        save_tenant = MagicMock()
        create_event_producer = MagicMock()
        with patch(
                'meniscus.api.tenant.resources.tenant_util.find_tenant',
                self.tenant_found), \
            patch(
                'meniscus.api.tenant.resources.tenant_util.save_tenant',
                save_tenant), \
            patch(
                'meniscus.api.tenant.resources.'
                'tenant_util.create_event_producer',
                create_event_producer):

            self.simulate_request(
                self.test_route,
                method='POST',
                headers={'content-type': 'application/json'},
                body=jsonutils.dumps(
                    {
                        'event_producer': {
                            'name': 'producer55',
                            'pattern': 'syslog',
                            'sinks': ["elasticsearch", "hdfs"]
                        }
                    }
                )
            )
            self.assertEqual(falcon.HTTP_201, self.srmock.status)
开发者ID:ProjectMeniscus,项目名称:meniscus,代码行数:29,代码来源:resources_test.py


示例10: _register_with_coordinator

    def _register_with_coordinator(
            self, coordinator_uri, personality, registration, auth_header):
        """
        register with the coordinator and persist the configuration to cache
        """
        try:
            resp = http_request(coordinator_uri + '/pairing', auth_header,
                                jsonutils.dumps(
                                    registration), http_verb='POST')

        except requests.RequestException:
            _LOG.exception(
                'Pairing Process: error posting worker registration')
            return False

        _LOG.debug('resp.status_code: {0}'.format(resp.status_code))

        if resp.status_code == httplib.ACCEPTED:
            body = resp.json()['worker_identity']
            config = WorkerConfiguration(
                personality, body['personality_module'], body['worker_token'],
                body['worker_id'], coordinator_uri)

            config_cache = ConfigCache()
            config_cache.set_config(config)

            return True
开发者ID:jbenito,项目名称:meniscus,代码行数:27,代码来源:pairing_process.py


示例11: test_return_201_with_optional_fields

 def test_return_201_with_optional_fields(self):
     save_tenant = MagicMock()
     create_event_producer = MagicMock()
     with patch(
             'meniscus.api.tenant.resources.tenant_util.find_tenant',
             self.tenant_found), \
         patch(
             'meniscus.api.tenant.resources.tenant_util.save_tenant',
             save_tenant), \
         patch(
             'meniscus.api.tenant.resources.'
             'tenant_util.create_event_producer',
             create_event_producer):
         self.simulate_request(
             self.test_route,
             method='POST',
             headers={'content-type': 'application/json'},
             body=jsonutils.dumps(
                 {
                     'event_producer': {
                         'name': 'producer55',
                         'pattern': 'syslog',
                         'durable': True,
                         'encrypted': False,
                         'sinks': ['elasticsearch']
                     }
                 }
             )
         )
         self.assertEqual(falcon.HTTP_201, self.srmock.status)
开发者ID:ProjectMeniscus,项目名称:meniscus,代码行数:30,代码来源:resources_test.py


示例12: _send_target_list_to_broadcaster

def _send_target_list_to_broadcaster(db, worker):
    """
    send broadcast list to broadcaster
    """

    # list of broadcasters
    broadcasters = _get_broadcaster_list(db)
    if not broadcasters:
        ## todo log no online broadcasters
        return False

    # list of broadcast targets
    broadcast_targets = _get_broadcast_targets(db, worker)
    if not broadcast_targets:
        ## todo: log failed to find target
        return False

    for broadcaster_uri in broadcasters:
        resp = None
        try:
            ## todo refactor callback address to not include /v1/callback/"
            resp = http_request(
                '{0}:8080/v1/broadcast'.format(broadcaster_uri),
                jsonutils.dumps(broadcast_targets), http_verb='PUT')
        except requests.RequestException:
            raise coordinator_errors.BroadcasterCommunicationError
        if resp.status_code == httplib.OK:
            return True
    else:
        ## todo Log broadcaster connection failure
        return False
开发者ID:dmend,项目名称:meniscus,代码行数:31,代码来源:watchlist_flow.py


示例13: test_return_200_producer_updated

 def test_return_200_producer_updated(self):
     save_tenant = MagicMock()
     with patch(
             'meniscus.api.tenant.resources.tenant_util.find_tenant',
             self.tenant_found), \
             patch(
                 'meniscus.api.tenant.resources.tenant_util.save_tenant',
                 save_tenant):
         self.simulate_request(
             '/v1/tenant/{tenant_id}/producers/{event_producer_id}'.format(
                 tenant_id=self.tenant_id,
                 event_producer_id=self.producer_id
             ),
             method='PUT',
             headers={'content-type': 'application/json'},
             body=jsonutils.dumps(
                 {
                     'event_producer': {
                         'name': self.producer_name,
                         'pattern': 'syslog',
                         'encrypted': False,
                         'durable': False
                     }
                 }
             )
         )
         self.assertEqual(falcon.HTTP_200, self.srmock.status)
开发者ID:ProjectMeniscus,项目名称:meniscus,代码行数:27,代码来源:resources_test.py


示例14: test_returns_200_worker_status

 def test_returns_200_worker_status(self):
     self.db_handler.find_one.return_value = self.worker_dict
     self.simulate_request(
         self.test_route,
         method='PUT',
         headers={'content-type': 'application/json'},
         body=jsonutils.dumps(self.worker_status))
     self.assertEqual(falcon.HTTP_200, self.srmock.status)
开发者ID:jbenito,项目名称:meniscus,代码行数:8,代码来源:resources_test.py


示例15: test_returns_400_body_validation

 def test_returns_400_body_validation(self):
     with patch('meniscus.data.model.worker_util.save_worker', MagicMock()):
         self.simulate_request(
             self.test_route,
             method='PUT',
             headers={'content-type': 'application/json'},
             body=jsonutils.dumps(self.bad_worker_status))
         self.assertEqual(falcon.HTTP_400, self.srmock.status)
开发者ID:ProjectMeniscus,项目名称:meniscus,代码行数:8,代码来源:resources_test.py


示例16: test_returns_400_for_no_message_token_header

 def test_returns_400_for_no_message_token_header(self):
     self.simulate_request(
         self.test_route,
         method='POST',
         headers={
             'content-type': 'application/json'
         },
         body=jsonutils.dumps(self.message))
     self.assertEquals(falcon.HTTP_400, self.srmock.status)
开发者ID:aelkikhia,项目名称:meniscus,代码行数:9,代码来源:resources_test.py


示例17: test_raises_worker_not_found

 def test_raises_worker_not_found(self):
     with patch('meniscus.data.model.worker_util.find_worker',
                MagicMock(return_value=None)):
         self.simulate_request(
             self.test_route,
             method='PUT',
             headers={'content-type': 'application/json'},
             body=jsonutils.dumps(self.worker_status))
         self.assertEqual(falcon.HTTP_404, self.srmock.status)
开发者ID:zinic,项目名称:meniscus,代码行数:9,代码来源:resources_test.py


示例18: test_return_400_for_tenant_id_empty

 def test_return_400_for_tenant_id_empty(self):
     with patch('meniscus.api.tenant.resources.tenant_util.find_tenant',
                self.tenant_not_found):
         self.simulate_request(
             self.test_route,
             method='POST',
             headers={'content-type': 'application/json'},
             body=jsonutils.dumps({'tenant': {"tenant_id": ""}}))
         self.assertEqual(falcon.HTTP_400, self.srmock.status)
开发者ID:ProjectMeniscus,项目名称:meniscus,代码行数:9,代码来源:resources_test.py


示例19: test_returns_415_for_unsupported_content_type

 def test_returns_415_for_unsupported_content_type(self):
     self.simulate_request(
         self.test_route,
         method='POST',
         headers={
             'content-type': 'application/xml',
         },
         body=jsonutils.dumps(self.body))
     self.assertEqual(falcon.HTTP_415, self.srmock.status)
开发者ID:zinic,项目名称:meniscus,代码行数:9,代码来源:resources_test.py


示例20: test_returns_400_for_bad_personality

 def test_returns_400_for_bad_personality(self):
     self.simulate_request(
         self.test_route,
         method='POST',
         headers={
             'content-type': 'application/json',
         },
         body=jsonutils.dumps(self.body_bad_personality))
     self.assertEqual(falcon.HTTP_400, self.srmock.status)
开发者ID:zinic,项目名称:meniscus,代码行数:9,代码来源:resources_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python image.BooleanImage类代码示例发布时间:2022-05-27
下一篇:
Python memory_profiler.memory_usage函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap