Merge lp:~stub/charm-helpers/bug-1663184-osplatform-fail into lp:charm-helpers

Proposed by Stuart Bishop
Status: Merged
Merged at revision: 684
Proposed branch: lp:~stub/charm-helpers/bug-1663184-osplatform-fail
Merge into: lp:charm-helpers
Diff against target: 22 lines (+6/-0)
1 file modified
charmhelpers/osplatform.py (+6/-0)
To merge this branch: bzr merge lp:~stub/charm-helpers/bug-1663184-osplatform-fail
Reviewer Review Type Date Requested Status
Cory Johns (community) Approve
Review via email: mp+316847@code.launchpad.net

Description of the change

Travis-CI has been failing unit tests, due to osplatform.get_platform() raising RuntimeErrors. Diagnosis shows platform.linux_platform() returning debian.

This fix is really a band-aid, as is probably appropriate as platform.linux_platform() is deprecated and will not exist in Python 3.7 (and the next Ubuntu LTS).

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/osplatform.py'
2--- charmhelpers/osplatform.py 2016-08-10 09:57:19 +0000
3+++ charmhelpers/osplatform.py 2017-02-09 13:46:02 +0000
4@@ -8,12 +8,18 @@
5 will be returned (which is the name of the module).
6 This string is used to decide which platform module should be imported.
7 """
8+ # linux_distribution is deprecated and will be removed in Python 3.7
9+ # Warings *not* disabled, as we certainly need to fix this.
10 tuple_platform = platform.linux_distribution()
11 current_platform = tuple_platform[0]
12 if "Ubuntu" in current_platform:
13 return "ubuntu"
14 elif "CentOS" in current_platform:
15 return "centos"
16+ elif "debian" in current_platform:
17+ # Stock Python does not detect Ubuntu and instead returns debian.
18+ # Or at least it does in some build environments like Travis CI
19+ return "ubuntu"
20 else:
21 raise RuntimeError("This module is not supported on {}."
22 .format(current_platform))

Subscribers

People subscribed via source and target branches