2 #from __future__ import print_function
11 except OSError as exc: # Python >2.5
12 if exc.errno == errno.EEXIST:
16 def publish(src,target):
17 cmd = ["rsync","-a","--copy-links","--partial",src,target]
18 retcode = subprocess.call(cmd)
20 error('%s : retruncode %s' % (' '.join(cmd),str(retcode)))
22 def ssh_cmd(target, command):
26 cmd = [c[0],c[1],t[0]]
28 cmd = ["ssh",t[0],c[0],c[1],t[1]]
29 retcode = subprocess.call(cmd)
31 error('%s : retruncode %s' % (' '.join(cmd),str(retcode)))
33 def sizeof_fmt(num, suffix='B'):
34 for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
36 return "%3.1f%s%s" % (num, unit, suffix)
38 return "%.1f%s%s" % (num, 'Yi', suffix)
40 def get_folder_size(folder):
41 total_size = os.path.getsize(folder)
42 if os.path.isfile(folder):
44 for item in os.listdir(folder):
45 itempath = os.path.join(folder, item)
46 if os.path.isfile(itempath):
47 total_size += os.path.getsize(itempath)
48 elif os.path.isdir(itempath):
49 total_size += get_folder_size(itempath)
52 #proc = subprocess.Popen(args, env={'PATH': os.getenv('PATH')})
55 out = subprocess.check_output(["translate.sh", f])
59 # print("WARNING: ", *objs, file=sys.stderr)
62 # print("ERROR: ", *objs, file=sys.stderr)