checkout.py 1.2 KB

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