Adding target directory and readability with ssh_cmd
authorFredrik Unger <fred@tree.se>
Mon, 6 Feb 2012 21:17:29 +0000 (22:17 +0100)
committerFredrik Unger <fred@tree.se>
Mon, 6 Feb 2012 21:17:29 +0000 (22:17 +0100)
Making sure that the target directory exists and that it is
readable after rsync. ssh_cmd added to simplify the call, but is
currently limited to commands with two arguments plus directory.
Can be generalized. subroutine call used to not need to add extra
dependencies at this point.

src/tree-cutter.py

index 1daed02116dc72cd6882d3bb04617038fce2fab5..4b28acba0ddbe34e067edd1b139951edf259ceb0 100755 (executable)
@@ -46,6 +46,13 @@ def publish(src,target):
     if retcode:
         print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'
 
+def ssh_cmd(target, command):
+    t = target.split(":")
+    c = command.split()
+    cmd = ["ssh",t[0],c[0],c[1],t[1]]
+    retcode = subprocess.call(cmd)
+    if retcode:
+        print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'
 
 PREFIXES={u'db': u'http://docbook.org/ns/docbook',
           u'xi': u'http://www.w3.org/2001/XInclude',
@@ -408,9 +415,12 @@ class Sitemap():
         return html
 
     def publish(self):
+        ssh_cmd(args.output,"mkdir -p")
         publish(tmptarget, args.output)
-        publish(args.style+"css", args.output)
-        publish(args.style+"images",args.output)
+        for res in ["css","images","js","favicon.ico"]:
+            if (os.path.exists(args.style+res)):
+                publish(args.style+res, args.output)
+        ssh_cmd(args.output,"chmod a+rx"
 
 ts = time.time()
 dir_ = Directory()