Skip to content

Commit

Permalink
Corrected case when update is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Uros Petrevski committed Jan 30, 2015
1 parent 66b72d4 commit 94566aa
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions handlers/updaterHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def checkForUpdates(self, rq):
wifiMode = "sta" # local setting

if (wifiMode=="sta"):

data = {}
if (self.isConnected("we-io.net") or self.isConnected("www.github.com")):
config = weioConfig.getConfiguration()
repository = ""
Expand All @@ -155,8 +155,14 @@ def checkForUpdates(self, rq):
else :
# not connected to the internet
print "NO INTERNET CONNECTION"
data['serverPush'] = "noInternetConnection"
data['data'] = "Can't reach Internet servers"
self.send(json.dumps(data))
else :
print "NO INTERNET CONNECTION"
data['serverPush'] = "noInternetConnection"
data['data'] = "Can't reach Internet servers"
self.send(json.dumps(data))

# checking version
def checkVersion(self, response):
Expand Down Expand Up @@ -193,16 +199,20 @@ def checkVersion(self, response):
self.downloadUpdateLink = file["browser_download_url"]
self.downloadSize = file["size"]
print self.downloadUpdateLink, "size", file["size"]

if ("weio_recovery.bin" in file["name"]):
print "found weio_recovery"
self.fwDownloadLink = file["browser_download_url"]
self.fwDownloadSize = file["size"]
else :
rsp['needsUpdate'] = "NO"

# You can always reflash with last version even if there are no new updates
for file in lastUpdate["assets"]:
if ("weio_recovery.bin" in file["name"]):
print "found weio_recovery"
self.fwDownloadLink = file["browser_download_url"]
self.fwDownloadSize = file["size"]

self.send(json.dumps(rsp))

def downloadUpdate(self, rq):

#self.progressInfo("5%", "Downloading WeIO Bundle " + self.distantJsonUpdater["version"])
if not(self.downloadUpdateLink is None):
http_client = httpclient.AsyncHTTPClient()
Expand All @@ -226,7 +236,7 @@ def downloadComplete(self, binary):

# Check is file size is the same as on the server
sizeOnDisk = os.path.getsize(fileToStoreUpdate)

print "comparing sizes", sizeOnDisk, self.downloadSize
if (sizeOnDisk == self.downloadSize):
# OK
print "File size is OK"
Expand Down Expand Up @@ -299,6 +309,8 @@ def reinstallFw(self, data):
a['serverPush'] = "errorDownloading"
a['data'] = ""
self.send(json.dumps(data))
else :
self.checkForUpdates()

def sizeWatcher(self):
print "sizeeee"
Expand Down

0 comments on commit 94566aa

Please sign in to comment.