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

Switch to subprocess module for running external commands

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • trunk
    • unscheduled
    • tools

    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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            subversion-importer Subversion Importer

            Dates

              Created:
              Updated:

              Slack

                Issue deployment