fix: bug when reinstall plugin

This commit is contained in:
lanvent
2023-04-06 21:03:17 +08:00
parent 3c6d42b22e
commit 8b73a74609
4 changed files with 56 additions and 24 deletions

View File

@@ -1,3 +1,4 @@
import time
import pip
def install(package):
@@ -7,9 +8,20 @@ def install_requirements(file):
pip.main(['install', '-r', file, "--upgrade"])
def check_dulwich():
needwait = False
for i in range(2):
if needwait:
time.sleep(3)
needwait = False
try:
import dulwich
return
except ImportError:
try:
install('dulwich')
except:
needwait = True
try:
import dulwich
return
except ImportError:
install('dulwich')
raise ImportError("Unable to import dulwich")
raise ImportError("Unable to import dulwich")