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


Python config.settings方法代码示例

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


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

示例1: file_size

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def file_size(size):
  """Reports the size of a file fetched from GCS by whitelisted clients.

  If the client's requests are not whitelisted for monitoring, does nothing.

  Args:
    size: Size of the file in bytes.
  """
  ip = auth.get_peer_ip()
  for cfg in config.settings().client_monitoring_config:
    if auth.is_in_ip_whitelist(cfg.ip_whitelist, ip):
      _bytes_requested.increment_by(
          size,
          fields={
              'client_name': cfg.label,
              'client_email': auth.get_peer_identity().to_bytes(),
              'download_source': 'GCS'
          })
      return 
开发者ID:luci,项目名称:luci-py,代码行数:21,代码来源:metrics.py

示例2: entry_key_from_id

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def entry_key_from_id(key_id):
  """Returns the ndb.Key for the key_id."""
  namespace, hash_key = key_id.rsplit('/', 1)
  # https://crbug.com/944896
  N = config.settings().sharding_letters
  assert N in (1, 4), N
  if namespace != 'default-gzip':
    # This is to work around https://crbug.com/943571, where prod instances have
    # sharding_letters: 1. Oops.
    #
    # This is a temporary hack until we migrate off default-gzip and
    # deprecate sharding_letters.
    N = 4
  return ndb.Key(
      ContentEntry, key_id,
      parent=datastore_utils.shard_key(hash_key, N, 'ContentShard')) 
开发者ID:luci,项目名称:luci-py,代码行数:18,代码来源:model.py

示例3: delete_entry_and_gs_entry_async

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def delete_entry_and_gs_entry_async(key):
  """Deletes synchronously a ContentEntry and its GS file.

  It deletes the ContentEntry first, then the file in GS. The worst case is that
  the GS file is left behind and will be reaped by a lost GS task queue. The
  reverse is much worse, having a ContentEntry pointing to a deleted GS entry
  will lead to lookup failures.
  """
  bucket = config.settings().gs_bucket
  # Note that some content entries may NOT have corresponding GS files. That
  # happens for small entry stored inline in the datastore. Since this function
  # operates only on keys, it can't distinguish "large" entries stored in GS
  # from "small" ones stored inline. So instead it always tries to delete the
  # corresponding GS files, silently skipping ones that are not there.
  # Always delete ContentEntry first.
  name = key.string_id()
  yield key.delete_async()
  # This is synchronous.
  yield gcs.delete_file_async(bucket, name, ignore_missing=True)
  raise ndb.Return(None) 
开发者ID:luci,项目名称:luci-py,代码行数:22,代码来源:model.py

示例4: setUp

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def setUp(self):
    """Creates a new app instance for every test case."""
    super(MainTest, self).setUp()
    self.testbed.init_blobstore_stub()
    self.testbed.init_urlfetch_stub()
    admin = auth.Identity(auth.IDENTITY_USER, 'admin@example.com')
    full_access_group = config.settings().auth.full_access_group
    auth.bootstrap_group(full_access_group, [admin])
    auth_testing.mock_get_current_identity(self, admin)
    version = utils.get_app_version()
    self.mock(utils, 'get_task_queue_host', lambda: version)
    self.testbed.setup_env(current_version_id='testbed.version')
    self.source_ip = '127.0.0.1'
    self.app = webtest.TestApp(
        handlers_backend.create_application(debug=True),
        extra_environ={'REMOTE_ADDR': self.source_ip})
    # add a private key; signing depends on config.settings()
    make_private_key()
    # Remove the check for dev server in should_push_to_gs().
    self.mock(utils, 'is_local_dev_server', lambda: False) 
开发者ID:luci,项目名称:luci-py,代码行数:22,代码来源:handlers_backend_test.py

示例5: create_application

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def create_application():
  ereporter2.register_formatter()

  # Zap out the ndb in-process cache by default.
  # This cache causes excessive memory usage in in handler where a lot of
  # entities are fetched in one query. When coupled with high concurrency
  # as specified via max_concurrent_requests in app.yaml, this may cause out of
  # memory errors.
  ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
  ndb.Context._cache_policy = staticmethod(lambda _key: False)

  backend = handlers_backend.create_application(False)

  def is_enabled_callback():
    return config.settings().enable_ts_monitoring

  gae_ts_mon.initialize(backend, is_enabled_fn=is_enabled_callback)
  return backend 
