pull.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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)
  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. display.show(hello_img) # 把这张图显示出来
  29. if os.path.exists(localrep + "/cclb_launch"):
  30. os.remove(localrep + "/cclb_launch")
  31. git.pull(localrep, steam)
  32. if os.path.exists("/root/CocoPi.py"):
  33. os.remove("/root/CocoPi.py")
  34. os.system('chmod -R 777 /home')
  35. os.system('reboot')
  36. git.ro()