當前位置: 首頁>>代碼示例>>Python>>正文


Python os.spawnl方法代碼示例

本文整理匯總了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) 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:27,代碼來源:__main__.py

示例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() 
開發者ID:jgeisler0303,項目名稱:CANFestivino,代碼行數:20,代碼來源:objdictedit.py

示例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) 
開發者ID:rpy2,項目名稱:rpy2,代碼行數:18,代碼來源:radmin.py

示例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 
開發者ID:bunbun,項目名稱:nested-dict,代碼行數:12,代碼來源:ez_setup.py

示例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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:37,代碼來源:test_tempfile.py

示例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) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:39,代碼來源:test_tempfile.py

示例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 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:16,代碼來源:pydev_monkey.py

示例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) 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:36,代碼來源:pydev_monkey.py

示例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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:38,代碼來源:test_tempfile.py

示例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","/?") 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:13,代碼來源:test_nt.py

示例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) 
開發者ID:mundialis,項目名稱:actinia_core,代碼行數:29,代碼來源:test_common_base.py

示例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) 
開發者ID:mundialis,項目名稱:actinia_core,代碼行數:29,代碼來源:test_resource_base.py

示例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)) 
開發者ID:jgeisler0303,項目名稱:CANFestivino,代碼行數:11,代碼來源:networkedit.py

示例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") 
開發者ID:jgeisler0303,項目名稱:CANFestivino,代碼行數:29,代碼來源:DS301_index.py

示例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) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:39,代碼來源:test_tempfile.py


注:本文中的os.spawnl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。