Skip to content

Commit

Permalink
Merge pull request easybuilders#72 from nudded/repository-get-buildstats
Browse files Browse the repository at this point in the history
Repository get buildstats
  • Loading branch information
itkovian committed Aug 10, 2012
2 parents fec0365 + 842870f commit da296a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
3 changes: 1 addition & 2 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import easybuild.tools.environment as env
from easybuild.tools.asyncprocess import Popen, PIPE, STDOUT, send_all, recv_some
from easybuild.tools.build_log import getLog
from easybuild.tools.config import logPath


log = getLog('fileTools')
Expand Down Expand Up @@ -93,7 +92,7 @@ def findBaseDir():
"""
def getLocalDirsPurged():
## e.g. always purge the log directory
ignoreDirs = [logPath()]
ignoreDirs = ["easybuild"]

lst = os.listdir(os.getcwd())
for ignDir in ignoreDirs:
Expand Down
28 changes: 26 additions & 2 deletions easybuild/tools/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import time

import easybuild
from easybuild.framework.easyblock import EasyBlock
from easybuild.tools.build_log import getLog


Expand Down Expand Up @@ -103,7 +104,13 @@ def cleanup(self):
"""
Clean up working copy.
"""
return
pass

def get_buildstats(self, name, version):
"""
Get the build statististics for module with name and version
"""
pass


class FileRepository(Repository):
Expand Down Expand Up @@ -153,7 +160,7 @@ def addEasyconfig(self, cfg, name, version, stats, previous):

# append a line to the eb file so we don't have git merge conflicts
if not previous:
statstemplate = "\n#Build statistics\nbuildstats=[%s]t\n"
statstemplate = "\n#Build statistics\nbuildstats=[%s]\n"
else:
statstemplate = "\nbuildstats.append(%s)\n"

Expand All @@ -165,6 +172,23 @@ def addEasyconfig(self, cfg, name, version, stats, previous):

return dest

def get_buildstats(self, name, version):
"""
return the build statistics
"""
full_path = os.path.join(self.wc, self.subdir, name)
if not os.path.isdir(full_path):
log.debug("module (%s) has not been found in the repo" % name)
return []

dest = os.path.join(full_path, "%s.eb" % version)
if not os.path.isfile(dest):
log.debug("version (%s) of module (%s) has not been found in the repo" % (version, name))
return []

eb = EasyBlock(dest)
return eb['buildstats']


class GitRepository(FileRepository):
"""
Expand Down

0 comments on commit da296a2

Please sign in to comment.