checkout.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import git
  2. import os
  3. from maix import camera, display, image # 引入python模块包
  4. from io import RawIOBase
  5. localrep = "/home"
  6. class NewStream(RawIOBase):
  7. """Fallback if stdout or stderr are unavailable, does nothing."""
  8. def read(self, size=-1):
  9. return None
  10. def readall(self):
  11. return None
  12. def readinto(self, b):
  13. return None
  14. def write(self, b):
  15. hello_img = image.new(size=(320, 240), color=(0, 0, 0),
  16. mode="RGB") # 创建一张黑色背景图
  17. hello_img.draw_string(10, 115, str(b), scale=1.0, color=(255, 255, 255),
  18. thickness=1) # 在黑色背景图上写下hello world
  19. display.show(hello_img) # 把这张图显示出来
  20. return None
  21. git.rw()
  22. steam = NewStream()
  23. if os.path.exists(localrep + "/cclb_launch"):
  24. os.remove(localrep + "/cclb_launch")
  25. if git.activeBranch(localrep) != b'master':
  26. git.checkout(localrep, 'master', steam)
  27. else:
  28. git.checkout(localrep, 'en', steam)
  29. if os.path.exists("/root/CocoPi.py"):
  30. os.remove("/root/CocoPi.py")
  31. os.system('chmod -R 777 /home')
  32. os.system('reboot')
  33. git.ro()