Python os 模块,P_NOWAIT 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用os.P_NOWAIT

项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def _start_setup(self):
        '''Start the setup tool if it is not running yet'''
        if self._setup_pid != 0:
            pid, dummy_state = os.waitpid(self._setup_pid, os.P_NOWAIT)
            if pid != self._setup_pid:
                # If the last setup tool started from here is still
                # running the pid returned by the above os.waitpid()
                # is 0. In that case just return, don’t start a
                # second setup tool.
                return
            self._setup_pid = 0
        setup_cmd = os.path.join(
            os.getenv('IBUS_HUNSPELL_LIB_LOCATION'),
            'ibus-setup-typing-booster')
        config_file = self._name.replace('typing-booster:', '') + '.conf'
        self._setup_pid = os.spawnl(
            os.P_NOWAIT,
            setup_cmd,
            'ibus-setup-typing-booster',
            '--config-file %s' %config_file)
项目:uzdevsbot    作者:Uzbek-Developers    | 项目源码 | 文件源码
def reload():
    """ Reload process """
    try:
        # Reload and replace current process
        os.execv(sys.executable, [sys.executable] + sys.argv)

    except OSError:
        # Ugh, that failed
        # Try spawning a new process and exitj
        os.spawnv(
            os.P_NOWAIT,
            sys.executable,
            [sys.executable] + sys.argv,
        )
        os._exit(os.EX_OK)
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __run_commandQQQ( app, cmd, args ):
    app.log.info( '%s %s' % (cmd, ' '.join( args ) ) )

    env = os.environ.copy()
    cmd = asUtf8( cmd )
    args = [asUtf8( arg ) for arg in args]

    os.spawnvpe( os.P_NOWAIT, cmd, [cmd]+args, env )
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __run_command( app, cmd, args ):
    app.log.info( '%s %s' % (cmd, ' '.join( [str(arg) for arg in args] ) ) )

    env = os.environ.copy()
    cmd = asUtf8( cmd )
    args = [asUtf8( str(arg) ) for arg in args]

    os.spawnvpe( os.P_NOWAIT, cmd, [cmd]+args, env )
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def launch_wxglade(self, options, wait=False):
        path = self.GetWxGladePath()
        glade = os.path.join(path, 'wxglade.py')
        if wx.Platform == '__WXMSW__':
            glade = "\"%s\"" % glade
        mode = {False: os.P_NOWAIT, True: os.P_WAIT}[wait]
        os.spawnv(mode, sys.executable, ["\"%s\"" % sys.executable] + [glade] + options)
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def downloadfileRTMP(url,nombrefichero,silent):
  ''' No usa librtmp ya que no siempre está disponible.
      Lanza un subproceso con rtmpdump. En Windows es necesario instalarlo.
      No usa threads así que no muestra ninguna barra de progreso ni tampoco
      se marca el final real de la descarga en el log info.
  '''
  Programfiles = os.getenv('Programfiles')
  if Programfiles:  # Windows
    rtmpdump_cmd = Programfiles + "/rtmpdump/rtmpdump.exe"
    nombrefichero = '"'+nombrefichero+'"'  # Windows necesita las comillas en el nombre
  else:
    rtmpdump_cmd = "/usr/bin/rtmpdump"

  if not os.path.isfile(rtmpdump_cmd) and not silent:
    from platformcode import platformtools
    advertencia = platformtools.dialog_ok( "Falta " + rtmpdump_cmd, "Comprueba que rtmpdump está instalado")
    return True

  valid_rtmpdump_options = ["help", "url", "rtmp", "host", "port", "socks", "protocol", "playpath", "playlist", "swfUrl", "tcUrl", "pageUrl", "app", "swfhash", "swfsize", "swfVfy", "swfAge", "auth", "conn", "flashVer", "live", "subscribe", "realtime", "flv", "resume", "timeout", "start", "stop", "token", "jtv", "hashes", "buffer", "skip", "quiet", "verbose", "debug"]   # for rtmpdump 2.4

  url_args = url.split(' ')
  rtmp_url = url_args[0]
  rtmp_args = url_args[1:]

  rtmpdump_args = ["--rtmp", rtmp_url]
  for arg in rtmp_args:
    n = arg.find('=')
    if n < 0: 
      if arg not in valid_rtmpdump_options:
        continue
      rtmpdump_args += ["--"+arg]
    else:
      if arg[:n] not in valid_rtmpdump_options:
        continue
      rtmpdump_args += ["--"+arg[:n], arg[n+1:]]

  try:
    rtmpdump_args = [rtmpdump_cmd] + rtmpdump_args + ["-o", nombrefichero]
    from os import spawnv, P_NOWAIT
    logger.info("Iniciando descarga del fichero: %s" % " ".join(rtmpdump_args))
    rtmpdump_exit = spawnv(P_NOWAIT, rtmpdump_cmd, rtmpdump_args)
    if not silent:
      from platformcode import platformtools
      advertencia = platformtools.dialog_ok( "La opción de descarga RTMP es experimental", "y el vídeo se descargará en segundo plano.", "No se mostrará ninguna barra de progreso.")
  except:
      return True

  return
