Removed dependency on rsync and replaced with python shutil methods.
authorNikos Andronikos <nikos.andronikos@cisra.canon.com.au>
Fri, 08 Feb 2013 14:33:43 +1100
changeset 63 fcfc39607c52
parent 62 c7d24fd2e63b
child 64 ebccd13ad193
Removed dependency on rsync and replaced with python shutil methods.
build.py
--- a/build.py	Fri Sep 14 20:03:34 2012 +1000
+++ b/build.py	Fri Feb 08 14:33:43 2013 +1100
@@ -23,6 +23,7 @@
 
 import os, sys, signal, commands
 from os.path import isfile, abspath, getmtime, exists, join, normpath
+import shutil
 
 def exit(code, *message):
   if len(message):
@@ -73,8 +74,8 @@
 # Add clean-up handler for SIGINT:
 
 def handle_SIGINT(signal, frame):
-  done();
-  sys.exit(1);
+  done()
+  sys.exit(1)
 
 signal.signal(signal.SIGINT, handle_SIGINT)
 
@@ -88,7 +89,7 @@
     print "Error, removing " + " ".join(toremove)
     for file in toremove:
       os.remove(file)
-    return 1;
+    return 1
 
 built_something = False
 
@@ -96,8 +97,8 @@
   global built_something
   print cmd
   if os.system(cmd):
-    done();
-    sys.exit(1);
+    done()
+    sys.exit(1)
   built_something = True
 
 # clean and exit if given -c option:
@@ -156,7 +157,7 @@
   toremove = tobuild
   os.chdir(master_dir)
   run("node \"" +
-      native_path(join(tools_dir, "publish/publish.js")) +
+      native_path(join(tools_dir, join("publish","publish.js"))) +
       "\" --build " +
       " ".join(tobuild_names) +
       (" --local-style" if os.environ.get("SVG_BUILD_LOCAL_STYLE_SHEETS") else ""))
@@ -174,27 +175,23 @@
   singlePageTime = getmtime(single_page)
   for name in all:
     if getmtime(join(master_dir, name + ".html")) > singlePageTime:
-      buildSinglePage = True;
+      buildSinglePage = True
       break
 
 if buildSinglePage:
   os.chdir(master_dir)
   run("node \"" +
-      native_path(join(tools_dir, "publish/publish.js")) +
+      native_path(join(tools_dir, join("publish","publish.js"))) +
       "\" --build-single-page")
   os.chdir(repo_dir) # chdir back
 
 # Copy over anything else that needs to be copied to 'publish':
-
-tocopypaths = []
 for f in tocopy:
   tocopypath = join(master_dir, f)
   if os.path.exists(tocopypath):
-    tocopypaths.append(tocopypath)
-tocopypaths = " ".join(tocopypaths)
-
-if tocopypaths != "":
-  run("rsync -auC " + tocopypaths + " " + publish_dir);
+    copyto = os.path.join(publish_dir,os.path.basename(tocopypath))
+    shutil.rmtree(copyto, ignore_errors=True)
+    shutil.copytree(tocopypath, copyto)
 
 # Done: