瀏覽代碼

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

junhuanchen 1 年之前
父節點
當前提交
70f67e883b
共有 1 個文件被更改,包括 25 次插入10 次删除
  1. 25 10
      backup/preset/app/pull.py

+ 25 - 10
backup/preset/app/pull.py

@@ -1,19 +1,34 @@
-from dulwich import porcelain
+import git
 import os
+from io import RawIOBase
 
-def ro():
-    os.system("/etc/init.d/S01mount_ro start")
+localrep = "/home"
 
 
-def rw():
-    os.system("/etc/init.d/S01mount_ro stop")
+class NewStream(RawIOBase):
+    """Fallback if stdout or stderr are unavailable, does nothing."""
 
+    def read(self, size=-1):
+        return None
 
-localrep = "/home"
+    def readall(self):
+        return None
+
+    def readinto(self, b):
+        return None
+
+    def write(self, b):
+        print(b)
+        return None
 
-rw()
 
-porcelain.pull(localrep)
-os.remove("/root/CocoPi.py")
-ro()
+git.rw()
+steam = NewStream()
+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")
+os.system('chmod -R 777 /home')
 os.system('reboot')
+git.ro()