项目:addon    作者:alfa-addon    | 项目源码 | 文件源码
def downloadfileRTMP(url, nombrefichero, silent):
    ''' No usa librtmp ya que no siempre está disponible.
        Lanza un subproceso con rtmpdump. En Windows es necesario instalarlo.
        No usa threads así que no muestra ninguna barra de progreso ni tampoco
        se marca el final real de la descarga en el log info.
    '''
    Programfiles = os.getenv('Programfiles')
    if Programfiles:  # Windows
        rtmpdump_cmd = Programfiles + "/rtmpdump/rtmpdump.exe"
        nombrefichero = '"' + nombrefichero + '"'  # Windows necesita las comillas en el nombre
    else:
        rtmpdump_cmd = "/usr/bin/rtmpdump"

    if not os.path.isfile(rtmpdump_cmd) and not silent:
        from platformcode import platformtools
        advertencia = platformtools.dialog_ok("Falta " + rtmpdump_cmd, "Comprueba que rtmpdump está instalado")
        return True

    valid_rtmpdump_options = ["help", "url", "rtmp", "host", "port", "socks", "protocol", "playpath", "playlist",
                              "swfUrl", "tcUrl", "pageUrl", "app", "swfhash", "swfsize", "swfVfy", "swfAge", "auth",
                              "conn", "flashVer", "live", "subscribe", "realtime", "flv", "resume", "timeout", "start",
                              "stop", "token", "jtv", "hashes", "buffer", "skip", "quiet", "verbose",
                              "debug"]  # for rtmpdump 2.4

    url_args = url.split(' ')
    rtmp_url = url_args[0]
    rtmp_args = url_args[1:]

    rtmpdump_args = ["--rtmp", rtmp_url]
    for arg in rtmp_args:
        n = arg.find('=')
        if n < 0:
            if arg not in valid_rtmpdump_options:
                continue
            rtmpdump_args += ["--" + arg]
        else:
            if arg[:n] not in valid_rtmpdump_options:
                continue
            rtmpdump_args += ["--" + arg[:n], arg[n + 1:]]

    try:
        rtmpdump_args = [rtmpdump_cmd] + rtmpdump_args + ["-o", nombrefichero]
        from os import spawnv, P_NOWAIT
        logger.info("Iniciando descarga del fichero: %s" % " ".join(rtmpdump_args))
        rtmpdump_exit = spawnv(P_NOWAIT, rtmpdump_cmd, rtmpdump_args)
        if not silent:
            from platformcode import platformtools
            advertencia = platformtools.dialog_ok("La opción de descarga RTMP es experimental",
                                                  "y el vídeo se descargará en segundo plano.",
                                                  "No se mostrará ninguna barra de progreso.")
    except:
        return True

    return