sandbox.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码
def _install_import_hooks(config, path_override_hook):
  """Install runtime's import hooks.

  These hooks customize the import process as per
  https://docs.python.org/2/library/sys.html#sys.meta_path .

  Args:
    config: An apphosting/tools/devappserver2/runtime_config.proto
        for this instance.
    path_override_hook: A hook for importing special appengine
        versions of select libraries from the libraries
        section of the current module's app.yaml file.
  """
  if not config.vm:
    enabled_library_regexes = [
        NAME_TO_CMODULE_WHITELIST_REGEX[lib.name] for lib in config.libraries
        if lib.name in NAME_TO_CMODULE_WHITELIST_REGEX]
    sys.meta_path = [
        StubModuleImportHook(),
        ModuleOverrideImportHook(_MODULE_OVERRIDE_POLICIES),
        CModuleImportHook(enabled_library_regexes),
        path_override_hook,
        PyCryptoRandomImportHook,
        PathRestrictingImportHook(enabled_library_regexes)]
  else:
    sys.meta_path = [
        # Picks up custom versions of certain libraries in the libraries section
        #     of app.yaml
        path_override_hook,
        # Picks up a custom version of Crypto.Random.OSRNG.posix.
        # TODO: Investigate removing this as it may not be needed
        #     for vms since they are able to read /dev/urandom, I left it for
        #     consistency.
        PyCryptoRandomImportHook]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号