checkout.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. localrep = "/home"
  2. from maix import camera, display, image
  3. image.load_freetype("/root/preset/fonts/simhei.ttf")
  4. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  5. hello_img.draw_string(10, 115, 'Checkout', scale=1.0, color=(255, 255, 255), thickness=1)
  6. display.show(hello_img)
  7. import os, git
  8. if os.path.exists(localrep + "/cclb_launch"):
  9. os.remove(localrep + "/cclb_launch")
  10. from io import RawIOBase
  11. class NewStream(RawIOBase):
  12. def write(self, b):
  13. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  14. hello_img.draw_string(10, 115, str(b), scale=1.0, color=(255, 255, 255), thickness=1)
  15. display.show(hello_img)
  16. return None
  17. git.rw()
  18. steam = NewStream()
  19. if os.path.exists(localrep + "/cclb_launch"):
  20. os.remove(localrep + "/cclb_launch")
  21. if git.activeBranch(localrep) != b'master':
  22. git.checkout(localrep, 'master', steam)
  23. else:
  24. git.checkout(localrep, 'en', steam)
  25. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  26. hello_img.draw_string(10, 115, 'Reconstruct directory', scale=1.0, color=(255, 255, 255), thickness=1)
  27. display.show(hello_img)
  28. os.system('chmod -R 777 /home')
  29. os.system('rsync -r --checksum /home/backup/ /root')
  30. os.system("ps | grep main.py | grep -v grep | awk '{print $1}' | xargs kill")
  31. git.ro()