开发者ID:luci,项目名称:luci-py,代码行数:20,代码来源:main_backend.py

示例6: post

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def post(self):
    # Convert MultiDict into a dict.
    params = {
      k: self.cast_to_type(k, self.request.params.getone(k))
      for k in self.request.params
      if k not in ('keyid', 'xsrf_token')
    }
    cfg = config.settings(fresh=True)
    keyid = int(self.request.get('keyid', '0'))
    if cfg.key.integer_id() != keyid:
      self.common('Update conflict %s != %s' % (cfg.key.integer_id(), keyid))
      return
    cfg.populate(**params)
    try:
      # Ensure key is correct, it's easy to make a mistake when creating it.
      gcs.URLSigner.load_private_key(cfg.gs_private_key)
    except Exception as exc:
      # TODO(maruel): Handling Exception is too generic. And add self.abort(400)
      self.response.write('Bad private key: %s' % exc)
      return
    cfg.store(updated_by=auth.get_current_identity().to_bytes())
    self.common('Settings updated') 
开发者ID:luci,项目名称:luci-py,代码行数:24,代码来源:handlers_frontend.py

示例7: FTPdeleteDirectory

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def FTPdeleteDirectory(self, directory, ftp = None):
        host = settings["dynamic_rfi"]["ftp"]["ftp_host"]
        user = settings["dynamic_rfi"]["ftp"]["ftp_user"]
        pw   = settings["dynamic_rfi"]["ftp"]["ftp_pass"]
        if ftp == None: 
            self._log("Deleting directory recursivly from FTP server '%s'..."%(host), self.LOG_DEBUG)
            ftp = FTP(host, user, pw)
        
        ftp.cwd(directory)
        for i in ftp.nlst(directory):
            try:
                ftp.delete(i)
            except:
                self.FTPdeleteDirectory(i, ftp)
            
        ftp.cwd(directory)
        ftp.rmd(directory) 
开发者ID:kurobeats,项目名称:fimap,代码行数:19,代码来源:baseClass.py

示例8: putLocalPayload

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def putLocalPayload(self, content, append):
        fl = settings["dynamic_rfi"]["local"]["local_path"] + append
        dirname = os.path.dirname(fl)
        if (not os.path.exists(dirname)):
            os.makedirs(dirname)
        up = {}
        
        up["local"] = settings["dynamic_rfi"]["local"]["local_path"]
        if append.find("/") != -1 and (not append.startswith("/")):
            up["local"] = settings["dynamic_rfi"]["local"]["local_path"] + append[:append.find("/")]
        up["http"] = settings["dynamic_rfi"]["local"]["http_map"]
        f = open(fl, "w")
        f.write(content)
        f.close()
        
        return(up) 
开发者ID:kurobeats,项目名称:fimap,代码行数:18,代码来源:baseClass.py

示例9: executeRFI

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def executeRFI(self, URL, postdata, appendix, content, header):
        content = self.payload_encode(content)
        
        if (appendix == "%00"): appendix = ""
        if settings["dynamic_rfi"]["mode"]=="ftp":
            up = self.FTPuploadFile(content, appendix)
            code = self.doPostRequest(URL, postdata, header)
            if up["dirstruct"]:
                self.FTPdeleteDirectory(up["ftp"])
            else:
                self.FTPdeleteFile(up["ftp"])
            return(code)
        elif settings["dynamic_rfi"]["mode"]=="local":
            up = self.putLocalPayload(content, appendix)
            code = self.doPostRequest(URL, postdata, additionalHeaders=header)
            self.deleteLocalPayload(up["local"])
            return(code) 
开发者ID:kurobeats,项目名称:fimap,代码行数:19,代码来源:codeinjector.py

示例10: gs_url_signer

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def gs_url_signer(self):
    """On demand instance of CloudStorageURLSigner object."""
    if not self._gs_url_signer:
      settings = config.settings()
      self._gs_url_signer = gcs.URLSigner(
          settings.gs_bucket,
          settings.gs_client_id_email,
          settings.gs_private_key)
    return self._gs_url_signer 
