- cmd = "cp -l %s %s" % (
- os.path.join(cfg.in_dir, file.rel_path),
- out_path
- )
- #print cmd
- os.system(cmd)
+ try:
+ shutil.copy(os.path.join(cfg.in_dir, file.rel_path), out_path)
+ except:
+ os.remove(out_path)
+ shutil.copy(os.path.join(cfg.in_dir, file.rel_path), out_path)
+ shutil.copystat(os.path.join(cfg.in_dir, file.rel_path), out_path)