pull.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from maix import camera, display, image # 引入python模块包
  2. image.load_freetype("/root/preset/fonts/simhei.ttf")
  3. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  4. hello_img.draw_string(10, 115, 'Pull', scale=1.0, color=(255, 255, 255), thickness=1)
  5. display.show(hello_img)
  6. import git, os, time
  7. from io import RawIOBase
  8. localrep = "/home"
  9. class NewStream(RawIOBase):
  10. def write(self, b):
  11. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  12. hello_img.draw_string(10, 115, str(b), scale=1.0, color=(255, 255, 255), thickness=1)
  13. display.show(hello_img)
  14. return None
  15. git.rw()
  16. steam = NewStream()
  17. if os.path.exists(localrep + "/cclb_launch"):
  18. os.remove(localrep + "/cclb_launch")
  19. git.pull(localrep, steam)
  20. hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
  21. commit, Author, Date, message = git.__log__(localrep)
  22. hello_img.draw_string(10, 50, commit, scale=1.0, color=(255, 255, 255), thickness=1)
  23. hello_img.draw_string(10, 100, Author, scale=1.0, color=(255, 255, 255), thickness=1)
  24. hello_img.draw_string(10, 150, Date, scale=1.0, color=(255, 255, 255), thickness=1)
  25. hello_img.draw_string(10, 200, message, scale=1.0, color=(255, 255, 255), thickness=1)
  26. display.show(hello_img)
  27. time.sleep(2)
  28. os.system('chmod -R 777 /home')
  29. os.system('rsync --checksum /home/backup /root')
  30. os.system("ps | grep main.py | grep -v grep | awk '{print $1}' | xargs kill")
  31. git.ro()