Commit 6f60a5eb authored by Jérome Perrin's avatar Jérome Perrin

fixup! Introduce an InstallMonitor

Monitor together all buildout using the cache

Store the git database in a place that will be ignored by other
buildouts
parent 2731aa6e
......@@ -60,15 +60,16 @@ class GitInstallMonitor(object):
"""
def __init__(self, buildout):
self._buildout = buildout
self._logger = logging.getLogger('zc.buildout.installmonitor')
self._logger = logging.getLogger('slapos.buildout.installmonitor')
self._start_install_time = {}
def _record_changes(self, message):
start = time.time()
self._logger.debug("Adding %s to git, this may take some time", self._work_tree)
if self._git("status", "--porcelain"):
self._git("add", self._work_tree)
self._git("commit", "-m", message)
self._logger.debug("Added %s to git", self._work_tree)
self._logger.debug("Added %s to git in %.2f seconds", self._work_tree, time.time() - start)
else:
self._logger.info("No changes to record")
......@@ -97,8 +98,8 @@ class GitInstallMonitor(object):
self._buildout['buildout']['slapos-recipe-cmmi-shared-path'],
)))
self._git_dir = os.path.join(
self._buildout['buildout']['directory'],
'slapos.gitinstallmonitor.git'
self._work_tree,
'slapos.buildout.installmonitor.git'
)
self._git("init")
......@@ -110,9 +111,13 @@ class GitInstallMonitor(object):
# ignore git dir ( as a path relative to work tree )
with open(os.path.join(self._git_dir, 'info', 'exclude'), 'w') as gitignore:
gitignore.write(self._git_dir[len(self._work_tree):])
gitignore.write('slapos.buildout.installmonitor.git')
software_release = os.path.basename(
self._buildout['buildout']['directory'])
self._record_changes("Begin install with args {install_args}".format(**locals()))
self._record_changes(
"Begin install {software_release} with args {install_args}".format(**locals()))
def end_install(self):
took = time.time() - self._start_install_time[self]
......
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