[gnome-ostree] qa/supybot: New IRC bot plugin
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree] qa/supybot: New IRC bot plugin
- Date: Wed, 24 Oct 2012 23:45:38 +0000 (UTC)
commit b58ec7711cbce9753ddc68f043f3703d90ec1883
Author: Colin Walters <walters verbum org>
Date: Wed Oct 24 19:44:31 2012 -0400
qa/supybot: New IRC bot plugin
qa/supybot/GNOMEOSTree/__init__.py | 11 ++++
qa/supybot/GNOMEOSTree/config.py | 7 +++
qa/supybot/GNOMEOSTree/plugin.py | 90 ++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+), 0 deletions(-)
---
diff --git a/qa/supybot/GNOMEOSTree/__init__.py b/qa/supybot/GNOMEOSTree/__init__.py
new file mode 100644
index 0000000..a621e01
--- /dev/null
+++ b/qa/supybot/GNOMEOSTree/__init__.py
@@ -0,0 +1,11 @@
+import supybot
+import supybot.world as world
+
+__version__ = "0"
+
+import config
+import plugin
+reload(plugin)
+
+Class = plugin.Class
+configure = config.configure
diff --git a/qa/supybot/GNOMEOSTree/config.py b/qa/supybot/GNOMEOSTree/config.py
new file mode 100644
index 0000000..56c87e6
--- /dev/null
+++ b/qa/supybot/GNOMEOSTree/config.py
@@ -0,0 +1,7 @@
+import supybot.conf as conf
+import supybot.registry as registry
+
+def configure(advanced):
+ conf.registerPlugin('GNOMEOSTree', True)
+
+GNOMEOSTree = conf.registerPlugin('GNOMEOSTree')
diff --git a/qa/supybot/GNOMEOSTree/plugin.py b/qa/supybot/GNOMEOSTree/plugin.py
new file mode 100644
index 0000000..211745c
--- /dev/null
+++ b/qa/supybot/GNOMEOSTree/plugin.py
@@ -0,0 +1,90 @@
+###
+# Copyright (c) 2003-2004, Jeremiah Fincher
+# Copyright (c) 2012 Colin Walters <walters verbum org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions, and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions, and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the author of this software nor the name of
+# contributors to this software may be used to endorse or promote products
+# derived from this software without specific prior written consent.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+###
+
+import time
+import os
+import shutil
+import tempfile
+import json
+
+import supybot.ircdb as ircdb
+import supybot.ircmsgs as ircmsgs
+import supybot.ircutils as ircutils
+import supybot.conf as conf
+import supybot.utils as utils
+from supybot.commands import *
+import supybot.schedule as schedule
+import supybot.callbacks as callbacks
+import supybot.world as world
+
+class GNOMEOSTree(callbacks.Plugin):
+ def __init__(self, irc):
+ self.__parent = super(GNOMEOSTree, self)
+ self.__parent.__init__(irc)
+ schedule.addPeriodicEvent(self._query_new_build, 1, now=False)
+ self._irc = irc
+ self._last_version = None
+
+ def _broadcast(self, msg):
+ for channel in self._irc.state.channels:
+ self._irc.queueMsg(ircmsgs.privmsg(channel, msg))
+
+ def _query_new_build(self, announce=False):
+ path = os.path.expanduser('~/ostbuild/work/autobuilder-default.json')
+ f = open(path)
+ data = json.load(f)
+ f.close()
+
+ builds = data['build']
+ if len(builds) == 0:
+ if announce:
+ self._broadcast("No builds")
+ return
+ latest = builds[-1]
+ version = latest['meta']['version']
+ if (not announce and version == self._last_version):
+ return
+
+ self._last_version = version
+ msg = "New build %s: %s" % (version, latest['state'])
+ diff = latest['diff']
+ if len(diff[0]) > 0:
+ msg += " added: %r" % (diff[0], )
+ if len(diff[1]) > 0:
+ msg += " modified: %r" % (diff[1], )
+ if len(diff[2]) > 0:
+ msg += " removed: %r" % (diff[2], )
+
+ self._broadcast(msg)
+
+ def latest(self, irc, msg, args):
+ self._query_new_build(announce=True)
+
+Class = GNOMEOSTree
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]