[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: Niels de Vos <niels.devos_at_wincor-nixdorf.com>
Date: Mon, 28 Jul 2008 10:39:26 +0200

Daniel Shahaf wrote:
> Ping; this last iteration of the patch has received little response.
>
> URL: http://thread.gmane.org/gmane.comp.version-control.subversion.devel/101880/focus=101933
>
> (more below)
>
> Niels de Vos wrote on Mon, 30 Jun 2008 at 12:14 +0200:
>> Here's a patch for review with popen.popen* replaced by the
>> subprocess-module. It should work on both UNIX and Windows. Only tested
>> on UNIX for now.
>>
>> Note that this patch also changes the output of the feed to match the
>> format of viewvc more.
>>
>> I could update the patch to only reflect the popen-subprocess change if
>> needed.
>>
>
> Please do so; one patch should contain one logical change, and patches
> that contain multiple unrelated changes are much less likely to be
> applied.

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()
         try:
             revisions = [int(cmd_out[0])]
         except IndexError, msg:

-- 
WINCOR NIXDORF International GmbH 
Sitz der Gesellschaft: Paderborn 
Registergericht Paderborn HRB 3507
Geschäftsführer: Eckard Heidloff (Vorsitzender), Stefan Auerbach, Dr. Jürgen Wunram
Vorsitzender des Aufsichtsrats: Karl-Heinz Stiller 
Steuernummer: 339/5884/0020 - Ust-ID Nr.: DE812927716 - WEEE-Reg.-Nr. DE44477193
Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.
This e-mail may contain confidential information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. 
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-07-28 14:32:55 CEST

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.