开发者ID:luci,项目名称:luci-py,代码行数:11,代码来源:handlers_endpoints_v1.py

示例11: new_content_entry

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def new_content_entry(key, **kwargs):
  """Generates a new ContentEntry for the request.

  Doesn't store it. Just creates a new ContentEntry instance.
  """
  expiration, next_tag = expiration_jitter(
      utils.utcnow(), config.settings().default_expiration)
  return ContentEntry(
      key=key, expiration_ts=expiration, next_tag_ts=next_tag, **kwargs) 
开发者ID:luci,项目名称:luci-py,代码行数:11,代码来源:model.py

示例12: create_application

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def create_application():
  ereporter2.register_formatter()

  # Zap out the ndb in-process cache by default.
  # This cache causes excessive memory usage in in handler where a lot of
  # entities are fetched in one query. When coupled with high concurrency
  # as specified via max_concurrent_requests in app.yaml, this may cause out of
  # memory errors.
  ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
  ndb.Context._cache_policy = staticmethod(lambda _key: False)

  # App that serves HTML pages and old API.
  frontend = handlers_frontend.create_application(False)

  def is_enabled_callback():
    return config.settings().enable_ts_monitoring

  gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
  # App that serves new endpoints API.
  endpoints_api = endpoints_webapp2.api_server([
      handlers_endpoints_v1.IsolateService,
      # components.config endpoints for validation and configuring of
      # luci-config service URL.
      config.ConfigApi,
  ])
  gae_ts_mon.instrument_wsgi_application(endpoints_api)

  prpc_api = webapp2.WSGIApplication(handlers_prpc.get_routes())
  return frontend, endpoints_api, prpc_api 
开发者ID:luci,项目名称:luci-py,代码行数:31,代码来源:main_frontend.py

示例13: make_private_key

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def make_private_key():
  new_key = RSA.generate(1024)
  pem_key = base64.b64encode(new_key.exportKey('PEM'))
  config.settings()._ds_cfg.gs_private_key = pem_key 
开发者ID:luci,项目名称:luci-py,代码行数:6,代码来源:handlers_endpoints_v1_test.py

示例14: setUp

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def setUp(self):
    super(IsolateServiceTest, self).setUp()
    self.testbed.init_blobstore_stub()
    self.testbed.init_urlfetch_stub()
    # It seems like there is a singleton state preserved across the tests,
    # making it hard to re-run the complete setUp procedure. Therefore we pre-
    # register all the possible identities being used in the tests.
    all_authed_ids = [
        auth.Identity(auth.IDENTITY_USER, 'admin@example.com'),
        auth.Identity(auth.IDENTITY_USER, 'admin@appspot.gserviceaccount.com'),
        auth.Identity(auth.IDENTITY_SERVICE, 'adminapp'),
    ]
    admin = all_authed_ids[0]
    full_access_group = config.settings().auth.full_access_group
    auth.bootstrap_group(full_access_group, all_authed_ids)
    auth_testing.mock_get_current_identity(self, admin)
    version = utils.get_app_version()
    self.mock(utils, 'get_task_queue_host', lambda: version)
    self.testbed.setup_env(current_version_id='testbed.version')
    self.source_ip = '127.0.0.1'
    # It is needed solely for self.execute_tasks(), which processes tasks queues
    # on the backend application.
    self.app = webtest.TestApp(
        handlers_backend.create_application(debug=True),
        extra_environ={'REMOTE_ADDR': self.source_ip})
    # add a private key; signing depends on config.settings()
    make_private_key()
    # Remove the check for dev server in should_push_to_gs().
    self.mock(utils, 'is_local_dev_server', lambda: False) 
开发者ID:luci,项目名称:luci-py,代码行数:31,代码来源:handlers_endpoints_v1_test.py

示例15: isolate_writable

# 需要导入模块: import config [as 别名]
# 或者: from config import settings [as 别名]
def isolate_writable():
  """Returns True if current user can write to isolate."""
  full_access = auth.is_group_member(config.settings().auth.full_access_group)
  return full_access or auth.is_admin() 
开发者ID:luci,项目名称:luci-py,代码行数:6,代码来源:acl.py


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