本文整理匯總了Python中subprocess._args_from_interpreter_flags方法的典型用法代碼示例。如果您正苦於以下問題:Python subprocess._args_from_interpreter_flags方法的具體用法?Python subprocess._args_from_interpreter_flags怎麽用?Python subprocess._args_from_interpreter_flags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類subprocess
的用法示例。
在下文中一共展示了subprocess._args_from_interpreter_flags方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_interpreter_argv
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _args_from_interpreter_flags [as 別名]
def _get_interpreter_argv():
"""Retrieve current Python interpreter's arguments.
Returns empty tuple in case of frozen mode, uses built-in arguments
reproduction function otherwise.
Frozen mode is possible for the app has been packaged into a binary
executable using py2exe. In this case the interpreter's arguments are
already built-in into that executable.
:seealso: https://github.com/cherrypy/cherrypy/issues/1526
Ref: https://pythonhosted.org/PyInstaller/runtime-information.html
"""
return ([]
if getattr(sys, 'frozen', False)
else subprocess._args_from_interpreter_flags())
示例2: args_from_interpreter_flags
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _args_from_interpreter_flags [as 別名]
def args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
settings in sys.flags and sys.warnoptions."""
return subprocess._args_from_interpreter_flags()
#============================================================
# Support for assertions about logging.
#============================================================
示例3: args_from_interpreter_flags
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _args_from_interpreter_flags [as 別名]
def args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
settings in sys.flags."""
import subprocess
return subprocess._args_from_interpreter_flags()
示例4: _args_from_interpreter_flags
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _args_from_interpreter_flags [as 別名]
def _args_from_interpreter_flags():
"""Tries to reconstruct original interpreter args from sys.flags for Python 2.6
Backported from Python 3.5. Aims to return a list of
command-line arguments reproducing the current
settings in sys.flags and sys.warnoptions.
"""
flag_opt_map = {
'debug': 'd',
# 'inspect': 'i',
# 'interactive': 'i',
'optimize': 'O',
'dont_write_bytecode': 'B',
'no_user_site': 's',
'no_site': 'S',
'ignore_environment': 'E',
'verbose': 'v',
'bytes_warning': 'b',
'quiet': 'q',
'hash_randomization': 'R',
'py3k_warning': '3',
}
args = []
for flag, opt in flag_opt_map.items():
v = getattr(sys.flags, flag)
if v > 0:
if flag == 'hash_randomization':
v = 1 # Handle specification of an exact seed
args.append('-' + opt * v)
for opt in sys.warnoptions:
args.append('-W' + opt)
return args
# html module come in 3.2 version
示例5: _use_sqlite_cli
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _args_from_interpreter_flags [as 別名]
def _use_sqlite_cli(self, env):
"""Pipes the test case into the "sqlite3" executable.
The method _has_sqlite_cli MUST be called before this method is called.
PARAMETERS:
env -- mapping; represents shell environment variables. Primarily, this
allows modifications to PATH to check the current directory first.
RETURNS:
(test, expected, result), where
test -- str; test input that is piped into sqlite3
expected -- str; the expected output, for display purposes
result -- str; the actual output from piping input into sqlite3
"""
test = []
expected = []
for line in self._setup + self._code + self._teardown:
if isinstance(line, interpreter.CodeAnswer):
expected.extend(line.output)
elif line.startswith(self.PS1):
test.append(line[len(self.PS1):])
elif line.startswith(self.PS2):
test.append(line[len(self.PS2):])
test = '\n'.join(test)
result, error = (None, None)
process = None
args = ['sqlite3']
sqlite_shell = get_sqlite_shell()
if sqlite_shell:
if self.timeout is None:
(stdin, stdout, stderr) = (io.StringIO(test), io.StringIO(), io.StringIO())
sqlite_shell.main(*args, stdin=stdin, stdout=stdout, stderr=stderr)
result, error = (stdout.getvalue(), stderr.getvalue())
else:
args[:] = [sys.executable] + subprocess._args_from_interpreter_flags() + ["--", sqlite_shell.__file__] + args[1:]
if result is None:
process = subprocess.Popen(args,
universal_newlines=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env)
if process:
try:
result, error = process.communicate(test, timeout=self.timeout)
except subprocess.TimeoutExpired as e:
process.kill()
print('# Error: evaluation exceeded {} seconds.'.format(self.timeout))
raise interpreter.ConsoleException(exceptions.Timeout(self.timeout))
return test, '\n'.join(expected), (error + '\n' + result).strip()