arch_buildbot.py :  » Build » Buildbot » buildbot-0.8.0 » contrib » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Build » Buildbot 
Buildbot » buildbot 0.8.0 » contrib » arch_buildbot.py
#! /usr/bin/python

# this script is meant to run as an Arch post-commit hook (and also as a
# pre-commit hook), using the "arch-meta-hook" framework. See
# http://wiki.gnuarch.org/NdimMetaHook for details. The pre-commit hook
# creates a list of files (and log comments), while the post-commit hook
# actually notifies the buildmaster.

# this script doesn't handle partial commits quite right: it will tell the
# buildmaster that everything changed, not just the filenames you give to
# 'tla commit'.

import os
import commands
import cStringIO

from buildbot.scripts import runner

# Just modify the appropriate values below and then put this file in two
# places: ~/.arch-params/hooks/ARCHIVE/=precommit/90buildbot.py and
# ~/.arch-params/hooks/ARCHIVE/=commit/10buildbot.py

master = "localhost:9989"
username = "myloginname"

# Remember that for this to work, your buildmaster's master.cfg needs to have
# a c['change_source'] list which includes a pb.PBChangeSource instance.

os.chdir(os.getenv("ARCH_TREE_ROOT"))
filelist = ",,bb-files"
commentfile = ",,bb-comments"

if os.getenv("ARCH_HOOK_ACTION") == "precommit":
    files = []
    out = commands.getoutput("tla changes")
    for line in cStringIO.StringIO(out).readlines():
        if line[0] in "AMD": # add, modify, delete
            files.append(line[3:])
    if files:
        f = open(filelist, "w")
        f.write("".join(files))
        f.close()
    # comments
    logfiles = [f for f in os.listdir(".") if f.startswith("++log.")]
    if len(logfiles) > 1:
        print ("Warning, multiple ++log.* files found, getting comments "
               "from the first one")
    if logfiles:
        open(commentfile, "w").write(open(logfiles[0], "r").read())

elif os.getenv("ARCH_HOOK_ACTION") == "commit":
    revision = os.getenv("ARCH_REVISION")

    files = []
    if os.path.exists(filelist):
        f = open(filelist, "r")
        for line in f.readlines():
            files.append(line.rstrip())
    if not files:
        # buildbot insists upon having at least one modified file (otherwise
        # the prefix-stripping mechanism will ignore the change)
        files = ["dummy"]

    if os.path.exists(commentfile):
        comments = open(commentfile, "r").read()
    else:
        comments = "commit from arch"

    c = {'master': master, 'username': username,
         'revision': revision, 'comments': comments, 'files': files}
    runner.sendchange(c, True)

    if os.path.exists(filelist):
        os.unlink(filelist)
    if os.path.exists(commentfile):
        os.unlink(commentfile)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.