perl_wrapper.py 503 B

123456789101112131415161718192021222324
  1. import os
  2. import sys
  3. import shutil
  4. if __name__ == '__main__':
  5. path = sys.argv[1]
  6. to = sys.argv[-1]
  7. fr = sys.argv[-2]
  8. to_dir = os.path.dirname(to)
  9. os.chdir(to_dir)
  10. f1 = os.path.basename(fr)
  11. fr_ = os.path.dirname(fr)
  12. f2 = os.path.basename(fr_)
  13. fr_ = os.path.dirname(fr_)
  14. os.makedirs(f2)
  15. shutil.copyfile(fr, os.path.join(f2, f1))
  16. if path[0] != '/':
  17. path = os.path.join(os.path.dirname(__file__), path)
  18. os.execv(path, [path] + sys.argv[2:])