Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 12512 → Rev 12502

/tools/mrscribe/Svnwatch/config.py
18,6 → 18,7
 
import supybot.conf as conf
import supybot.registry as registry
import supybot.callbacks as callbacks
 
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
26,32 → 27,33
# registry as appropriate.
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('Svnwatch', True)
# output('The default SVN xml URI is https://www.postnewspapers.com.au/cgi-bin/xmllog')
# if yn('Would you like to specify a SVN xml URI?'):
# xmluri = something('SVN XML URI?')
# conf.supybot.plugins.Svnwatch.set(xmluri)
output('The default SVN xml URI is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
if yn('Would you like to specify a SVN xml URI?'):
xmluri = something('SVN XML URI?')
conf.supybot.plugins.Svnwatch.set(xmluri)
 
#class PostChannels(registry.SpaceSeparated):
# List = callbacks.CanonicalNameSet
 
Svnwatch = conf.registerPlugin('Svnwatch')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Svnwatch, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName."""))
conf.registerGlobalValue(Svnwatch, 'batchSize', registry.PositiveInteger(3,
"""Determines the upper limit on the number of reports that will be output
at a time."""))
#conf.registerGlobalValue(Svnwatch, 'xmluri',
# registry.String("https://www.postnewspapers.com.au/cgi-bin/xmllog",
# """The uri for the exported SVN XML source."""))
conf.registerGlobalValue(Svnwatch, 'xmluri',
registry.String('',
"""The uri for the exported SVN XML source."""))
conf.registerGlobalValue(Svnwatch, 'fetchPeriod',
registry.PositiveInteger(60, """Indicates how many seconds the bot will
wait between retrieving new svn commit information."""))
conf.registerGlobalValue(Svnwatch, 'channels', conf.SpaceSeparatedSetOfChannels([],
"""Determines which channels the bot will post SVN commit information
to."""))
registry.PositiveInteger(60, """Indicates how many seconds the
bot will wait between retrieving new svn commit
information."""))
conf.registerGlobalValue(Svnwatch, 'lastRevision',
registry.PositiveInteger(1000, """Indicates the last revision published in
the channels."""))
the channels."""))
conf.registerGlobalValue(Svnwatch, 'postFrequency', registry.PositiveInteger(5,
"""Indicates how many seconds the bot will wait between posting svn commit
information messages."""))
conf.registerGlobalValue(Svnwatch,
'channels', conf.SpaceSeparatedSetOfChannels([], """Determines
which channels the bot will post SVN commit information to."""))
 
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
/tools/mrscribe/Svnwatch/plugin.py
35,18 → 35,17
def __init__(self, irc):
self.__parent = super(Svnwatch, self)
self.__parent.__init__(irc)
# try:
self.xmluri = self.registryValue('xmluri')
self.wait = self.registryValue('fetchPeriod')
self.postfrequency = self.registryValue('postFrequency')
# self.batchsize = self.registryValue('batchSize')
self.channels = self.registryValue('channels')
self.lastrev = self.registryValue('lastRevision')
self.lastfetch = time.time() - self.wait - 1
self.log.debug("%s; %s, %s, %s, %s" % (self.xmluri, self.wait, self.postfrequency, self.channels, self.lastrev))
# except registry.NonExistentRegistryEntry:
# self.log.debug('%s is not a registered URI.', self.xmluri)
# irc.error('Can\'t get configuration variables.', Raise=True)
try:
self.xmluri = self.registryValue('xmluri')
self.wait = self.registryValue('fetchPeriod')
self.postfrequency = self.registryValue('postFrequency')
self.channels = self.registryValue('channels')
self.lastrev = self.registryValue('lastRevision')
self.lastfetch = time.time() - self.wait - 1
self.log.debug("%s; %s, %s, %s, %s" % (self.xmluri, self.wait, self.postfrequency, self.channels, self.lastrev))
except registry.NonExistentRegistryEntry:
self.log.debug('%s is not a registered URI.', self.xmluri)
irc.error('Can\'t get configuration variables.', Raise=True)
self.getCommit(irc)
 
def canGetNewCommit(self, irc):
75,9 → 74,6
else:
return self.commitdata.keys()[0]
 
def printData(self, irc, data, channel):
irc.reply(data, to=channel, prefixNick=False, private=True)
 
