From: Fredrik Unger Date: Tue, 22 Jan 2019 20:20:41 +0000 (+0100) Subject: tools: copy-link support and size calculations X-Git-Url: https://source.tree.se/git?p=treecutter.git;a=commitdiff_plain;h=f48c54af10719beb3ec8dba3494bd75064001fdd;ds=sidebyside tools: copy-link support and size calculations 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. --- diff --git a/treecutter/tools.py b/treecutter/tools.py index fa98ee0..3371a0c 100644 --- a/treecutter/tools.py +++ b/treecutter/tools.py @@ -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)