[Buildbot-commits] buildbot/buildbot/test test_vc.py,1.45,1.46

Brian Warner warner at users.sourceforge.net
Tue Apr 11 06:09:04 UTC 2006


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15752/buildbot/test

Modified Files:
	test_vc.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-488
Creator:  Brian Warner <warner at lothar.com>

fix a twisted1.3 compatibility problem with t.p.procutils.which()

	* buildbot/test/test_vc.py (which): define our own which() in case
	we can't import twisted.python.procutils, because procutils doesn't
	exist in Twisted-1.3


Index: test_vc.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_vc.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- test_vc.py	5 Apr 2006 18:25:36 -0000	1.45
+++ test_vc.py	11 Apr 2006 06:09:01 -0000	1.46
@@ -7,7 +7,35 @@
 
 from twisted.trial import unittest
 from twisted.internet import defer, reactor, utils
-from twisted.python.procutils import which
+try:
+    from twisted.python.procutils import which
+except ImportError:
+    # copied from Twisted circa 2.2.0
+    def which(name, flags=os.X_OK):
+        """Search PATH for executable files with the given name.
+
+        @type name: C{str}
+        @param name: The name for which to search.
+
+        @type flags: C{int}
+        @param flags: Arguments to L{os.access}.
+
+        @rtype: C{list}
+        @param: A list of the full paths to files found, in the
+        order in which they were found.
+        """
+        result = []
+        exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
+        for p in os.environ['PATH'].split(os.pathsep):
+            p = os.path.join(p, name)
+            if os.access(p, flags):
+                result.append(p)
+            for e in exts:
+                pext = p + e
+                if os.access(pext, flags):
+                    result.append(pext)
+        return result
+
 #defer.Deferred.debug = True
 
 from twisted.python import log





More information about the Commits mailing list