Uploaded image for project: 'Subversion'
  1. Subversion
  2. SVN-3412

Switch to subprocess module for running external commands

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: trunk
    • Fix Version/s: unscheduled
    • Component/s: tools
    • Labels:

      Description

      Switch to subprocess module for running external commands, thereby
         improving Windows compatibility. 
      
      Patch By:sergey@optimaltec.com
      
      
      Index: svnperms.py
      ===================================================================
      --- svnperms.py	(revision 37182)
      +++ svnperms.py	(working copy)
      @@ -6,15 +6,10 @@
      # $LastChangedBy$
      # $LastChangedRevision$
      
      +from subprocess import PIPE, Popen
      import sys, os
      import getopt
      try:
      -  # Python >=3.0
      -  from subprocess import getstatusoutput as subprocess_getstatusoutput
      -except ImportError:
      -  # Python <3.0
      -  from commands import getstatusoutput as subprocess_getstatusoutput
      -try:
          my_getopt = getopt.gnu_getopt
      except AttributeError:
          my_getopt = getopt.getopt
      @@ -146,15 +141,18 @@
              self.rev = rev
      
          def _execcmd(self, *cmd, **kwargs):
      -        cmdstr = " ".join(cmd)
      -        status, output = subprocess_getstatusoutput(cmdstr)
      -        if status != 0:
      -            sys.stderr.write(cmdstr)
      -            sys.stderr.write("\n")
      -            sys.stderr.write(output)
      -            raise Error("command failed: %s\n%s" % (cmdstr, output))
      -        return status, output
      +        process = Popen(cmd, stdout = PIPE, stderr = PIPE)
      +        status = process.wait()
      +        if 0 == status:
      +            return status, process.stdout.read()
      
      +        cmdstr = ' '.join(cmd)
      +        error_output = process.stderr.read()
      +        sys.stderr.write(cmdstr)
      +        sys.stderr.write('\n')
      +        sys.stderr.write(error_output)
      +        raise Error("command failed: %s\n%s" % (cmdstr, error_output))
      +
          def _execsvnlook(self, cmd, *args, **kwargs):
              execcmd_args = ["svnlook", cmd, self.repospath]
              self._add_txnrev(execcmd_args, kwargs)
      

      http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1661097

      Original issue reported by gavinbaumanis

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              subversion-importer Subversion Importer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: