本文整理汇总了Python中os.spawnl方法的典型用法代码示例。如果您正苦于以下问题:Python os.spawnl方法的具体用法?Python os.spawnl怎么用?Python os.spawnl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.spawnl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadFile
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def loadFile(self, edited=False):
extra = []
qtLib = str(self.ui.qtLibCombo.currentText())
gfxSys = str(self.ui.graphicsSystemCombo.currentText())
if qtLib != 'default':
extra.append(qtLib.lower())
elif gfxSys != 'default':
extra.append(gfxSys)
if edited:
path = os.path.abspath(os.path.dirname(__file__))
proc = subprocess.Popen([sys.executable, '-'] + extra, stdin=subprocess.PIPE, cwd=path)
code = str(self.ui.codeView.toPlainText()).encode('UTF-8')
proc.stdin.write(code)
proc.stdin.close()
else:
fn = self.currentFile()
if fn is None:
return
if sys.platform.startswith('win'):
os.spawnl(os.P_NOWAIT, sys.executable, '"'+sys.executable+'"', '"' + fn + '"', *extra)
else:
os.spawnl(os.P_NOWAIT, sys.executable, sys.executable, fn, *extra)
示例2: OnHelpCANFestivalMenu
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def OnHelpCANFestivalMenu(self, event):
#self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
if wx.Platform == '__WXMSW__':
readerpath = get_acroversion()
readerexepath = os.path.join(readerpath,"AcroRd32.exe")
if(os.path.isfile(readerexepath)):
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
else:
message = wx.MessageDialog(self, _("Check if Acrobat Reader is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
try:
os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
except:
message = wx.MessageDialog(self, _("Check if xpdf is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
示例3: viewAction
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def viewAction(self, widget, data=None):
# Get the selection in the gtk.TreeView
selection = self._treeView.get_selection()
# Get the selection iter
model, selection_iter = selection.get_selected()
if selection_iter:
packName = self._table.get_value(selection_iter,
self.PACKAGE_I)
vigName = self._table.get_value(selection_iter,
self.ITEM_I)
pdffile = robjects.r.vignette(vigName, package = packName)
pdffile = pdffile.subset("file")[0][0]
pdfviewer = robjects.baseenv["options"]("pdfviewer")[0][0]
pid = os.spawnl(os.P_NOWAIT, pdfviewer, pdffile)
示例4: _python_cmd
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def _python_cmd(*args):
args = (sys.executable,) + args
# quoting arguments if windows
if sys.platform == 'win32':
def quote(arg):
if ' ' in arg:
return '"%s"' % arg
return arg
args = [quote(arg) for arg in args]
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
示例5: test_noinherit
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def test_noinherit(self):
# _mkstemp_inner file handles are not inherited by child processes
if support.verbose:
v="v"
else:
v="q"
file = self.do_create()
fd = "%d" % file.fd
try:
me = __file__
except NameError:
me = sys.argv[0]
# We have to exec something, so that FD_CLOEXEC will take
# effect. The core of this test is therefore in
# tf_inherit_check.py, which see.
tester = os.path.join(os.path.dirname(os.path.abspath(me)),
"tf_inherit_check.py")
# On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
# but an arg with embedded spaces should be decorated with double
# quotes on each end
if sys.platform in ('win32',):
decorated = '"%s"' % sys.executable
tester = '"%s"' % tester
else:
decorated = sys.executable
retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
self.assertFalse(retval < 0,
"child process caught fatal signal %d" % -retval)
self.assertFalse(retval > 0, "child process reports failure %d"%retval)
示例6: test_noinherit
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def test_noinherit(self):
# _mkstemp_inner file handles are not inherited by child processes
if not has_spawnl:
return # ugh, can't use SkipTest.
if support.verbose:
v="v"
else:
v="q"
file = self.do_create()
fd = "%d" % file.fd
try:
me = __file__
except NameError:
me = sys.argv[0]
# We have to exec something, so that FD_CLOEXEC will take
# effect. The core of this test is therefore in
# tf_inherit_check.py, which see.
tester = os.path.join(os.path.dirname(os.path.abspath(me)),
"tf_inherit_check.py")
# On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
# but an arg with embedded spaces should be decorated with double
# quotes on each end
if sys.platform in ('win32',):
decorated = '"%s"' % sys.executable
tester = '"%s"' % tester
else:
decorated = sys.executable
retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
self.assertFalse(retval < 0,
"child process caught fatal signal %d" % -retval)
self.assertFalse(retval > 0, "child process reports failure %d"%retval)
示例7: create_spawnl
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def create_spawnl(original_name):
def new_spawnl(mode, path, *args):
"""
os.spawnl(mode, path, arg0, arg1, ...)
os.spawnlp(mode, file, arg0, arg1, ...)
"""
if _get_apply_arg_patching():
args = patch_args(args)
send_process_created_message()
return getattr(os, original_name)(mode, path, *args)
return new_spawnl
示例8: patch_new_process_functions_with_warning
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def patch_new_process_functions_with_warning():
monkey_patch_os('execl', create_warn_multiproc)
monkey_patch_os('execle', create_warn_multiproc)
monkey_patch_os('execlp', create_warn_multiproc)
monkey_patch_os('execlpe', create_warn_multiproc)
monkey_patch_os('execv', create_warn_multiproc)
monkey_patch_os('execve', create_warn_multiproc)
monkey_patch_os('execvp', create_warn_multiproc)
monkey_patch_os('execvpe', create_warn_multiproc)
monkey_patch_os('spawnl', create_warn_multiproc)
monkey_patch_os('spawnle', create_warn_multiproc)
monkey_patch_os('spawnlp', create_warn_multiproc)
monkey_patch_os('spawnlpe', create_warn_multiproc)
monkey_patch_os('spawnv', create_warn_multiproc)
monkey_patch_os('spawnve', create_warn_multiproc)
monkey_patch_os('spawnvp', create_warn_multiproc)
monkey_patch_os('spawnvpe', create_warn_multiproc)
monkey_patch_os('posix_spawn', create_warn_multiproc)
if not IS_JYTHON:
if not IS_WINDOWS:
monkey_patch_os('fork', create_warn_multiproc)
try:
import _posixsubprocess
monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec)
except ImportError:
pass
else:
# Windows
try:
import _subprocess
except ImportError:
import _winapi as _subprocess
monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc)
示例9: test_noinherit
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def test_noinherit(self):
# _mkstemp_inner file handles are not inherited by child processes
if support.verbose:
v="v"
else:
v="q"
file = self.do_create()
self.assertEqual(os.get_inheritable(file.fd), False)
fd = "%d" % file.fd
try:
me = __file__
except NameError:
me = sys.argv[0]
# We have to exec something, so that FD_CLOEXEC will take
# effect. The core of this test is therefore in
# tf_inherit_check.py, which see.
tester = os.path.join(os.path.dirname(os.path.abspath(me)),
"tf_inherit_check.py")
# On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
# but an arg with embedded spaces should be decorated with double
# quotes on each end
if sys.platform == 'win32':
decorated = '"%s"' % sys.executable
tester = '"%s"' % tester
else:
decorated = sys.executable
retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
self.assertFalse(retval < 0,
"child process caught fatal signal %d" % -retval)
self.assertFalse(retval > 0, "child process reports failure %d"%retval)
示例10: test_spawnl
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def test_spawnl(self):
#sanity check
#CPython nt has no spawnl function
pint_cmd = ping_cmd = os.path.join(os.environ['windir'], 'system32', 'ping.exe')
os.spawnl(nt.P_WAIT, ping_cmd , "ping","127.0.0.1","-n","1")
os.spawnl(nt.P_WAIT, ping_cmd , "ping","/?")
os.spawnl(nt.P_WAIT, ping_cmd , "ping")
# negative case
cmd = pint_cmd+"oo"
self.assertRaises(OSError,os.spawnl,nt.P_WAIT,cmd,"ping","/?")
示例11: setup_environment
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def setup_environment():
# If docker config
if custom_actinia_cfg is not False:
global_config.read(custom_actinia_cfg)
return
global redis_pid
# Set the port to the test redis server
global_config.REDIS_SERVER_SERVER = "localhost"
global_config.REDIS_SERVER_PORT = 7000
# home = os.getenv("HOME")
# GRASS
# Setup the test environment
global_config.GRASS_GIS_BASE="/usr/local/grass78/"
global_config.GRASS_GIS_START_SCRIPT="/usr/local/bin/grass78"
# global_config.GRASS_DATABASE= "/usr/local/grass_test_db"
# global_config.GRASS_DATABASE = "%s/actinia/grass_test_db" % home
# Start the redis server for user and logging management
redis_pid = os.spawnl(os.P_NOWAIT, "/usr/bin/redis-server",
"common/redis.conf",
"--port %i" % global_config.REDIS_SERVER_PORT)
time.sleep(1)
示例12: setup_environment
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def setup_environment():
global redis_pid
# Set the port to the test redis server
global_config.REDIS_SERVER_SERVER = "localhost"
global_config.REDIS_SERVER_PORT = 7000
# Set the path to redis WORKER_LOGFILE
# global_config.WORKER_LOGFILE = "/var/log/redis/redis"
# home = os.getenv("HOME")
# GRASS GIS
# Setup the test environment
global_config.GRASS_GIS_BASE="/usr/local/grass78/"
global_config.GRASS_GIS_START_SCRIPT="/usr/local/bin/grass78"
# global_config.GRASS_DATABASE= "/usr/local/grass_test_db"
# global_config.GRASS_DATABASE = "%s/actinia/grass_test_db" % home
global_config.GRASS_TMP_DATABASE = "/tmp"
if server_test is False and custom_actinia_cfg is False:
# Start the redis server for user and logging management
redis_pid = os.spawnl(os.P_NOWAIT, "/usr/bin/redis-server",
"common/redis.conf",
"--port %i" % global_config.REDIS_SERVER_PORT)
time.sleep(1)
if server_test is False and custom_actinia_cfg is not False:
global_config.read(custom_actinia_cfg)
示例13: OnHelpCANFestivalMenu
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def OnHelpCANFestivalMenu(self, event):
#self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
if wx.Platform == '__WXMSW__':
readerpath = get_acroversion()
readerexepath = os.path.join(readerpath,"AcroRd32.exe")
if(os.path.isfile(readerexepath)):
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
else:
os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
示例14: OpenPDFDocIndex
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def OpenPDFDocIndex(index, cwd):
if not os.path.isfile(os.path.join(cwd, "doc","301_v04000201.pdf")):
return _("""No documentation file available.
Please read can festival documentation to know how to obtain one.""")
try:
if index in DS301_PDF_INDEX:
if wx.Platform == '__WXMSW__':
readerpath = get_acroversion()
readerexepath = os.path.join(readerpath,"AcroRd32.exe")
if(os.path.isfile(readerexepath)):
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % DS301_PDF_INDEX[index], '"%s"'%os.path.join(cwd, "doc","301_v04000201.pdf"))
else:
os.system("xpdf -remote DS301 %s %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index]))
else:
if wx.Platform == '__WXMSW__':
readerpath = get_acroversion()
readerexepath = os.path.join(readerpath,"AcroRd32.exe")
if(os.path.isfile(readerexepath)):
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(cwd, "doc","301_v04000201.pdf"))
else:
os.system("xpdf -remote DS301 %s &"%os.path.join(cwd, "doc","301_v04000201.pdf"))
return True
except:
if wx.Platform == '__WXMSW__':
return _("Check if Acrobat Reader is correctly installed on your computer")
else:
return _("Check if xpdf is correctly installed on your computer")
示例15: test_noinherit
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnl [as 别名]
def test_noinherit(self):
# _mkstemp_inner file handles are not inherited by child processes
if not has_spawnl:
return # ugh, can't use TestSkipped.
if test_support.verbose:
v="v"
else:
v="q"
file = self.do_create()
fd = "%d" % file.fd
try:
me = __file__
except NameError:
me = sys.argv[0]
# We have to exec something, so that FD_CLOEXEC will take
# effect. The core of this test is therefore in
# tf_inherit_check.py, which see.
tester = os.path.join(os.path.dirname(os.path.abspath(me)),
"tf_inherit_check.py")
# On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
# but an arg with embedded spaces should be decorated with double
# quotes on each end
if sys.platform in ('win32',):
decorated = '"%s"' % sys.executable
tester = '"%s"' % tester
else:
decorated = sys.executable
retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
self.failIf(retval < 0,
"child process caught fatal signal %d" % -retval)
self.failIf(retval > 0, "child process reports failure %d"%retval)