Skip to content

Commit

Permalink
Merge pull request commaai#376 from pjlao307/arne182-release2
Browse files Browse the repository at this point in the history
Add internet check before installing
  • Loading branch information
arne182 committed Jun 8, 2019
2 parents 201b74d + 11e56e5 commit 7f1d744
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
43 changes: 43 additions & 0 deletions checkCustomAPK.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import urllib
import os
import time

apk_dir="/data/communitypilot_scripts"
install_script = "https://raw.githubusercontent.com/pjlao307/communitypilot-apk-dist/master/install.py"

def checkConnection():
try:
url = "https://raw.githubusercontent.com/pjlao307/communitypilot-apk-dist/master/install.py"
urllib.urlopen(url)
isConnected = True
except:
isConnected = False

return isConnected

def waitForConnection():
isConnected = False
connectCount = 0
maxWaitTime = 10

while not isConnected:
print "Waitng for internet connection"
if connectCount >= maxWaitTime:
break
connectCount += 1
isConnected = checkConnection()
time.sleep(1)

if not isConnected:
print "No connection, giving up"
exit

print "Checking for custom APK installation"
path_exists = os.path.isdir(apk_dir)

if not path_exists:
print "%s does not exist, installing" % apk_dir
waitForconnection()
os.system("curl -L %s | python" % install_script)
else:
print "APK already installed"
10 changes: 0 additions & 10 deletions checkCustomAPK.sh

This file was deleted.

2 changes: 1 addition & 1 deletion launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function launch {
export PYTHONPATH="$PWD"

# check to see if custom APK is installed
sh ./checkCustomAPK.sh
python ./checkCustomAPK.py

# start manager
cd selfdrive
Expand Down

0 comments on commit 7f1d744

Please sign in to comment.