[Buildbot-commits] buildbot/contrib svn_watcher.py,1.1,1.2
Brian Warner
warner at users.sourceforge.net
Sun Oct 8 20:54:19 UTC 2006
Update of /cvsroot/buildbot/buildbot/contrib
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6339/contrib
Modified Files:
svn_watcher.py
Log Message:
[project @ security fix to contrib/svn_watcher.py]
Original author: warner at lothar.com
Date: 2006-10-08 20:48:35
Index: svn_watcher.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/contrib/svn_watcher.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- svn_watcher.py 17 Apr 2006 18:11:42 -0000 1.1
+++ svn_watcher.py 8 Oct 2006 20:54:17 -0000 1.2
@@ -16,7 +16,7 @@
# 15.03.06 by John Pye
# 29.03.06 by Niklaus Giger, added support to run under windows, added invocation option
-import commands
+import subprocess
import xml.dom.minidom
import sys
import time
@@ -24,8 +24,13 @@
if sys.platform == 'win32':
import win32pipe
+def getoutput(cmd):
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ return p.stdout.read()
+
def checkChanges(repo, master, verbose=False, oldRevision=-1):
- cmd ="svn log --non-interactive --xml --verbose --limit=1 "+repo
+ cmd = ["svn", "log", "--non-interactive", "--xml", "--verbose",
+ "--limit=1", repo]
if verbose == True:
print "Getting last revision of repository: " + repo
@@ -34,11 +39,11 @@
xml1 = ''.join(f.readlines())
f.close()
else:
- xml1 = commands.getoutput(cmd)
-
+ xml1 = getoutput(cmd)
+
if verbose == True:
print "XML\n-----------\n"+xml1+"\n\n"
-
+
doc = xml.dom.minidom.parseString(xml1)
el = doc.getElementsByTagName("logentry")[0]
revision = el.getAttribute("revision")
@@ -57,20 +62,23 @@
print paths
if revision != oldRevision:
- cmd = "buildbot sendchange --master="+master+" --revision=\""+revision+"\" --username=\""+author+"\"--comments=\""+comments+"\" "+" ".join(paths)
-
+ cmd = ["buildbot", "sendchange", "--master=%s"%master,
+ "--revision=%s"%revision, "--username=%s"%author,
+ "--comments=%s"%comments]
+ cmd += paths
+
if verbose == True:
print cmd
-
+
if sys.platform == 'win32':
f = win32pipe.popen(cmd)
print time.strftime("%H.%M.%S ") + "Revision "+revision+ ": "+ ''.join(f.readlines())
f.close()
else:
- xml1 = commands.getoutput(cmd)
+ xml1 = getoutput(cmd)
else:
print time.strftime("%H.%M.%S ") + "nothing has changed since revision "+revision
-
+
return revision
if __name__ == '__main__':
More information about the Commits
mailing list