Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
status at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Groszer committed Jun 15, 2010
1 parent a8246a8 commit 1d109dd
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 9 deletions.
12 changes: 11 additions & 1 deletion src/zope/wineggbuilder/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Let's see:

>>> import os.path
>>> testininame = os.path.join(os.path.dirname(build.__file__), 'test.ini')
>>> build.main([testininame, '-v']) # doctest: +REPORT_NDIFF
>>> build.main([testininame, '-v', '-s']) # doctest: +REPORT_NDIFF
INFO - loading configuration from ...zope.wineggbuilder\trunk\src\zope\wineggbuilder\test.ini
INFO - Starting to build
DEBUG - getting http://pypi.python.org/simple/zope.proxy/
Expand Down Expand Up @@ -267,6 +267,16 @@ Let's see:
DEBUG - Checking if build required for [zope.proxy_34_to_35] zope.proxy 3.4.2 py26_32
DEBUG - Build not required for [zope.proxy_34_to_35] zope.proxy 3.4.2 py26_32
INFO - Done.
INFO -
<BLANKLINE>
zope.proxy py25_32 py24_32 py26_32 py26_64
==================== ========== ========== ========== ==========
3.3.0 n/a n/a n/a n/a
3.4.0 ex n/a done n/a
3.4.1 done n/a n/a n/a
3.4.2 ex n/a ex n/a
3.5.0 n/a n/a n/a n/a
3.6.0 n/a n/a n/a n/a

Let's see what was executed on mocks:

Expand Down
5 changes: 5 additions & 0 deletions src/zope/wineggbuilder/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ def rmtree(dirname):
"-d", "--dryrun", action="store_true",
dest="dryrun", default=False,
help="When specified, no upload is done.")

parser.add_option(
"-s", "--status", action="store_true",
dest="status", default=False,
help="When specified, detailed status is output at the end.")
74 changes: 66 additions & 8 deletions src/zope/wineggbuilder/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def checkBuild(self, package, version, files):
package.sectionName, package.name, version, self.name)
return needBuild

def build(self, package, version, files, sourceFolder):
def build(self, package, version, files, sourceFolder, status):
LOGGER.info('Starting build for [%s] %s %s %s',
package.sectionName, package.name, version, self.name)
#we really need to build
Expand Down Expand Up @@ -97,12 +97,14 @@ def build(self, package, version, files, sourceFolder):
and 'Server response (200): OK' in output:
LOGGER.info("Upload seems to be OK.\n%s",
'\n'.join(output.splitlines()[-3:]))
status.setStatus(package, version, "done", self)
except KeyboardInterrupt:
raise
except:
#prepare for the worst
LOGGER.exception("An error occurred while running the build command")
#continue without bailing out
status.setStatus(package, version, "err", self)

if tmpfile:
os.remove(tmpfile)
Expand Down Expand Up @@ -145,11 +147,13 @@ def read(self, sectionName, config, compilers):
for target in config.get(sectionName, 'targets').split():
self.targets.append(compilers[target])

def build(self):
def build(self, status):
#1 get versions from pypi
pypi = self.pypiKlass()
versions = pypi.package_releases(self.name, show_hidden=True)

status.setVersions(self, versions)

#1.1 filter versions according to minVersion and maxVersion:
if self.minVersion:
minver = versionToTuple(self.minVersion)
Expand Down Expand Up @@ -185,7 +189,7 @@ def build(self):
LOGGER.debug('Got a file: %s', cntnt)
verFiles[version].append(cntnt)

svn = self.svnKlass()
svn = self.svnKlass(exitOnError=False)
for version in versions:
#3 check whether we need a build
needs = []
Expand All @@ -194,22 +198,72 @@ def build(self):
self, version, verFiles.get(version, []))
if needBuild:
needs.append(target)
else:
status.setStatus(self, version, "ex", target)

if needs:
tmpfolder = tempfile.mkdtemp('wineggbuilder')
try:
#3.1 svn co tag
svnurl = "%s/%s" % (self.tagurl, version)
svn.co(svnurl, tmpfolder)
try:
#3.1 svn co tag
svnurl = "%s/%s" % (self.tagurl, version)
svn.co(svnurl, tmpfolder)
except OSError:
status.setStatus(self, version, "SVN error")

#3.2 build missing
for target in needs:
needBuild = target.build(
self, version, verFiles.get(version, []), tmpfolder)
self, version, verFiles.get(version, []),
tmpfolder, status)
finally:
#3.3 del temp folder
base.rmtree(tmpfolder)

class Status(object):
def __init__(self, packages, targets):
self.data = {}
self.packages = packages
self.targets = targets

for p in packages:
self.data[p.name] = {}

def setVersions(self, package, versions):
for v in versions:
self.data[package.name][v]= {}
for t in self.targets:
self.data[package.name][v][t] = 'n/a'

def setStatus(self, package, version, status, target=None):
if target is None:
# this is a version general status
self.data[package.name][version] = status
else:
self.data[package.name][version][target.name] = status

def log(self):
text = ['\n']
for pname in sorted(self.data.keys()):
package = self.data[pname]
vs = ' '.join([target.ljust(10) for target in self.targets])
txt = "%s %s" % (pname.ljust(20), vs)
text.append(txt)
vs = ' '.join(['='*10 for target in self.targets])
txt = "%s %s" % ('='*20, vs)
text.append(txt)
for vname in sorted(package.keys()):
version = package[vname]
if isinstance(version, basestring):
txt = "%20s %s" % (vname, version)
else:
vs = ' '.join([version[target].ljust(10) for target in self.targets])
txt = "%20s %s" % (vname, vs)
text.append(txt)
output = '\n'.join(text)
LOGGER.info(output)


class Builder(object):
def __init__(self, configFileName, options):
LOGGER.info('loading configuration from %s', configFileName)
Expand All @@ -234,9 +288,11 @@ def __init__(self, configFileName, options):
def runCLI(self):
LOGGER.info('Starting to build')

status = Status(self.packages, self.compilers)

for pkg in self.packages:
try:
pkg.build()
pkg.build(status)
except KeyboardInterrupt:
raise
except:
Expand All @@ -247,6 +303,8 @@ def runCLI(self):

LOGGER.info('Done.')

status.log()


def main(args=None):
# Make sure we get the arguments.
Expand Down

0 comments on commit 1d109dd

Please sign in to comment.