Hi devs,
 I have just been looking at running the benchmarks and have got to the stage 
where I can 
run it on windows.

This attached patch fixes three issues with the script:
 1) use of file:// when I'm sure that file:/// is correct from previous 
discussions on this list
 2) make sure no \ end up is repos url file://
 3) at error handler to rmtree to handle the windows read-only files.

I have removed the "which svn" command, not sure how to do this so it is only 
removed on 
windows as I'm not really a python person.
 I hope this is useful.
 I haven't provided a log message as I don't really think it can be applied 
without a bit of 
editing.

Cheers
Alan Wood
Index: tools/dev/benchmarks/suite1/benchmark.py
===================================================================
--- tools/dev/benchmarks/suite1/benchmark.py	(revision 1094482)
+++ tools/dev/benchmarks/suite1/benchmark.py	(working copy)
@@ -362,7 +362,25 @@
     if os.path.isdir(path):
       propadd_tree(path, fraction)
 
+def rmtreeonerror(func, path, exc_info):
+    """
+    Error handler for ``shutil.rmtree``.
 
+    If the error is due to an access error (read only file)
+    it attempts to add write permission and then retries.
+
+    If the error is for another reason it re-raises the error.
+
+    Usage : ``shutil.rmtree(path, onerror=onerror)``
+    """
+    import stat
+    if not os.access(path, os.W_OK):
+        # Is the error an access error ?
+        os.chmod(path, stat.S_IWUSR)
+        func(path)
+    else:
+        raise
+
 def run(levels, spread, N):
   # ensure identical modifications for every run of this script
   random.seed(0)
@@ -372,15 +390,16 @@
     base = tempfile.mkdtemp()
     try:
       repos = j(base, 'repos')
+      repos = repos.replace('\\','/')
       wc = j(base, 'wc')
       wc2 = j(base, 'wc2')
 
-      file_url = 'file://%s' % repos
+      file_url = 'file:///%s' % repos
 
-      so, se = run_cmd(['which', 'svn'])
-      if not so:
-        print "Can't find svn."
-        exit(1)
+#      so, se = run_cmd(['which', 'svn'])
+#      if not so:
+#        print "Can't find svn."
+#        exit(1)
 
       print '\nRunning svn benchmark in', base
       print 'dir levels: %s; new files and dirs per leaf: %s; run %d of %d' %(
@@ -480,7 +499,7 @@
 
         print timings.summary()
     finally:
-      shutil.rmtree(base)
+      shutil.rmtree(base,onerror=rmtreeonerror)
 
 
 def read_from_file(file_path):

Reply via email to