pb.py :  » Build » Buildbot » buildbot-0.8.0 » buildbot » changes » 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 » buildbot » changes » pb.py
# -*- test-case-name: buildbot.test.test_changes -*-

from twisted.python import log

from buildbot.pbutil import NewCredPerspective
from buildbot.changes import base,changes

class ChangePerspective(NewCredPerspective):

    def __init__(self, changemaster, prefix):
        self.changemaster = changemaster
        self.prefix = prefix

    def attached(self, mind):
        return self
    def detached(self, mind):
        pass

    def perspective_addChange(self, changedict):
        log.msg("perspective_addChange called")
        pathnames = []
        for path in changedict['files']:
            if self.prefix:
                if not path.startswith(self.prefix):
                    # this file does not start with the prefix, so ignore it
                    continue
                path = path[len(self.prefix):]
            pathnames.append(path)

        if pathnames:
            change = changes.Change(who=changedict['who'],
                                    files=pathnames,
                                    comments=changedict['comments'],
                                    branch=changedict.get('branch'),
                                    revision=changedict.get('revision'),
                                    revlink=changedict.get('revlink', ''),
                                    category=changedict.get('category'),
                                    when=changedict.get('when'),
                                    properties=changedict.get('properties', {}),
                                    repository=changedict.get('repository', '') or '',
                                    project=changedict.get('project', '') or '',
                                    )
            self.changemaster.addChange(change)

class PBChangeSource(base.ChangeSource):
    compare_attrs = ["user", "passwd", "port", "prefix"]

    def __init__(self, user="change", passwd="changepw", port=None,
                 prefix=None, sep=None):
        """I listen on a TCP port for Changes from 'buildbot sendchange'.

        I am a ChangeSource which will accept Changes from a remote source. I
        share a TCP listening port with the buildslaves.

        The 'buildbot sendchange' command, the contrib/svn_buildbot.py tool,
        and the contrib/bzr_buildbot.py tool know how to send changes to me.

        @type prefix: string (or None)
        @param prefix: if set, I will ignore any filenames that do not start
                       with this string. Moreover I will remove this string
                       from all filenames before creating the Change object
                       and delivering it to the Schedulers. This is useful
                       for changes coming from version control systems that
                       represent branches as parent directories within the
                       repository (like SVN and Perforce). Use a prefix of
                       'trunk/' or 'project/branches/foobranch/' to only
                       follow one branch and to get correct tree-relative
                       filenames.

        @param sep: DEPRECATED (with an axe). sep= was removed in
                    buildbot-0.7.4 . Instead of using it, you should use
                    prefix= with a trailing directory separator. This
                    docstring (and the better-than-nothing error message
                    which occurs when you use it) will be removed in 0.7.5 .
        """

        # sep= was removed in 0.7.4 . This more-helpful-than-nothing error
        # message will be removed in 0.7.5 .
        assert sep is None, "prefix= is now a complete string, do not use sep="
        # TODO: current limitations
        assert user == "change"
        assert passwd == "changepw"
        assert port == None
        self.user = user
        self.passwd = passwd
        self.port = port
        self.prefix = prefix

    def describe(self):
        # TODO: when the dispatcher is fixed, report the specific port
        #d = "PB listener on port %d" % self.port
        d = "PBChangeSource listener on all-purpose slaveport"
        if self.prefix is not None:
            d += " (prefix '%s')" % self.prefix
        return d

    def startService(self):
        base.ChangeSource.startService(self)
        # our parent is the ChangeMaster object
        # find the master's Dispatch object and register our username
        # TODO: the passwd should be registered here too
        master = self.parent.parent
        master.dispatcher.register(self.user, self)

    def stopService(self):
        base.ChangeSource.stopService(self)
        # unregister our username
        master = self.parent.parent
        master.dispatcher.unregister(self.user)

    def getPerspective(self):
        return ChangePerspective(self.parent, self.prefix)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.