Merge lp://staging/~bac/juju-quickstart/get_os_version into lp://staging/juju-quickstart
Proposed by
Brad Crittenden
Status: | Merged |
---|---|
Merged at revision: | 68 |
Proposed branch: | lp://staging/~bac/juju-quickstart/get_os_version |
Merge into: | lp://staging/juju-quickstart |
Diff against target: |
183 lines (+152/-2) 4 files modified
quickstart/platform_support.py (+61/-0) quickstart/tests/test_manage.py (+2/-2) quickstart/tests/test_platform_support.py (+84/-0) requirements.pip (+5/-0) |
To merge this branch: | bzr merge lp://staging/~bac/juju-quickstart/get_os_version |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email: mp+220737@code.staging.launchpad.net |
Description of the change
Add a function for determing OS flavor.
Determines OS and then for the case of Linuxes, determines whether the
system uses apt-get or RPM.
To post a comment you must log in.
Reviewers: mp+220737_ code.launchpad. net,
Message:
Please take a look.
Description:
Add a function for determing OS flavor.
Determines OS and then for the case of Linuxes, determines whether the
system uses apt-get or RPM.
https:/ /code.launchpad .net/~bac/ juju-quickstart /get_os_ version/ +merge/ 220737
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/99410054/
Affected files (+78, -0 lines): manage. py tests/test_ manage. py
A [revision details]
M quickstart/
M quickstart/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision: <email address hidden>
Index: quickstart/ manage. py manage. py' manage. py 2014-04-23 11:22:44 +0000 manage. py 2014-05-22 20:51:42 +0000
parser. exit()
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -25,6 +25,7 @@
import codecs
import logging
import os
+import platform
import shutil
import sys
import webbrowser
@@ -54,6 +55,31 @@
+class UnsupportedOS( Exception) : isfile( '/usr/bin/ apt-get' ): isfile( '/usr/bin/ rpm'): system) ) system) info(juju_ source) :
+ pass
+
+
+OSX = object()
+LINUX_APT = object()
+LINUX_RPM = object()
+WINDOWS = object()
+
+
+def get_os_version():
+ system = platform.system()
+ if system == 'Darwin':
+ return OSX
+ elif system == 'Windows':
+ return WINDOWS
+ elif system == 'Linux':
+ if os.path.
+ return LINUX_APT
+ elif os.path.
+ return LINUX_RPM
+ raise UnsupportedOS('{} without apt-get nor rpm'.format(
+ raise UnsupportedOS(
+
+
def _get_packaging_
"""Return packaging info based on the given juju source.
Index: quickstart/ tests/test_ manage. py tests/test_ manage. py' tests/test_ manage. py 2014-04-23 13:08:12 +0000 tests/test_ manage. py 2014-05-22 20:51:42 +0000
u'admin- secret not found in ~/.juju/ environments/ local.jenv '
self. assertEqual( expected, context. exception. message) n(unittest. TestCase) : system( self, system=None): return_ value=system) manage. platform. system' platform) side_effect= iter(values) ) manage. os.path. isfile' apt(self) : platform_ system( 'Linux' ): isfile( [True]) : get_os_ version( ) l(manage. LINUX_APT, result) rpm(self) : platform_ system( 'Linux' ):
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -919,3 +919,53 @@
'or environments.yaml')
+
+
+class TestGetOSVersio
+
+ def patch_platform_
+ """Patch the platform.system call to return the given value."""
+ mock_patch_platform = mock.Mock(
+ path = 'quickstart.
+ return mock.patch(path, mock_patch_
+
+ def patch_isfile(self, values):
+ mock_patch_isfile = mock.Mock(
+ path = 'quickstart.
+ return mock.patch(path, mock_patch_isfile)
+
+ def test_linux_
+ with self.patch_
+ with self.patch_
+ result = manage.
+ self.assertEqua
+
+ def test_linux_
+ with self.patch_
+ with self.pat...