Browse Source

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

junhuanchen 1 year ago
parent
commit
0629168ee0
1 changed files with 13 additions and 5 deletions
  1. 13 5
      backup/preset/app/pull.py

+ 13 - 5
backup/preset/app/pull.py

@@ -1,3 +1,5 @@
+localrep = "/home"
+
 from maix import camera, display, image  # 引入python模块包
 
 image.load_freetype("/root/preset/fonts/simhei.ttf")
@@ -5,10 +7,18 @@ 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
+import os, git, time
 
-localrep = "/home"
+if not git.isOnline(localrep):
+    hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
+    hello_img.draw_string(10, 115, 'Network connection error', scale=1.0, color=(255, 255, 255), thickness=1)
+    display.show(hello_img)
+    time.sleep(2)
+    exit()
+if os.path.exists(localrep + "/cclb_launch"):
+    os.remove(localrep + "/cclb_launch")
+
+from io import RawIOBase
 
 
 class NewStream(RawIOBase):
@@ -22,8 +32,6 @@ class NewStream(RawIOBase):
 git.rw()
 steam = NewStream()
 
-if os.path.exists(localrep + "/cclb_launch"):
-    os.remove(localrep + "/cclb_launch")
 git.pull(localrep, steam)
 hello_img = image.new(size=(320, 240), color=(0, 0, 0), mode="RGB")
 commit, Author, Date, message = git.__log__(localrep)