def getCommit(self, irc):
self.channels = self.registryValue('channels')
self.log.debug("Reporting channels: %s", self.channels)
96,7 → 92,7
self.log.debug("Fetched 'HEAD' - no new commmits at %s", self.xmluri)
self.now = time.time()
self.lastfetch = self.now
# self.log.debug("Fetched new 'HEAD' revision at %s" % (self.now))
self.log.debug("Fetched new 'HEAD' revision at %s" % (self.now))
else:
self.oldestnewrev = self.lastrev + 1
self.revid = "%s:HEAD" % self.oldestnewrev
107,39 → 103,21
self.resultcommitdata = svnxmlparser.getCommit(self.rawxml)
self.log.debug("Fetched data %s" % self.resultcommitdata)
self.shortdata = svnxmlparser.shortoutput(self.resultcommitdata)
self.log.debug("Data list: %s" % self.shortdata)
batch = self.shortdata[:5]
# self.lastrev = self.batch[-1]
self.log.debug("Revision #: %s" % self.lastrev)
for revisiondata in batch:
self.log.debug("Revision data: %s" % revisiondata)
self.lastrev = int(revisiondata.split(" ")[1])
self.log.debug("Processed revision #%s" % self.lastrev)
self.log.debug("Revision data: %s" % revisiondata)
for channel in self.channels:
self.printData(irc, revisiondata, channel)
# irc.replies(self.revisiondata, joiner='', to=self.channel, prefixNick=False, private=True)
# irc.reply(self.revisiondata, to=self.channel, prefixNick=False, private=True)
# if len(self.shortdata) == 1:
# self.revisiondata = " ".join(self.shortdata)
# self.log.debug("Formatted data: %s" % self.revisiondata)
# self.lastrev = int(self.revisiondata.split(" ")[1])
# self.log.debug("Revision ID: %s" % self.lastrev)
# for self.channel in self.channels:
# irc.reply(self.revisiondata, joiner='', to=self.channel, prefixNick=False, private=True)
# else:
# self.log.debug("Multiple data sets detected")
# for self.revisiondata in self.shortdata:
# self.log.debug("Revision data: %s" % self.revisiondata)
# self.lastrev = int(self.revisiondata.split(" ")[1])
# self.log.debug("Last revision ID: %s" % self.lastrev)
# for self.channel in self.channels:
# self.log.debug("Sleeping in channels for %i sec." % self.postfrequency)
# self.log.debug("Revision data: %s" % self.revisiondata)
# irc.replies(self.revisiondata, joiner='', to=self.channel, prefixNick=False, private=True)
# irc.reply(self.revisiondata, to=self.channel, prefixNick=False, private=True)
# self.log.debug("Sleeping in data cycles for %i sec." % self.postfrequency) (self.postfrequency)
# sleep(self.postfrequency)
self.log.debug("Short data: %s" % self.shortdata)
if len(self.shortdata) == 1:
self.revisiondata = " ".join(self.shortdata)
self.log.debug("Formatted data: %s" % self.revisiondata)
self.lastrev = int(self.revisiondata.split(" ")[1])
self.log.debug("Revision ID: %s" % self.lastrev)
for self.channel in self.channels:
irc.replies(self.revisiondata, joiner='', to=self.channel, prefixNick=False, private=True)
else:
for self.revisiondata in self.shortdata:
self.log.debug("Revision data: %s" % self.revisiondata)
self.lastrev = int(self.revisiondata.split(" ")[1])
self.log.debug("Last revision ID: %s" % self.lastrev)
for self.channel in self.channels:
irc.replies(self.revisiondata, joiner='', to=self.channel, prefixNick=False, private=True)
self.now = time.time()
self.lastfetch = self.now
conf.supybot.plugins.Svnwatch.lastRevision.setValue(self.lastrev)
/tools/mrscribe/Svnwatch/__init__.py
40,7 → 40,9
 
import config
import plugin
import svnxmlparser
reload(plugin) # In case we're being reloaded.
reload(svnxmlparser) # In case we're being reloaded
# Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well!
 
/tools/mrscribe/Svnwatch/svnxmlparser.py
30,8 → 30,11
# want to send an Accept header, set this to None.
ACCEPT_HEADER = "text/xml"
 
# Default URI:
URI = "https://www.postnewspapers.com.au/cgi-bin/xmllog"
 
def fetchXml(uri, rev):
"""Fetches a document from the given uri (with gzip encoding). Returns the
"""Fetches a document from the given URI (with gzip encoding). Returns the
document as a string, or an empty string in case of a transmission problem."""
import urllib2, gzip, StringIO
try:
131,11 → 134,10
import sys
fullpath = logentry['common_path']
pathelements = fullpath.split("/")
print pathelements
if pathelements[1] == 'trunk':
return 'trunk'
else:
return "%s" % "/".join(pathelements)
return "%s" % pathelements[2]
 
def shortoutput(commitdata):
outlist = []
194,8 → 196,7
args = ['HEAD']
for i in args:
print "Fetching commit information for '%s':" % i
uri = args[1]
xml = fetchXml(uri,i)
xml = fetchXml(URI,i)
commitdata = getCommit(xml)
if commitdata == None:
sys.exit()