tools: copy-link support and size calculations
authorFredrik Unger <fred@tree.se>
Tue, 22 Jan 2019 20:20:41 +0000 (21:20 +0100)
committerFredrik Unger <fred@tree.se>
Tue, 22 Jan 2019 20:20:41 +0000 (21:20 +0100)
Chaning to make sure to copy the content of symbolic links
adding size calculation to estimate the size of the style directory
as it can contain large images, it is helpful to know when uploading.

treecutter/tools.py

index fa98ee0f9db5fa0a6a0be18e4a525e499fdcc3f9..3371a0c117ddbaa2ebc0b6a8a22cd7390edb714a 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-from __future__ import print_function
+#from __future__ import print_function
 import os
 import subprocess
 import errno
@@ -14,7 +14,7 @@ def mkdir_p(path):
         else: raise
 
 def publish(src,target):
-    cmd = ["rsync","-a","--delete","--partial",src,target]
+    cmd = ["rsync","-a","--copy-links","--partial",src,target]
     retcode = subprocess.call(cmd)
     if retcode:
         error('%s : retruncode %s' % (' '.join(cmd),str(retcode)))
@@ -39,6 +39,8 @@ def sizeof_fmt(num, suffix='B'):
 
 def get_folder_size(folder):
     total_size = os.path.getsize(folder)
+    if os.path.isfile(folder):
+        return total_size
     for item in os.listdir(folder):
         itempath = os.path.join(folder, item)
         if os.path.isfile(itempath):
@@ -47,8 +49,14 @@ def get_folder_size(folder):
             total_size += get_folder_size(itempath)
     return total_size
 
-def warning(*objs):
-    print("WARNING: ", *objs, file=sys.stderr)
+#proc = subprocess.Popen(args, env={'PATH': os.getenv('PATH')})
+def translate(files):
+    for f in files:
+        out = subprocess.check_output(["translate.sh", f])
+        sys.stdout.write('#')
 
-def error(*objs):
-    print("ERROR: ", *objs, file=sys.stderr)
+#def warning(*objs):
+#    print("WARNING: ", *objs, file=sys.stderr)
+
+#def error(*objs):
+#    print("ERROR: ", *objs, file=sys.stderr)