checkout.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. localrep = "/home/backup"
  2. remoteurl = 'https://git.cocorobo.cn/liushuai/CocoPi_upgrade.git'
  3. otaPath = "/root/preset/app/ota.py"
  4. from maix import camera, display, image
  5. image.load_freetype("/root/preset/fonts/simhei.ttf")
  6. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  7. hello_img.draw_string(10, 115, '切换语言中...', scale=1.0, color=(255, 255, 255), thickness=1)
  8. display.show(hello_img)
  9. import git
  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. git.swRemote(localrep, remoteurl)
  19. steam = NewStream()
  20. if git.activeBranch(localrep) != b'zh':
  21. git.checkout(localrep, 'zh', steam)
  22. else:
  23. git.checkout(localrep, 'en', steam)
  24. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  25. hello_img.draw_string(10, 115, '目录重建中...', scale=1.0, color=(255, 255, 255), thickness=1)
  26. display.show(hello_img)
  27. with open(otaPath) as f:
  28. code = f.read()
  29. exec(code)
  30. git.ro()