Python os.P_NOWAIT() Examples

The following are code examples for showing how to use os.P_NOWAIT(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: ibus-typing-booster   Author: mike-fabian   File: hunspell_table.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 2
Project: uzdevsbot   Author: Uzbek-Developers   File: reloader.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 3
Project: scm-workbench   Author: barry-scott   File: wb_shell_unix_commands.py    (license) View Source Project 5 votes vote down vote up
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 ) 
Example 4
Project: scm-workbench   Author: barry-scott   File: wb_shell_macosx_commands.py    (license) View Source Project 5 votes vote down vote up
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 ) 
Example 5
Project: beremiz   Author: nucleron   File: wxglade_hmi.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 6
Project: pelisalacarta-ce   Author: pelisalacarta-ce   File: downloadtools.py    (license) View Source Project 4 votes vote down vote up
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 
Example 7
Project: addon   Author: alfa-addon   File: downloadtools.py    (license) View Source Project 4 votes vote down vote up
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