liushuai 2 месяцев назад
Родитель
Сommit
a16b8e8fb8
3 измененных файлов с 15 добавлено и 8 удалено
  1. 4 1
      preset/app/checkout.py
  2. 6 5
      preset/app/git.py
  3. 5 2
      preset/app/pull.py

+ 4 - 1
preset/app/checkout.py

@@ -1,4 +1,5 @@
 localrep = "/home/backup"
+remoteurl = 'https://git.cocorobo.cn/liushuai/CocoPi_upgrade.git'
 otaPath = "/root/preset/app/ota.py"
 
 from maix import camera, display, image
@@ -21,6 +22,8 @@ class NewStream(RawIOBase):
 
 
 git.rw()
+
+git.swRemote(localrep, remoteurl)
 steam = NewStream()
 
 if git.activeBranch(localrep) != b'zh':
@@ -36,4 +39,4 @@ with open(otaPath) as f:
     code = f.read()
 exec(code)
 
-git.ro()
+git.ro()

+ 6 - 5
preset/app/git.py

@@ -119,13 +119,14 @@ def isOnline(localRep):
     
 def swRemote(localRep, remote_url):
     r = Repo(localRep)
-    porcelain.remote_remove(r,'origin')
-    porcelain.remote_add(r,'origin',remote_url)
+    try:
+        porcelain.remote_remove(r,'origin')
+        porcelain.remote_add(r,'origin',remote_url)
+    except:
+        porcelain.remote_add(r,'origin',remote_url)
 
 def swRemote_force(localRep, remote_url):
-    r = Repo(localRep)
-    porcelain.remote_remove(r,'origin')
-    porcelain.remote_add(r,'origin',remote_url)
+    swRemote(localRep, remote_url)
     porcelain.fetch(localRep)
     porcelain.pull(localRep, refspecs=porcelain.active_branch(localRep), force=True)
 

+ 5 - 2
preset/app/pull.py

@@ -1,5 +1,6 @@
 localrep = "/home/backup"
-otaPath = 'ota.py'
+remoteurl = 'https://git.cocorobo.cn/liushuai/CocoPi_upgrade.git'
+otaPath = "/root/preset/app/ota.py"
 
 from maix import camera, display, image  # 引入python模块包
 
@@ -29,6 +30,8 @@ class NewStream(RawIOBase):
 
 
 git.rw()
+
+git.swRemote(localrep, remoteurl)
 steam = NewStream()
 git.pull(localrep, steam)
 
@@ -44,4 +47,4 @@ with open(otaPath) as f:
     code = f.read()
 exec(code)
 
-git.ro()
+git.ro()