checkout.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. localrep = "/home/backup"
  2. otaPath = "/root/preset/app/ota.py"
  3. from maix import camera, display, image
  4. image.load_freetype("/root/preset/fonts/simhei.ttf")
  5. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  6. hello_img.draw_string(10, 115, 'Checkout', scale=1.0, color=(255, 255, 255), thickness=1)
  7. display.show(hello_img)
  8. import git
  9. from io import RawIOBase
  10. class NewStream(RawIOBase):
  11. def write(self, b):
  12. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  13. hello_img.draw_string(10, 115, str(b), scale=1.0, color=(255, 255, 255), thickness=1)
  14. display.show(hello_img)
  15. return None
  16. git.rw()
  17. steam = NewStream()
  18. if git.activeBranch(localrep) != b'zh':
  19. git.checkout(localrep, 'zh', steam)
  20. else:
  21. git.checkout(localrep, 'en', steam)
  22. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  23. hello_img.draw_string(10, 115, 'Reconstruct directory', scale=1.0, color=(255, 255, 255), thickness=1)
  24. display.show(hello_img)
  25. with open(otaPath) as f:
  26. code = f.read()
  27. exec(code)
  28. git.ro()