Merge lp:~nuclearbob/utah/media-info-mini into lp:utah

Proposed by Max Brustkern
Status: Merged
Approved by: Javier Collado
Approved revision: 778
Merged at revision: 784
Proposed branch: lp:~nuclearbob/utah/media-info-mini
Merge into: lp:utah
Diff against target: 33 lines (+1/-15)
1 file modified
utah/client/common.py (+1/-15)
To merge this branch: bzr merge lp:~nuclearbob/utah/media-info-mini
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Review via email: mp+138976@code.launchpad.net

Description of the change

When running on a mini image, media info was missing, and this generated a type error when we tried to put None into the yaml, so I've changed it to use 'unknown' instead. When running pyflakes, I found there were two get_arch functions in that file, so I removed the one that wasn't currently in use.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

What was the output of `platform.machine()` call in that case?

According to the python documentation, when the machine type cannot be
determined, the empty string is returned. Hence, maybe the `arches` dictionary
in the `get_arch` function has to be updated and the 'unknown' value should be
inserted for the empty string (if another non empty value is returned, then we
should consider adding it to the `arches` dictionary as well).

review: Needs Information
Revision history for this message
Max Brustkern (nuclearbob) wrote :

The get_media_info function tries to open /var/log/installer/media-info, and if it doesn't open that file, it leaves media_info as None. The platform.machine call in get_arch is working fine. We had get_arch defined two different ways, which was picked up by static analysis, so I deleted the first one, since the second one is what's getting used and working fine.

Revision history for this message
Javier Collado (javier.collado) wrote :

I see I got confused with the diff. Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/client/common.py'
2--- utah/client/common.py 2012-12-08 02:10:12 +0000
3+++ utah/client/common.py 2012-12-10 14:09:27 +0000
4@@ -343,7 +343,7 @@
5
6 filename = '/var/log/installer/media-info'
7
8- media_info = None
9+ media_info = 'unknown'
10
11 if os.path.exists(filename) and os.access(filename, os.R_OK):
12 with open(filename, 'r') as f:
13@@ -389,20 +389,6 @@
14
15 def get_arch():
16 """
17- The host's architecture (i.e. i386, amd64, etc.)
18- """
19- uname = platform.uname()
20-
21- arch = {
22- 'x86_64': 'amd64',
23- 'x86': 'i386',
24- }.get(uname[5]) # 5 == processor
25-
26- return arch
27-
28-
29-def get_arch():
30- """
31 The host's architecture.
32
33 Returns the human readable architecture or 'unknown'.

Subscribers

People subscribed via source and target branches