Browse Source

更新 'backup/preset/app/pull.py'

junhuanchen 1 year ago
parent
commit
a96b32fae2
1 changed files with 21 additions and 26 deletions
  1. 21 26
      backup/preset/app/pull.py

+ 21 - 26
backup/preset/app/pull.py

@@ -1,45 +1,40 @@
-import git
-import os
 from maix import camera, display, image  # 引入python模块包
+
+image.load_freetype("/root/preset/fonts/simhei.ttf")
+hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
+hello_img.draw_string(10, 115, 'Pull', scale=1.0, color=(255, 255, 255), thickness=1)
+display.show(hello_img)
+
+import git, os, time
 from io import RawIOBase
 
 localrep = "/home"
 
 
 class NewStream(RawIOBase):
-    """Fallback if stdout or stderr are unavailable, does nothing."""
-
-    def read(self, size=-1):
-        return None
-
-    def readall(self):
-        return None
-
-    def readinto(self, b):
-        return None
-
     def write(self, b):
-        hello_img = image.new(size=(320, 240), color=(0, 0, 0),
-                              mode="RGB")
-        hello_img.draw_string(10, 115, str(b), scale=1.0, color=(255, 255, 255),
-                              thickness=1)
+        hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
+        hello_img.draw_string(10, 115, str(b), scale=1.0, color=(255, 255, 255), thickness=1)
         display.show(hello_img)
         return None
 
 
 git.rw()
 steam = NewStream()
-image.load_freetype("/root/preset/fonts/simhei.ttf")
-hello_img = image.new(size=(320, 240), color=(0, 0, 0),
-                      mode="RGB")  # 创建一张黑色背景图
-hello_img.draw_string(10, 115,'Start', scale=1.0, color=(255, 255, 255),
-                      thickness=1)  # 在黑色背景图上写下hello world
-display.show(hello_img)  # 把这张图显示出来
+
 if os.path.exists(localrep + "/cclb_launch"):
     os.remove(localrep + "/cclb_launch")
 git.pull(localrep, steam)
-if os.path.exists("/root/CocoPi.py"):
-    os.remove("/root/CocoPi.py")
+hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
+commit, Author, Date, message = git.__log__(localrep)
+hello_img.draw_string(10, 50, commit, scale=1.0, color=(255, 255, 255), thickness=1)
+hello_img.draw_string(10, 100, Author, scale=1.0, color=(255, 255, 255), thickness=1)
+hello_img.draw_string(10, 150, Date, scale=1.0, color=(255, 255, 255), thickness=1)
+hello_img.draw_string(10, 200, message, scale=1.0, color=(255, 255, 255), thickness=1)
+display.show(hello_img)
+time.sleep(2)
+
 os.system('chmod -R 777 /home')
-os.system('reboot')
+os.system('rsync --checksum /home/backup /root')
+os.system("ps | grep main.py | grep -v grep | awk '{print $1}' | xargs kill")
 git.ro()