Commit eb1cd142 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos.package: Minor style/pep changes

parent cd600cda
...@@ -196,15 +196,18 @@ class AptGet: ...@@ -196,15 +196,18 @@ class AptGet:
def updateSystem(self, caller): def updateSystem(self, caller):
""" Dist-Upgrade of system """ """ Dist-Upgrade of system """
self.updateRepository(caller)
caller(['apt-get', 'dist-upgrade', '-y'], stdout=None) caller(['apt-get', 'dist-upgrade', '-y'], stdout=None)
class Zypper: class Zypper:
def purgeRepository(self, caller): def purgeRepository(self, caller):
"""Remove all repositories""" """Remove all repositories"""
listing, err = caller(['zypper', 'lr'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) listing, err = caller(['zypper', 'lr'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while listing.count('\n') > 2: while listing.count('\n') > 2:
output, err = caller(['zypper', 'rr', '1'], stdout=None) output, err = caller(['zypper', 'rr', '1'], stdout=None)
listing, err = caller(['zypper', 'lr'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) listing, err = caller(['zypper', 'lr'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def addRepository(self, caller, url, alias): def addRepository(self, caller, url, alias):
""" Add a repository """ """ Add a repository """
...@@ -223,7 +226,8 @@ class Zypper: ...@@ -223,7 +226,8 @@ class Zypper:
caller(['zypper', '--gpg-auto-import-keys', 'in', '-Dly'], stdout=None) caller(['zypper', '--gpg-auto-import-keys', 'in', '-Dly'], stdout=None)
def isUpgradable(self, caller, name): def isUpgradable(self, caller, name):
output, err = caller(['zypper', '--gpg-auto-import-keys', 'up', '-ly'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, err = caller(['zypper', '--gpg-auto-import-keys', 'up', '-ly'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in output.splitlines(): for line in output.splitlines():
if line.startswith("'%s' is already installed." % name): if line.startswith("'%s' is already installed." % name):
return False return False
...@@ -247,5 +251,6 @@ class Zypper: ...@@ -247,5 +251,6 @@ class Zypper:
def do_discover(): def do_discover():
package_manager = PackageManager() package_manager = PackageManager()
print "The signature for your current system is: %s" % package_manager.getOSSignature() print "The signature for your current system is: %s" % \
package_manager.getOSSignature()
...@@ -130,7 +130,6 @@ class testPackageManager(unittest.TestCase): ...@@ -130,7 +130,6 @@ class testPackageManager(unittest.TestCase):
return dummy_handler return dummy_handler
package_manager._getDistributionHandler = DummyCase package_manager._getDistributionHandler = DummyCase
self.assertEquals(package_manager._getDistributionHandler(), dummy_handler) self.assertEquals(package_manager._getDistributionHandler(), dummy_handler)
self.assertEquals(dummy_handler.called, []) self.assertEquals(dummy_handler.called, [])
return package_manager, dummy_handler return package_manager, dummy_handler
...@@ -150,7 +149,6 @@ class testPackageManager(unittest.TestCase): ...@@ -150,7 +149,6 @@ class testPackageManager(unittest.TestCase):
package_manager._addKey("http://...", "slapos") package_manager._addKey("http://...", "slapos")
self.assertEquals(handler.called, ["addKey"]) self.assertEquals(handler.called, ["addKey"])
def testUpdateRepositoryAPI(self): def testUpdateRepositoryAPI(self):
package_manager, handler = self._getPatchedPackageManagerForApiTest() package_manager, handler = self._getPatchedPackageManagerForApiTest()
package_manager._updateRepository() package_manager._updateRepository()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment