Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 12502 → Rev 12512

/tools/mrscribe/Svnwatch/plugin.py
35,17 → 35,18
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.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.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)
self.getCommit(irc)
 
def canGetNewCommit(self, irc):
74,6 → 75,9
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)
92,7 → 96,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
103,21 → 107,39
self.resultcommitdata = svnxmlparser.getCommit(self.rawxml)
self.log.debug("Fetched data %s" % self.resultcommitdata)
self.shortdata = svnxmlparser.shortoutput(self.resultcommitdata)
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.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.now = time.time()
self.lastfetch = self.now
conf.supybot.plugins.Svnwatch.lastRevision.setValue(self.lastrev)
/tools/mrscribe/Svnwatch/__init__.py
40,9 → 40,7
 
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,11 → 30,8
# 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:
134,10 → 131,11
import sys
fullpath = logentry['common_path']
pathelements = fullpath.split("/")
print pathelements
if pathelements[1] == 'trunk':
return 'trunk'
else:
return "%s" % pathelements[2]
return "%s" % "/".join(pathelements)
 
def shortoutput(commitdata):
outlist = []
196,7 → 194,8
args = ['HEAD']
for i in args:
print "Fetching commit information for '%s':" % i
xml = fetchXml(URI,i)
uri = args[1]
xml = fetchXml(uri,i)
commitdata = getCommit(xml)
if commitdata == None:
sys.exit()
/tools/mrscribe/Svnwatch/config.py
18,7 → 18,6
 
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
27,33 → 26,32
# registry as appropriate.
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('Svnwatch', True)
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)
# 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)
 
#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, 'xmluri',
registry.String('',
"""The uri for the exported SVN XML source."""))
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, 'fetchPeriod',
registry.PositiveInteger(60, """Indicates how many seconds the
bot will wait between retrieving new svn commit
information."""))
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."""))
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: