[Buildbot-commits] [Buildbot] #1758: hgbuildbot.py should always use ui.status and ui.warn for output

Buildbot nobody at buildbot.net
Mon Jan 10 20:20:30 UTC 2011


#1758: hgbuildbot.py should always use ui.status and ui.warn for output
------------------------+--------------------
Reporter:  mjw          |       Owner:  mjw
    Type:  enhancement  |      Status:  new
Priority:  major        |   Milestone:  0.8.4
 Version:  0.8.3p1      |  Resolution:
Keywords:  hg           |
------------------------+--------------------

Comment (by mjw):

 I was thinking of something like the following:

 diff --git a/master/buildbot/changes/hgbuildbot.py
 b/master/buildbot/changes/hgbuildbot.py
 index 86173ca..5a577e0 100644
 --- a/master/buildbot/changes/hgbuildbot.py
 +++ b/master/buildbot/changes/hgbuildbot.py
 @@ -53,7 +53,7 @@
  #                                        # change:changepw, which is also
  #                                        # the default of PBChangeSource.

 -import os
 +import os, StringIO

  from mercurial.node import bin, hex, nullid #@UnresolvedImport
  from mercurial.context import workingctx #@UnresolvedImport
 @@ -153,6 +153,18 @@ def hook(ui, repo, hooktype, node=None, source=None,
 **kwargs):
          }
          d.addCallback(_send, change)

 +    def _printSuccess(res):
 +        output = StringIO.StringIO()
 +        s.printSuccess(res, output=output)
 +        ui.status(output.getvalue())
 +        output.close()
 +
 +    def _printFailure(why):
 +        output = StringIO.StringIO()
 +        s.printSuccess(why, output=output)
 +        ui.warn(output.getvalue())
 +        output.close()
 +
      d.addCallbacks(s.printSuccess, s.printFailure)
      d.addBoth(s.stop)
      s.run()
 diff --git a/master/buildbot/clients/sendchange.py
 b/master/buildbot/clients/sendchange.py
 index b66687b..810a653 100644
 --- a/master/buildbot/clients/sendchange.py
 +++ b/master/buildbot/clients/sendchange.py
 @@ -14,6 +14,7 @@
  # Copyright Buildbot Team Members


 +import sys
  from twisted.spread import pb
  from twisted.cred import credentials
  from twisted.internet import reactor
 @@ -44,17 +45,17 @@ class Sender:
          d.addCallback(lambda res:
 remote.broker.transport.loseConnection())
          return d

 -    def printSuccess(self, res):
 +    def printSuccess(self, res, output=sys.stdout):
          if self.num_changes > 1:
 -            print "%d changes sent successfully" % self.num_changes
 +            print >> output, "%d changes sent successfully" %
 self.num_changes
          elif self.num_changes == 1:
 -            print "change sent successfully"
 +            print >> output, "change sent successfully"
          else:
 -            print "no changes to send"
 +            print >> output, "no changes to send"

 -    def printFailure(self, why):
 -        print "change(s) NOT sent, something went wrong:"
 -        print why
 +    def printFailure(self, why, output=sys.stderr):
 +        print >> output, "change(s) NOT sent, something went wrong:"
 +        print >> output, why

      def stop(self, res):
          reactor.stop()

-- 
Ticket URL: <http://trac.buildbot.net/ticket/1758#comment:1>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation


More information about the Commits mailing list