Merge lp:~dobey/ubuntuone-installer/proper-series into lp:ubuntuone-installer

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 7
Merged at revision: 11
Proposed branch: lp:~dobey/ubuntuone-installer/proper-series
Merge into: lp:ubuntuone-installer
Diff against target: 46 lines (+25/-1)
1 file modified
ubuntuone/installer/gui.py (+25/-1)
To merge this branch: bzr merge lp:~dobey/ubuntuone-installer/proper-series
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+71601@code.launchpad.net

Commit message

Check that we're on Ubuntu, and get series info from /etc/lsb-release

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1 with an asterisk on the print.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/installer/gui.py'
2--- ubuntuone/installer/gui.py 2011-08-04 22:06:31 +0000
3+++ ubuntuone/installer/gui.py 2011-08-15 19:42:16 +0000
4@@ -32,6 +32,10 @@
5 inline_callbacks = old_callbacks
6
7
8+class UnsupportedDistribution(BaseException):
9+ """Exception for when on an unsupported distribution."""
10+
11+
12 class Window(Gtk.Window):
13 """The main dialog to use."""
14
15@@ -174,10 +178,30 @@
16
17 def __get_series(self):
18 """Get the series we're running on."""
19- return 'natty'
20+ on_ubuntu = False
21+ series = None
22+
23+ def get_value(keypair):
24+ return keypair.split('=')[1].strip()
25+
26+ try:
27+ with open('/etc/lsb-release', 'r') as f:
28+ for line in f.readlines():
29+ if line.startswith('DISTRIB_ID'):
30+ on_ubuntu = get_value(line) == u'Ubuntu'
31+ if line.startswith('DISTRIB_CODENAME'):
32+ series = get_value(line)
33+ if not on_ubuntu or series is None:
34+ raise UnsupportedDistribution(
35+ 'This distribution is not supported by Ubuntu One.')
36+ except (OSError, IOError, UnsupportedDistribution), error:
37+ self.__got_error(error)
38+
39+ return series
40
41 def __got_error(self, error):
42 """Got an error trying to set up Ubuntu One."""
43+ print error
44 Gtk.main_quit()
45
46 @inline_callbacks

Subscribers

People subscribed via source and target branches

to all changes: