本文整理汇总了Python中os.__dict__方法的典型用法代码示例。如果您正苦于以下问题:Python os.__dict__方法的具体用法?Python os.__dict__怎么用?Python os.__dict__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.__dict__方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signal_initialize
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def signal_initialize():
import signal
signal.signal(signal.SIGTERM, sig_exit)
signal.signal(signal.SIGINT, sig_exit)
signal.signal(signal.SIGABRT, sig_exit)
if 'SIGQUIT' in signal.__dict__:
signal.signal(signal.SIGQUIT, sig_exit)
if 'SIGCHLD' in signal.__dict__:
signal.signal(signal.SIGCHLD, sig_chld)
if 'SIGPIPE' in signal.__dict__:
signal.signal(signal.SIGPIPE, signal.SIG_IGN)
return 0
#----------------------------------------------------------------------
# logs
#----------------------------------------------------------------------
示例2: setUp
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def setUp(self):
super(SandboxTest, self).setUp()
self.mox = mox.Mox()
self.old_path = sys.path
self.old_meta_path = sys.meta_path
self.old_library_format_string = sandbox._THIRD_PARTY_LIBRARY_FORMAT_STRING
self.config = runtime_config_pb2.Config()
self.app_root = 'test/app/root'
self.config.application_root = self.app_root
self.config.app_id = 'app'
self.config.version_id = '1'
self.builtins = __builtin__.__dict__.copy()
self.modules = sys.modules.copy()
示例3: tearDown
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def tearDown(self):
sys.modules.clear()
sys.modules.update(self.modules)
__builtin__.__dict__.update(self.builtins)
sys.meta_path = self.old_meta_path
sys.path = self.old_path
sandbox._THIRD_PARTY_LIBRARY_FORMAT_STRING = self.old_library_format_string
self.mox.UnsetStubs()
super(SandboxTest, self).tearDown()
示例4: test_load_without_path_hook
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def test_load_without_path_hook(self):
self.test_policies['urllib'] = sandbox.ModuleOverridePolicy(
None, [], {}, default_pass_through=True)
urllib = self.hook.load_module('urllib')
self.assertIn('urlopen', urllib.__dict__)
self.assertEqual('urllib', urllib.__name__)
示例5: test_os_module_policy
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def test_os_module_policy(self):
hooked_os = imp.new_module('os')
hooked_os.__dict__.update(os.__dict__)
sandbox._MODULE_OVERRIDE_POLICIES['os'].apply_policy(hooked_os.__dict__)
self.assertEqual(stubs.return_minus_one, hooked_os.getpid)
self.assertNotIn('execv', hooked_os.__dict__)
self.assertEqual(stubs.os_error_not_implemented, hooked_os.unlink)
self.assertEqual(os.walk, hooked_os.walk)
示例6: test_module_success
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def test_module_success(self):
hook = sandbox.PathOverrideImportHook(['urllib'])
self.assertEqual(hook, hook.find_module('urllib'))
del sys.modules['urllib']
hooked_urllib = hook.load_module('urllib')
self.assertEqual(hooked_urllib.__file__.replace('.pyc', '.py'),
urllib.__file__.replace('.pyc', '.py'))
self.assertEqual(hooked_urllib.__loader__, hook)
self.assertNotIn('__path__', hooked_urllib.__dict__)
self.assertFalse(hook.extra_accessible_paths)
self.assertFalse(hook.extra_sys_paths)
示例7: test_os_module_policy
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def test_os_module_policy(self):
hooked_os = imp.new_module('os')
hooked_os.__dict__.update(os.__dict__)
sandbox._MODULE_OVERRIDE_POLICIES['os'].apply_policy(hooked_os.__dict__)
self.assertEqual(stubs.return_minus_one, hooked_os.getpid)
self.assertNotIn('execv', hooked_os.__dict__)
self.assertEqual(stubs.os_error_not_implemented, hooked_os.unlink)
self.assertEqual(stubs.os_error_not_implemented, hooked_os.readlink)
self.assertEqual(os.walk, hooked_os.walk)
示例8: test_module_success
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def test_module_success(self):
hook = sandbox.PathOverrideImportHook({'urllib'})
self.assertEqual(hook, hook.find_module('urllib'))
del sys.modules['urllib']
hooked_urllib = hook.load_module('urllib')
self.assertEqual(hooked_urllib.__file__.replace('.pyc', '.py'),
urllib.__file__.replace('.pyc', '.py'))
self.assertEqual(hooked_urllib.__loader__, hook)
self.assertNotIn('__path__', hooked_urllib.__dict__)
self.assertFalse(hook.extra_accessible_paths)
self.assertFalse(hook.extra_sys_paths)
示例9: generate
# 需要导入模块: import os [as 别名]
# 或者: from os import __dict__ [as 别名]
def generate(env):
# If os.spawnvpe() exists, we use it to spawn commands. Otherwise
# if the env utility exists, we use os.system() to spawn commands,
# finally we fall back on os.fork()/os.exec().
#
# os.spawnvpe() is prefered because it is the most efficient. But
# for Python versions without it, os.system() is prefered because it
# is claimed that it works better with threads (i.e. -j) and is more
# efficient than forking Python.
#
# NB: Other people on the scons-users mailing list have claimed that
# os.fork()/os.exec() works better than os.system(). There may just
# not be a default that works best for all users.
if 'spawnvpe' in os.__dict__:
spawn = spawnvpe_spawn
elif env.Detect('env'):
spawn = env_spawn
else:
spawn = fork_spawn
if env.Detect('env'):
pspawn = piped_env_spawn
else:
pspawn = piped_fork_spawn
if 'ENV' not in env:
env['ENV'] = {}
env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
env['OBJPREFIX'] = ''
env['OBJSUFFIX'] = '.o'
env['SHOBJPREFIX'] = '$OBJPREFIX'
env['SHOBJSUFFIX'] = '$OBJSUFFIX'
env['PROGPREFIX'] = ''
env['PROGSUFFIX'] = ''
env['LIBPREFIX'] = 'lib'
env['LIBSUFFIX'] = '.a'
env['SHLIBPREFIX'] = '$LIBPREFIX'
env['SHLIBSUFFIX'] = '.so'
env['LIBPREFIXES'] = [ '$LIBPREFIX' ]
env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
env['PSPAWN'] = pspawn
env['SPAWN'] = spawn
env['SHELL'] = 'sh'
env['ESCAPE'] = escape
env['TEMPFILE'] = TempFileMunge
env['TEMPFILEPREFIX'] = '@'
#Based on LINUX: ARG_MAX=ARG_MAX=131072 - 3000 for environment expansion
#Note: specific platforms might rise or lower this value
env['MAXLINELENGTH'] = 128072
# This platform supports RPATH specifications.
env['__RPATH'] = '$_RPATH'
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4: