Python os.__dict__() Examples
The following are 13
code examples of os.__dict__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: crond.py From collection with MIT License | 6 votes |
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 #----------------------------------------------------------------------
Example #2
Source File: sandbox_test.py From browserscope with Apache License 2.0 | 5 votes |
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()
Example #3
Source File: sandbox_test.py From browserscope with Apache License 2.0 | 5 votes |
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()
Example #4
Source File: sandbox_test.py From browserscope with Apache License 2.0 | 5 votes |
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__)
Example #5
Source File: sandbox_test.py From browserscope with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: sandbox_test.py From browserscope with Apache License 2.0 | 5 votes |
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)
Example #7
Source File: sandbox_test.py From python-compat-runtime with Apache License 2.0 | 5 votes |
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()
Example #8
Source File: sandbox_test.py From python-compat-runtime with Apache License 2.0 | 5 votes |
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()
Example #9
Source File: sandbox_test.py From python-compat-runtime with Apache License 2.0 | 5 votes |
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__)
Example #10
Source File: sandbox_test.py From python-compat-runtime with Apache License 2.0 | 5 votes |
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)
Example #11
Source File: sandbox_test.py From python-compat-runtime with Apache License 2.0 | 5 votes |
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)
Example #12
Source File: posix.py From pivy with ISC License | 4 votes |
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:
Example #13
Source File: posix.py From sitoa with Apache License 2.0 | 4 votes |
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: