From d585ebc96c291d29ba9dc01e458398c288ac1bdb Mon Sep 17 00:00:00 2001 From: Vito Giuliani Date: Fri, 30 May 2014 23:46:42 +0200 Subject: Pass the result of the function call as an argument in place of a callable --- gcimagebundle/gcimagebundlelib/fs_copy.py | 4 +++- gcimagebundle/gcimagebundlelib/manifest.py | 6 +++--- gcimagebundle/gcimagebundlelib/tests/block_disk_test.py | 2 +- gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gcimagebundle/gcimagebundlelib/fs_copy.py b/gcimagebundle/gcimagebundlelib/fs_copy.py index 8989539..9924414 100644 --- a/gcimagebundle/gcimagebundlelib/fs_copy.py +++ b/gcimagebundle/gcimagebundlelib/fs_copy.py @@ -22,6 +22,7 @@ import os import re from gcimagebundlelib import manifest +from gcimagebundlelib import utils class FsCopyError(Exception): @@ -48,7 +49,8 @@ class FsCopy(object): self._overwrite_list = [] self._scratch_dir = '/tmp' self._disk = None - self._manifest = manifest.ImageManifest() + is_running_on_gce = utils.IsRunningOnGCE() + self._manifest = manifest.ImageManifest(is_running_on_gce) def SetTarfile(self, tar_file): """Sets tar file which will contain file system copy. diff --git a/gcimagebundle/gcimagebundlelib/manifest.py b/gcimagebundle/gcimagebundlelib/manifest.py index cc7dc2c..df16741 100755 --- a/gcimagebundle/gcimagebundlelib/manifest.py +++ b/gcimagebundle/gcimagebundlelib/manifest.py @@ -29,10 +29,10 @@ class ImageManifest(object): - Licenses """ - def __init__(self, http=utils.Http(), isProviderGCE=utils.IsRunningOnGCE): + def __init__(self, isGceInstance, http=utils.Http()): self._http = http self._licenses = [] - self._isProviderGCE = isProviderGCE + self._is_gce_instance = isGceInstance def CreateIfNeeded(self, file_path): """Creates the manifest file to the specified path if it's needed. @@ -44,7 +44,7 @@ class ImageManifest(object): True Manifest was written to file_path. False Manifest was not created. """ - if self._isProviderGCE(): + if self._is_gce_instance: self._LoadLicenses() if self._IsManifestNeeded(): with open(file_path, 'w') as manifest_file: diff --git a/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py b/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py index 692e915..1f7f994 100755 --- a/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py +++ b/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py @@ -285,7 +285,7 @@ class FsRawDiskTest(image_bundle_test_base.ImageBundleTest): self._http = MockHttp() self._manifest._http = self._http - self._manifest._isProviderGCE = lambda: False + self._manifest._is_gce_instance = False self._bundle.AddSource(self.tmp_path) self._bundle.Verify() diff --git a/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py b/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py index bbc6eb0..272a760 100755 --- a/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py +++ b/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py @@ -87,7 +87,7 @@ class ImageBundleTest(unittest.TestCase): self.tmp_root = tempfile.mkdtemp(dir='/tmp') self.tmp_path = tempfile.mkdtemp(dir=self.tmp_root) self._http = MockHttp() - self._manifest = manifest.ImageManifest(http=self._http, isProviderGCE=lambda: True) + self._manifest = manifest.ImageManifest(True, http=self._http) self._SetupFilesystemToTar() def tearDown(self): -- cgit v1.2.1