Fix autoupdate to be backwards compatible with previous releases.
If the "board" attribute is not set, then assume "x86-generic"
Review URL: http://codereview.chromium.org/661005
diff --git a/autoupdate.py b/autoupdate.py
index 2bdef68..eb5b9ac 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -58,7 +58,8 @@
"""
client_tokens = client_version.split('.')
latest_tokens = latest_version.split('.')
- web.debug("client version %s latest version %s" % (client_version, latest_version))
+ web.debug("client version %s latest version %s" \
+ % (client_version, latest_version))
for i in range(0,4):
if int(latest_tokens[i]) == int(client_tokens[i]):
continue
@@ -79,7 +80,8 @@
web.debug("Found an image, copying it to static")
err = os.system("cp %s/update.gz %s" % (image_path, self.static_dir))
if err != 0:
- web.debug("Unable to move update.gz from %s to %s" % (image_path, self.static_dir))
+ web.debug("Unable to move update.gz from %s to %s" \
+ % (image_path, self.static_dir))
return False
return True
@@ -87,7 +89,8 @@
return os.path.getsize(update_path)
def GetHash(self, update_path):
- cmd = "cat %s | openssl sha1 -binary | openssl base64 | tr \'\\n\' \' \';" % update_path
+ cmd = "cat %s | openssl sha1 -binary | openssl base64 | tr \'\\n\' \' \';" \
+ % update_path
web.debug(cmd)
return os.popen(cmd).read()
@@ -95,11 +98,13 @@
update_dom = minidom.parseString(data)
root = update_dom.firstChild
query = root.getElementsByTagName("o:app")[0]
- client_version = query.attributes['version'].value
- board_id = query.attributes['board'].value
- latest_image_path = self.GetLatestImagePath(board_id);
- latest_version = self.GetLatestVersion(latest_image_path);
- if client_version != "ForcedUpdate" and not self.CanUpdate(client_version, latest_version):
+ client_version = query.getAttribute('version')
+ board_id = query.hasAttribute('board') and query.getAttribute('board') \
+ or "x86-generic"
+ latest_image_path = self.GetLatestImagePath(board_id)
+ latest_version = self.GetLatestVersion(latest_image_path)
+ if client_version != "ForcedUpdate" \
+ and not self.CanUpdate(client_version, latest_version):
web.debug("no update")
return self.GetNoUpdatePayload()