[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] hooks-scripts: fix svn2feed.py on Windows

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Tue, 12 Aug 2008 13:04:57 +0300 (Jerusalem Daylight Time)

(Patch manager hat on. I was about to file this, but then...)

Niels de Vos wrote on Mon, 28 Jul 2008 at 10:39 +0200:
> Okay, here it is. This patch replaces the non-Windows popen2 usage with
> the platform independent subprocess module. As discussed, this requires
> at least Pyhon-2.4 as earlier versions do not contain the subprocess
> module.
>
> Thanks,
> Niels
>
> Index: svn2feed.py
> ===================================================================
> --- svn2feed.py (revision 32316)
> +++ svn2feed.py (working copy)
> @@ -78,7 +78,7 @@
>
> import getopt
> import os
> -import popen2
> +import subprocess
> import cPickle as pickle
> import datetime
> import time
> @@ -127,18 +127,14 @@
> revision = str(revision)
>
> cmd = [self.svnlook_cmd, 'info', '-r', revision, self.repos_path]
> - child_out, child_in, child_err = popen2.popen3(cmd)
> - info_lines = child_out.readlines()
> - child_out.close()
> - child_in.close()
> - child_err.close()
> + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
> + proc.wait()
> + info_lines = proc.stdout.readlines()
>
> cmd = [self.svnlook_cmd, 'changed', '-r', revision, self.repos_path]
> - child_out, child_in, child_err = popen2.popen3(cmd)
> - changed_data = child_out.read()
> - child_out.close()
> - child_in.close()
> - child_err.close()
> + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
> + proc.wait()
> + changed_data = proc.stdout.readlines()
>
> desc = ("\nRevision: %s\nLog: %sModified: \n%s"
> % (revision, info_lines[3], changed_data))
> @@ -411,13 +407,10 @@
> svnlook_cmd = 'svnlook'
> if svn_path is not None:
> svnlook_cmd = os.path.join(svn_path, 'svnlook')
> - child_out, child_in, child_err = popen2.popen3([svnlook_cmd,
> - 'youngest',
> - repos_path])
> - cmd_out = child_out.readlines()
> - child_out.close()
> - child_in.close()
> - child_err.close()
> + cmd = [svnlook_cmd, 'youngest', repos_path]
> + proc = subprocess.Popen(cmd)
> + proc.wait()
> + cmd_out = proc.stdout.readlines()

I got an error with the patched version:

    tools\hook-scripts> python -V
    Python 2.5.1

    tools\hook-scripts> python svn2feed.py -F atom -u http://bar -U http://bar C:\tmp\svn\repos1
    1
    Traceback (most recent call last):
      File "svn2feed.py", line 452, in <module>
        main()
      File "svn2feed.py", line 413, in main
        cmd_out = proc.stdout.readlines()
    AttributeError: 'NoneType' object has no attribute 'readlines'

> try:
> revisions = [int(cmd_out[0])]
> except IndexError, msg:
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-08-12 12:05:35 CEST

This is an archived mail posted to the Subversion Dev mailing list.