[Python-checkins] CVS: distutils/distutils spawn.py,1.9,1.10

Greg Ward python-dev@python.org
Mon, 25 Sep 2000 19:00:54 -0700


Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv23376

Modified Files:
	spawn.py 
Log Message:
Reformat docstrings.
Standardize whitespace in function calls.


Index: spawn.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/spawn.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** spawn.py	2000/08/02 01:08:02	1.9
--- spawn.py	2000/09/26 02:00:51	1.10
***************
*** 4,8 ****
  specific functions for launching another program in a sub-process.
  Also provides the 'find_executable()' to search the path for a given
! executable name. """
  
  # created 1999/07/24, Greg Ward
--- 4,9 ----
  specific functions for launching another program in a sub-process.
  Also provides the 'find_executable()' to search the path for a given
! executable name.
! """
  
  # created 1999/07/24, Greg Ward
***************
*** 20,41 ****
  
      """Run another program, specified as a command list 'cmd', in a new
!        process.  'cmd' is just the argument list for the new process, ie.
!        cmd[0] is the program to run and cmd[1:] are the rest of its
!        arguments.  There is no way to run a program with a name different
!        from that of its executable.
! 
!        If 'search_path' is true (the default), the system's executable
!        search path will be used to find the program; otherwise, cmd[0] must
!        be the exact path to the executable.  If 'verbose' is true, a
!        one-line summary of the command will be printed before it is run.
!        If 'dry_run' is true, the command will not actually be run.
! 
!        Raise DistutilsExecError if running the program fails in any way;
!        just return on success."""
! 
      if os.name == 'posix':
!         _spawn_posix (cmd, search_path, verbose, dry_run)
      elif os.name == 'nt':
!         _spawn_nt (cmd, search_path, verbose, dry_run)
      else:
          raise DistutilsPlatformError, \
--- 21,42 ----
  
      """Run another program, specified as a command list 'cmd', in a new
!     process.  'cmd' is just the argument list for the new process, ie.
!     cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
!     There is no way to run a program with a name different from that of its
!     executable.
! 
!     If 'search_path' is true (the default), the system's executable search
!     path will be used to find the program; otherwise, cmd[0] must be the
!     exact path to the executable.  If 'verbose' is true, a one-line summary
!     of the command will be printed before it is run.  If 'dry_run' is true,
!     the command will not actually be run.
! 
!     Raise DistutilsExecError if running the program fails in any way; just
!     return on success.
!     """
      if os.name == 'posix':
!         _spawn_posix(cmd, search_path, verbose, dry_run)
      elif os.name == 'nt':
!         _spawn_nt(cmd, search_path, verbose, dry_run)
      else:
          raise DistutilsPlatformError, \
***************
*** 46,51 ****
  
  def _nt_quote_args (args):
!     """Obscure quoting command line arguments on NT.
!        Simply quote every argument which contains blanks."""
  
      # XXX this doesn't seem very robust to me -- but if the Windows guys
--- 47,54 ----
  
  def _nt_quote_args (args):
!     """Quote command-line arguments for DOS/Windows conventions: just
!     wraps every argument which contains blanks in double quotes, and
!     returns a new argument list.
!     """
  
      # XXX this doesn't seem very robust to me -- but if the Windows guys
***************
*** 55,60 ****
      # quoting?)
  
!     for i in range (len (args)):
!         if string.find (args[i], ' ') != -1:
              args[i] = '"%s"' % args[i]
      return args
--- 58,63 ----
      # quoting?)
  
!     for i in range(len(args)):
!         if string.find(args[i], ' ') != -1:
              args[i] = '"%s"' % args[i]
      return args
***************
*** 66,79 ****
  
      executable = cmd[0]
!     cmd = _nt_quote_args (cmd)
      if search_path:
          # either we find one or it stays the same
          executable = find_executable(executable) or executable 
      if verbose:
!         print string.join ([executable] + cmd[1:], ' ')
      if not dry_run:
          # spawn for NT requires a full path to the .exe
          try:
!             rc = os.spawnv (os.P_WAIT, executable, cmd)
          except OSError, exc:
              # this seems to happen when the command isn't found
--- 69,82 ----
  
      executable = cmd[0]
!     cmd = _nt_quote_args(cmd)
      if search_path:
          # either we find one or it stays the same
          executable = find_executable(executable) or executable 
      if verbose:
!         print string.join([executable] + cmd[1:], ' ')
      if not dry_run:
          # spawn for NT requires a full path to the .exe
          try:
!             rc = os.spawnv(os.P_WAIT, executable, cmd)
          except OSError, exc:
              # this seems to happen when the command isn't found
***************
*** 92,101 ****
  
      if verbose:
!         print string.join (cmd, ' ')
      if dry_run:
          return
      exec_fn = search_path and os.execvp or os.execv
  
!     pid = os.fork ()
  
      if pid == 0:                        # in the child
--- 95,104 ----
  
      if verbose:
!         print string.join(cmd, ' ')
      if dry_run:
          return
      exec_fn = search_path and os.execvp or os.execv
  
!     pid = os.fork()
  
      if pid == 0:                        # in the child
***************
*** 103,114 ****
              #print "cmd[0] =", cmd[0]
              #print "cmd =", cmd
!             exec_fn (cmd[0], cmd)
          except OSError, e:
!             sys.stderr.write ("unable to execute %s: %s\n" %
!                               (cmd[0], e.strerror))
!             os._exit (1)
              
!         sys.stderr.write ("unable to execute %s for unknown reasons" % cmd[0])
!         os._exit (1)
  
      
--- 106,117 ----
              #print "cmd[0] =", cmd[0]
              #print "cmd =", cmd
!             exec_fn(cmd[0], cmd)
          except OSError, e:
!             sys.stderr.write("unable to execute %s: %s\n" %
!                              (cmd[0], e.strerror))
!             os._exit(1)
              
!         sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0])
!         os._exit(1)
  
      
***************
*** 117,128 ****
          # (ie. keep waiting if it's merely stopped)
          while 1:
!             (pid, status) = os.waitpid (pid, 0)
!             if os.WIFSIGNALED (status):
                  raise DistutilsExecError, \
                        "command '%s' terminated by signal %d" % \
!                       (cmd[0], os.WTERMSIG (status))
  
!             elif os.WIFEXITED (status):
!                 exit_status = os.WEXITSTATUS (status)
                  if exit_status == 0:
                      return              # hey, it succeeded!
--- 120,131 ----
          # (ie. keep waiting if it's merely stopped)
          while 1:
!             (pid, status) = os.waitpid(pid, 0)
!             if os.WIFSIGNALED(status):
                  raise DistutilsExecError, \
                        "command '%s' terminated by signal %d" % \
!                       (cmd[0], os.WTERMSIG(status))
  
!             elif os.WIFEXITED(status):
!                 exit_status = os.WEXITSTATUS(status)
                  if exit_status == 0:
                      return              # hey, it succeeded!
***************
*** 132,136 ****
                            (cmd[0], exit_status)
          
!             elif os.WIFSTOPPED (status):
                  continue
  
--- 135,139 ----
                            (cmd[0], exit_status)
          
!             elif os.WIFSTOPPED(status):
                  continue