diff --git a/checkCustomAPK.py b/checkCustomAPK.py new file mode 100755 index 00000000000000..89aa683cba6bec --- /dev/null +++ b/checkCustomAPK.py @@ -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" diff --git a/checkCustomAPK.sh b/checkCustomAPK.sh deleted file mode 100755 index 4f879bde17627d..00000000000000 --- a/checkCustomAPK.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/bash - -apk_dir="/data/communitypilot_scripts" -if [ ! -d $apk_dir ] -then - echo "$apk_dir does not exist, installing" - curl -L https://raw.githubusercontent.com/pjlao307/communitypilot-apk-dist/master/install.py | python -else - echo "APK already installed" -fi diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index e97c07b464181f..62d0e06ac9b4f2 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -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