forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request commaai#376 from pjlao307/arne182-release2
Add internet check before installing
- Loading branch information
Showing
3 changed files
with
44 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters