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


Python cloudstorage.RetryParams方法代码示例

本文整理汇总了Python中cloudstorage.RetryParams方法的典型用法代码示例。如果您正苦于以下问题:Python cloudstorage.RetryParams方法的具体用法?Python cloudstorage.RetryParams怎么用?Python cloudstorage.RetryParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudstorage的用法示例。


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

示例1: __init__

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def __init__(self, *args, **kwargs):
    # webapp framework invokes initialize after __init__.
    # webapp2 framework invokes initialize within __init__.
    # Python27 runtime swap webapp with webapp2 underneath us.
    # Since initialize will conditionally change this field,
    # it needs to be set before calling super's __init__.
    self._preprocess_success = False
    super(TaskQueueHandler, self).__init__(*args, **kwargs)
    if cloudstorage:
      cloudstorage.set_default_retry_params(
          cloudstorage.RetryParams(
              min_retries=5,
              max_retries=10,
              urlfetch_timeout=parameters._GCS_URLFETCH_TIMEOUT_SEC,
              save_access_token=True,
              _user_agent=self._DEFAULT_USER_AGENT)) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:18,代码来源:base_handler.py

示例2: upload

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def upload(self, attachment, content):
        ''' Uploads a file to the default cloud storage bucket

        Args:
        attachment - The models.Attachment metadata for the file
        content - The file content
        '''
        filename = '/{}/{}'.format(self.bucket_name,
                                   attachment.stored_filename)
        write_retry_params = gcs.RetryParams(backoff_factor=1.1)
        gcs_file = gcs.open(
            filename,
            'w',
            content_type=attachment.mime_type,
            retry_params=write_retry_params)
        gcs_file.write(content)
        gcs_file.close() 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:19,代码来源:storage.py

示例3: create_file

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def create_file(self, filename):
        """Create a file."""

        self.response.write('Creating file {}\n'.format(filename))

        # The retry_params specified in the open call will override the default
        # retry params for this particular file handle.
        write_retry_params = cloudstorage.RetryParams(backoff_factor=1.1)
        with cloudstorage.open(
            filename, 'w', content_type='text/plain', options={
                'x-goog-meta-foo': 'foo', 'x-goog-meta-bar': 'bar'},
                retry_params=write_retry_params) as cloudstorage_file:
            cloudstorage_file.write('abcde\n')
            cloudstorage_file.write('f'*1024*4 + '\n')
        self.tmp_filenames_to_clean_up.append(filename)
# [END write]

# [START read] 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:20,代码来源:main.py

示例4: _make_retry_params

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def _make_retry_params():
  """RetryParams structure configured to store access token in Datastore."""
  # Note that 'cloudstorage.set_default_retry_params' function stores retry
  # params in per-request thread local storage, which means it needs to be
  # called for each request. Since we are wrapping all cloudstorage library
  # calls anyway, it's more convenient just to pass RetryParams explicitly,
  # instead of making it a default for request with 'set_default_retry_params'.
  return cloudstorage.RetryParams(save_access_token=True) 
开发者ID:luci,项目名称:luci-py,代码行数:10,代码来源:gcs.py

示例5: post

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def post():
    form = PhotoForm(CombinedMultiDict((request.files, request.form)))
    if request.method == 'POST' and form.validate():
        filename = '%s.%s' % (str(uuid.uuid4()),
                              secure_filename(form.input_photo.data.filename))
        content_type = content_types[filename.split('.')[-1]]
        write_retry_params = gcs.RetryParams(backoff_factor=1.1)
        gcs_file = gcs.open('/%s/%s' % (bucket_name, filename), 'w',
                            retry_params=write_retry_params,
                            content_type=content_type,
                            options={'x-goog-acl': 'authenticated-read'})
        for _ in form.input_photo.data.stream:
            gcs_file.write(_)
        gcs_file.close()

        labels = get_labels(filename)
        tags = [translate_text(label.description) for label in labels]
        entity = Photo(id=filename, tags=tags,
                       parent=ndb.Key('User', 'default'))
        entity.put()

        for tag in tags:
            entity = ndb.Key('User', 'default', 'Tags', tag).get()
            if entity:
                entity.count += 1
            else:
                entity = Tags(count=1, id=tag,
                              parent=ndb.Key('User', 'default'))
            entity.put()
        return render_template('post.html', storage_path=storage_path,
                               filename=filename, tags=tags)
    else:
        return redirect(url_for('photos')) 
开发者ID:GoogleCloudPlatform,项目名称:appengine-photoalbum-example,代码行数:35,代码来源:main.py

示例6: write

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def write(self, path, content):
        write_retry_params = gcs.RetryParams(backoff_factor=1.1)
        gcs_file = gcs.open(path, 'w', options={'x-goog-acl': self.acl}, retry_params=write_retry_params)
        gcs_file.write(content)
        gcs_file.close() 
开发者ID:ml2grow,项目名称:GAEPyPI,代码行数:7,代码来源:storage.py

示例7: delete_file_or_list

# 需要导入模块: import cloudstorage [as 别名]
# 或者: from cloudstorage import RetryParams [as 别名]
def delete_file_or_list(self, filename_or_list):
    if isinstance(filename_or_list, list):
      for filename in filename_or_list:
        self.delete_file_or_list(filename)
    else:
      filename = filename_or_list
      retry_params = cloudstorage.RetryParams(min_retries=self._MIN_RETRIES,
                                              max_retries=self._MAX_RETRIES)
      # pylint: disable=bare-except
      try:
        cloudstorage.delete(filename, retry_params)
      except:
        pass 
开发者ID:GoogleCloudPlatform,项目名称:appengine-mapreduce,代码行数:15,代码来源:shuffler.py


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