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","--delete","--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 for item in os.listdir(folder):
43 itempath = os.path.join(folder, item)
44 if os.path.isfile(itempath):
45 total_size += os.path.getsize(itempath)
46 elif os.path.isdir(itempath):
47 total_size += get_folder_size(itempath)
51 print("WARNING: ", *objs, file=sys.stderr)
54 print("ERROR: ", *objs, file=sys.stderr)