encrypt.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import subprocess
  2. import os
  3. import sys
  4. import shutil
  5. if __name__ == '__main__':
  6. if os.path.exists("src/Dockerfile"):
  7. os.remove("src/Dockerfile")
  8. if os.path.exists("src/DockerfileEncrypt"):
  9. os.remove("src/DockerfileEncrypt")
  10. for root,dir,files in os.walk("./src"):
  11. for f in files:
  12. if f.endswith(".py") and f != "main.py":
  13. shell = f"cd {root} \
  14. && easycython {f}"
  15. cmd = subprocess.Popen(shell, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
  16. stdout=sys.stdout, universal_newlines=True, shell=True, bufsize=1)
  17. cmd.communicate()
  18. if cmd.returncode != 0:
  19. raise Exception(f+"加密出错")
  20. os.remove(os.path.join(root,f))
  21. os.remove(os.path.join(root,f.split(".")[0]+".html"))
  22. os.remove(os.path.join(root,f.split(".")[0]+".c"))
  23. shutil.rmtree(os.path.join(root,"build"))
  24. os.remove("encrypt.py")