Here are the examples of the python api sys.flags taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
9 Examples
5
Example 1
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug", "py3k_warning", "division_warning", "division_new",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_site", "ignore_environment", "tabcheck", "verbose",
"unicode", "bytes_warning")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
self.assertTrue(repr(sys.flags))
5
Example 2
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug", "division_warning",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_user_site", "no_site", "ignore_environment", "verbose",
"bytes_warning", "quiet")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
self.assertTrue(repr(sys.flags))
self.assertEqual(len(sys.flags), len(attrs))
5
Example 3
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_user_site", "no_site", "ignore_environment", "verbose",
"bytes_warning", "quiet", "hash_randomization")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
self.assertTrue(repr(sys.flags))
self.assertEqual(len(sys.flags), len(attrs))
5
Example 4
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug", "py3k_warning", "division_warning", "division_new",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_site", "ignore_environment", "tabcheck", "verbose",
"unicode", "bytes_warning", "hash_randomization")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
self.assertTrue(repr(sys.flags))
5
Example 5
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_user_site", "no_site", "ignore_environment", "verbose",
"bytes_warning", "quiet", "hash_randomization", "isolated")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
self.assertTrue(repr(sys.flags))
self.assertEqual(len(sys.flags), len(attrs))
3
Example 6
Project: pymo Source File: test_support.py
def args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
settings in sys.flags."""
flag_opt_map = {
'bytes_warning': 'b',
'dont_write_bytecode': 'B',
'ignore_environment': 'E',
'no_user_site': 's',
'no_site': 'S',
'optimize': 'O',
'py3k_warning': '3',
'verbose': 'v',
}
args = []
for flag, opt in flag_opt_map.items():
v = getattr(sys.flags, flag)
if v > 0:
args.append('-' + opt * v)
return args
0
Example 7
def check_enableusersite():
"""Check if user site directory is safe for inclusion
The function tests for the command line flag (including environment var),
process uid/gid equal to effective uid/gid.
None: Disabled for security reasons
False: Disabled by user (command line option)
True: Safe and enabled
"""
if hasattr(sys, 'flags') and getattr(sys.flags, 'no_user_site', False):
return False
if hasattr(os, "getuid") and hasattr(os, "geteuid"):
# check process uid == effective uid
if os.geteuid() != os.getuid():
return None
if hasattr(os, "getgid") and hasattr(os, "getegid"):
# check process gid == effective gid
if os.getegid() != os.getgid():
return None
return True
0
Example 8
Project: mpi4py Source File: _worker.py
def _sys_flags():
flag_opt_map = {
# Python 3
'inspect': 'i',
'interactive': 'i',
'debug': 'd',
'optimize': 'O',
'no_user_site': 's',
'no_site': 'S',
'isolated': 'I',
'ignore_environment': 'E',
'dont_write_bytecode': 'B',
'hash_randomization': 'R',
'verbose': 'v',
'quiet': 'q',
'bytes_warning': 'b',
# Python 2
'division_warning': 'Qwarn',
'division_new': 'Qnew',
'py3k_warning': '3',
'tabcheck': 't',
'unicode': 'U',
}
args = []
for flag, opt in flag_opt_map.items():
val = getattr(sys.flags, flag, 0)
val = val if opt[0] != 'i' else 0
val = val if opt[0] != 'Q' else min(val, 1)
if val > 0:
args.append('-' + opt * val)
for opt in sys.warnoptions: # pragma: no cover
args.append('-W' + opt)
sys_xoptions = getattr(sys, '_xoptions', {})
for opt, val in sys_xoptions.items(): # pragma: no cover
args.append('-X' + opt if val is True else
'-X' + opt + '=' + val)
return args
0
Example 9
Project: iot-utilities Source File: test_sys.py
def test_sys_flags_no_instantiation(self):
self.assert_raise_on_new_sys_type(sys.flags)