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


Python json.load函数代码示例

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


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

示例1: get_slowdown_data

 def get_slowdown_data(self):
     if time() - self.last_get > 10:
         try:
             self._slowdown_data = json.load(open(self.data_file))
         except (ValueError, IOError):
             self._slowdown_data = {}
         self.last_get = time()
     return self._slowdown_data
开发者ID:dpgoetz,项目名称:slowdown,代码行数:8,代码来源:slowdown.py

示例2: REPLICATE

 def REPLICATE(self, req):
     """
     Handle HTTP REPLICATE request (json-encoded RPC calls for replication.)
     """
     post_args = split_and_validate_path(req, 3)
     drive, partition, hash = post_args
     if self.mount_check and not check_mount(self.root, drive):
         return HTTPInsufficientStorage(drive=drive, request=req)
     try:
         args = json.load(req.environ['wsgi.input'])
     except ValueError, err:
         return HTTPBadRequest(body=str(err), content_type='text/plain')
开发者ID:atulshridhar,项目名称:swift,代码行数:12,代码来源:server.py

示例3: REPLICATE

 def REPLICATE(self, req):
     """
     Handle HTTP REPLICATE request.
     Handler for RPC calls for account replication.
     """
     post_args = split_and_validate_path(req, 3)
     drive, partition, hash = post_args
     if self.mount_check and not check_mount(self.root, drive):
         return HTTPInsufficientStorage(drive=drive, request=req)
     try:
         args = json.load(req.environ["wsgi.input"])
     except ValueError as err:
         return HTTPBadRequest(body=str(err), content_type="text/plain")
     ret = self.replicator_rpc.dispatch(post_args, args)
     ret.request = req
     return ret
开发者ID:steveruckdashel,项目名称:swift,代码行数:16,代码来源:server.py

示例4: _from_recon_cache

    def _from_recon_cache(self, cache_keys, cache_file, openr=open):
        """retrieve values from a recon cache file

        :params cache_keys: list of cache items to retrieve
        :params cache_file: cache file to retrieve items from.
        :params openr: open to use [for unittests]
        :return: dict of cache items and their value or none if not found
        """
        try:
            with openr(cache_file, 'r') as f:
                recondata = json.load(f)
                return dict((key, recondata.get(key)) for key in cache_keys)
        except IOError:
            self.logger.exception(_('Error reading recon cache file'))
        except ValueError:
            self.logger.exception(_('Error parsing recon cache file'))
        except Exception:
            self.logger.exception(_('Error retrieving recon data'))
        return dict((key, None) for key in cache_keys)
开发者ID:CiscoAS,项目名称:swift,代码行数:19,代码来源:recon.py

示例5: split_path

        Handler for RPC calls for account replication.
        """
        start_time = time.time()
        try:
            post_args = split_path(unquote(req.path), 3)
            drive, partition, hash = post_args
            validate_device_partition(drive, partition)
        except ValueError, err:
            self.logger.increment('REPLICATE.errors')
            return HTTPBadRequest(body=str(err), content_type='text/plain',
                                  request=req)
        if self.mount_check and not check_mount(self.root, drive):
            self.logger.increment('REPLICATE.errors')
            return HTTPInsufficientStorage(drive=drive, request=req)
        try:
            args = json.load(req.environ['wsgi.input'])
        except ValueError, err:
            self.logger.increment('REPLICATE.errors')
            return HTTPBadRequest(body=str(err), content_type='text/plain')
        ret = self.replicator_rpc.dispatch(post_args, args)
        ret.request = req
        self.logger.timing_since('REPLICATE.timing', start_time)
        return ret

    @public
    def POST(self, req):
        """Handle HTTP POST request."""
        start_time = time.time()
        try:
            drive, part, account = split_path(unquote(req.path), 3)
            validate_device_partition(drive, part)
开发者ID:VictorLowther,项目名称:swift,代码行数:31,代码来源:server.py

示例6: REPLICATE

    @public
    @timing_stats
    def REPLICATE(self, req):
        """
        Handle HTTP REPLICATE request (json-encoded RPC calls for replication.)
        """
        try:
            post_args = split_path(unquote(req.path), 3)
            drive, partition, hash = post_args
            validate_device_partition(drive, partition)
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)
        if self.mount_check and not check_mount(self.root, drive):
            return HTTPInsufficientStorage(drive=drive, request=req)
        try:
            args = json.load(req.environ["wsgi.input"])
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type="text/plain")
        ret = self.replicator_rpc.dispatch(post_args, args)
        ret.request = req
        return ret

    @public
    @timing_stats
    def POST(self, req):
        """Handle HTTP POST request."""
        try:
            drive, part, account, container = split_path(unquote(req.path), 4)
            validate_device_partition(drive, part)
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)
开发者ID:DylanYu,项目名称:swift,代码行数:31,代码来源:server.py


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