summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-07-31 14:51:52 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-08-01 13:19:12 +0000
commitf968ecadfd972c6d032a519259cfa43dec020eac (patch)
treee99acdba01188bcada20dd493fd8aa0bd52cb065 /morphlib/app.py
parenta24f546197206774f846d4135285f7a918127475 (diff)
downloadmorph-f968ecadfd972c6d032a519259cfa43dec020eac.tar.gz
Move utility functions for creating caches
Code for creating caches is repeated through the codebase because there wasn't a useful function for creating caches. Now the functions in BuildCommand have been moved into morphlib.util, where they will be more usefully reachable. Stubs have been left in BuildCommand so they can be overridden by subclasses of BuildCommand and not break external plugins.
Diffstat (limited to 'morphlib/app.py')
-rwxr-xr-xmorphlib/app.py47
1 files changed, 4 insertions, 43 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 45db9bfa..e2460f68 100755
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -94,55 +94,16 @@ class BuildCommand(object):
return morphlib.cachekeycomputer.CacheKeyComputer(build_env)
def new_artifact_caches(self):
- '''Create new objects for local, remote artifact caches.'''
-
- self.create_cachedir()
- artifact_cachedir = self.create_artifact_cachedir()
-
- lac = morphlib.localartifactcache.LocalArtifactCache(artifact_cachedir)
-
- rac_url = self.app.settings['cache-server']
- if rac_url:
- rac = morphlib.remoteartifactcache.RemoteArtifactCache(rac_url)
- else:
- rac = None
- return lac, rac
+ return morphlib.util.new_artifact_caches(self.app.settings)
def create_artifact_cachedir(self):
- '''Create a new directory for the local artifact cache.'''
-
- artifact_cachedir = os.path.join(
- self.app.settings['cachedir'], 'artifacts')
- if not os.path.exists(artifact_cachedir):
- os.mkdir(artifact_cachedir)
- return artifact_cachedir
+ return morphlib.util.create_artifact_cachedir(self.app.settings)
def new_repo_caches(self):
- '''Create new objects for local, remote git repository caches.'''
-
- aliases = self.app.settings['repo-alias']
- cachedir = self.create_cachedir()
- gits_dir = os.path.join(cachedir, 'gits')
- bundle_base_url = self.app.settings['bundle-server']
- repo_resolver = morphlib.repoaliasresolver.RepoAliasResolver(aliases)
- lrc = morphlib.localrepocache.LocalRepoCache(
- self.app, gits_dir, repo_resolver, bundle_base_url=bundle_base_url)
-
- url = self.app.settings['cache-server']
- if url:
- rrc = morphlib.remoterepocache.RemoteRepoCache(url, repo_resolver)
- else:
- rrc = None
-
- return lrc, rrc
+ return morphlib.util.new_repo_caches(self.app)
def create_cachedir(self):
- '''Create a new cache directory.'''
-
- cachedir = self.app.settings['cachedir']
- if not os.path.exists(cachedir):
- os.mkdir(cachedir)
- return cachedir
+ return morphlib.util.create_cachedir(self.app.settings)
def compute_build_order(self, repo_name, ref, filename):
'''Compute build order for a triplet.'''