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


Python google.__path__方法代码示例

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


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

示例1: fix_protobuf_package

# 需要导入模块: import google [as 别名]
# 或者: from google import __path__ [as 别名]
def fix_protobuf_package():
  """Modifies 'google' package to include path to 'google.protobuf' package.

  Prefer our own proto package on the server. Note that this functions is not
  used on the Swarming bot nor any other client.
  """
  if sys.version_info.major != 2:
    # Unnecessary on python3.
    return
  # google.__path__[0] will be google_appengine/google.
  import google
  if len(google.__path__) > 1:
    return

  # We do not mind what 'google' get used, inject protobuf in there.
  path = os.path.join(THIS_DIR, 'third_party', 'protobuf', 'google')
  google.__path__.append(path)

  # six is needed for oauth2client and webtest (local testing).
  six_path = os.path.join(THIS_DIR, 'third_party', 'six')
  if six_path not in sys.path:
    sys.path.insert(0, six_path) 
开发者ID:luci,项目名称:luci-py,代码行数:24,代码来源:utils.py

示例2: fix_protobuf_package

# 需要导入模块: import google [as 别名]
# 或者: from google import __path__ [as 别名]
def fix_protobuf_package():
  """Ensures that the bundled version of protobuf is used.

  Inspired by components/utils.py
  """
  # In some system, google is preloaded when using runit.py, which is implicitly
  # loaded by using the zip support, as used with swarming_bot.zip. Using
  # 'python -s -S' doesn't work to skip 'import site' in this case. So use the
  # nuclear option, unload the package if found.
  if 'google' in sys.modules:
    del sys.modules['google']
  # Completely zap out preinstalled google. This works because package google
  # itself has no functionality.
  path_to_google = os.path.join(THIS_FILE, 'third_party', 'google')
  import google
  google.__path__.insert(0, path_to_google)
  del google.__path__[1:]

  # Sanity check.
  import google.protobuf
  # pylint: disable=unused-variable
  from google.protobuf import symbol_database


# Then it's safe to import the rest. 
开发者ID:luci,项目名称:luci-py,代码行数:27,代码来源:__main__.py

示例3: set_appengine_imports

# 需要导入模块: import google [as 别名]
# 或者: from google import __path__ [as 别名]
def set_appengine_imports():
  gae_path = os.getenv('GAE')
  if gae_path is None:
    return

  sys.path.insert(0, gae_path)
  sys.modules.pop('google', None)
  import dev_appserver
  dev_appserver.fix_sys_path()

  if GOOGLE_PACKAGE_PATH is not None:
    import google
    GOOGLE_PACKAGE_PATH.update(google.__path__)
    google.__path__ = list(GOOGLE_PACKAGE_PATH) 
开发者ID:GoogleCloudPlatform,项目名称:datastore-ndb-python,代码行数:16,代码来源:google_imports.py

示例4: setup_test_env

# 需要导入模块: import google [as 别名]
# 或者: from google import __path__ [as 别名]
def setup_test_env():
  """Sets up the environment for bot tests."""
  init_symlinks(BOT_DIR)
  client = os.path.normpath(os.path.join(BOT_DIR, '..', '..', '..', 'client'))
  client_tests = os.path.join(client, 'tests')
  sys.path.insert(0, client_tests)

  tp = os.path.join(BOT_DIR, 'third_party')
  if sys.platform == 'win32':
    # third_party is a symlink.
    with open(tp, 'rb') as f:
      tp = os.path.join(BOT_DIR, f.read())
  sys.path.insert(0, tp)

  # libusb1 expects to be directly in sys.path.
  sys.path.insert(0, os.path.join(BOT_DIR, 'python_libusb1'))

  # For python-rsa.
  sys.path.insert(0, os.path.join(tp, 'rsa'))
  sys.path.insert(0, os.path.join(tp, 'pyasn1'))

  # Protobuf is now used in the bot itself.
  # See fix_protobuf_package() in appengine/components/components/utils.py
  # but until this code, the version under client is used.
  if 'google' in sys.modules:
    # It may be in lib/python2.7/site-packages/google, take not chance and flush
    # it out.
    del sys.modules['google']
  # This should import client/third_party/google
  import google
  google_pkg = os.path.join(client, 'third_party', 'google')
  if google_pkg not in google.__path__:
    google.__path__.insert(0, google_pkg)
  six_path = os.path.join(client, 'third_party', 'six')
  if six_path not in sys.path:
    sys.path.insert(0, six_path)
  sys.path.insert(
      0,
      os.path.join(client, 'third_party', 'httplib2',
                   'python%d' % sys.version_info.major)) 
开发者ID:luci,项目名称:luci-py,代码行数:42,代码来源:test_env_bot.py

示例5: fail

# 需要导入模块: import google [as 别名]
# 或者: from google import __path__ [as 别名]
def fail(module_name):
    global _failed
    sys.stderr.write('FAIL: import %s: expected import error\n' % (module_name))
    print 'google:', google.__path__
    _failed = True 
开发者ID:TriggerMail,项目名称:rules_pyz,代码行数:7,代码来源:import_site_packages.py


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