Comment 4 for bug 887879

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Although it is guarded with try/except, instead of checking for online state it still solves the problem:
revno: 5528
committer: Mario Limonciello <email address hidden>
branch nick: ubiquity
timestamp: Wed 2012-06-27 19:21:51 -0500
message:
  Don't let oem-config crash from an invalid server return on the timezone
  page.
diff:
=== modified file 'debian/changelog'
--- debian/changelog 2012-06-27 21:46:17 +0000
+++ debian/changelog 2012-06-28 00:21:51 +0000
@@ -4,6 +4,10 @@
   * Only allow a user to proceed on the networking screen if he entered a valid
     password. This prevents a nm dbus exception. (LP: #112211)

+ [ Mario Limonciello ]
+ * Don't let oem-config crash from an invalid server return on the timezone
+ page.
+
  -- Stéphane Graber <email address hidden> Wed, 27 Jun 2012 17:45:36 -0400

 ubiquity (2.11.7) quantal-proposed; urgency=low

=== modified file 'ubiquity/plugins/ubi-timezone.py'
--- ubiquity/plugins/ubi-timezone.py 2012-05-29 23:07:53 +0000
+++ ubiquity/plugins/ubi-timezone.py 2012-06-28 00:21:51 +0000
@@ -176,15 +176,19 @@
                            (text, message.status_code,
                             message.reason_phrase))))
         else:
- for result in json.loads(message.response_body.data):
- model.append([result['name'],
- result['admin1'],
- result['country'],
- result['latitude'],
- result['longitude']])
-
- # Only cache positive results.
- self.geoname_cache[text] = model
+ try:
+ for result in json.loads(message.response_body.data):
+ model.append([result['name'],
+ result['admin1'],
+ result['country'],
+ result['latitude'],
+ result['longitude']])
+
+ # Only cache positive results.
+ self.geoname_cache[text] = model
+
+ except ValueError:
+ syslog.syslog('Server return does not appear to be valid JSON.')

         self.city_entry.get_completion().set_model(model)