checkout.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. image.load_freetype("/root/preset/fonts/simhei.ttf")
  24. hello_img = image.new(size=(320, 240), color=(0, 0, 0),
  25. mode="RGB") # 创建一张黑色背景图
  26. hello_img.draw_string(10, 115,'Start', scale=1.0, color=(255, 255, 255),
  27. thickness=1) # 在黑色背景图上写下hello world
  28. if os.path.exists(localrep + "/cclb_launch"):
  29. os.remove(localrep + "/cclb_launch")
  30. if git.activeBranch(localrep) != b'master':
  31. git.checkout(localrep, 'master', steam)
  32. else:
  33. git.checkout(localrep, 'en', steam)
  34. if os.path.exists("/root/CocoPi.py"):
  35. os.remove("/root/CocoPi.py")
  36. os.system('chmod -R 777 /home')
  37. os.system('reboot')
  38. git.ro()