* Don't display 'in xxx minutes' for current meeting

* Support buntudot
* Support multiple databases in the web interface
* Show architecture for package info if not all/any
This commit is contained in:
Dennis Kaarsemaker 2006-07-13 22:21:54 +02:00
parent 5821c80a2b
commit 1b1e1d1787
5 changed files with 44 additions and 17 deletions

View File

@ -30,6 +30,8 @@ def q(txt):
database = 'ubuntu' database = 'ubuntu'
form = cgi.FieldStorage() form = cgi.FieldStorage()
if 'db' in form:
database = form['db'].value
try: try:
page = int(form['page'].value) page = int(form['page'].value)
except: except:
@ -50,14 +52,14 @@ num = cur.fetchall()[0][0]
npages = int(ceil(num / float(NUM_PER_PAGE))) npages = int(ceil(num / float(NUM_PER_PAGE)))
out('·') out('·')
for i in range(npages): for i in range(npages):
out(' <a href="factoids.cgi?order=%s&page=%s">%d</a> &middot;' % (order_by, i, i+1)) out(' <a href="factoids.cgi?db=%s&order=%s&page=%s">%d</a> &middot;' % (database, order_by, i, i+1))
out('<br />Order by<br />&middot;') out('<br />Order by<br />&middot;')
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> &middot;' % ('name ASC', page, 'Name +')) out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> &middot;' % (database, 'name ASC', page, 'Name +'))
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> &middot;' % ('name DESC', page, 'Name -')) out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> &middot;' % (database, 'name DESC', page, 'Name -'))
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> &middot;' % ('popularity ASC', page, 'Popularity +')) out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> &middot;' % (database, 'popularity ASC', page, 'Popularity +'))
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> &middot;' % ('popularity DESC', page, 'Popularity -')) out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> &middot;' % (database, 'popularity DESC', page, 'Popularity -'))
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> &middot;' % ('added ASC', page, 'Date added +')) out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> &middot;' % (database, 'added ASC', page, 'Date added +'))
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> &middot;' % ('added DESC', page, 'Date added -')) out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> &middot;' % (database, 'added DESC', page, 'Date added -'))
out('<table cellspacing="0"><tr><th>Factoid</th><th>Value</th><th>Author</th></tr>') out('<table cellspacing="0"><tr><th>Factoid</th><th>Value</th><th>Author</th></tr>')

View File

@ -124,10 +124,16 @@ div.log {
<div class="main"> <div class="main">
<h1>Ubotu factoids</h1> <h1>Ubotu factoids</h1>
<p> <p>
More help: <a href="http://wiki.ubuntu.com/">wiki.ubuntu.com</a> &middot;
<a href="http://help.ubuntu.com/">help.ubuntu.com</a><br />
More factoids: <a href="factoids.cgi?db=ubuntu">Ubuntu</a> &middot;
<a href="factoids.cgi?db=buntudot">buntudot</a>
<p>
%s %s
</p> </p>
<p> <p>
<a href="ubuntu.db">Factoid database file</a><br /> <a href="ubuntu.db">Ubuntu factoid database file</a><br />
<a href="buntudot.db">Buntudot factoid database file</a><br />
&copy;2006 Dennis Kaarsemaker &copy;2006 Dennis Kaarsemaker
</p> </p>
</div> </div>

View File

@ -26,6 +26,8 @@ datadir = '/home/dennis/ubugtu/data/facts'
def r(repo,section): def r(repo,section):
if 'seveas' in repo: if 'seveas' in repo:
return 'Seveas' return 'Seveas'
if 'buntudot' in repo:
return 'buntudot'
if '/' in section: if '/' in section:
return section[:section.find('/')] return section[:section.find('/')]
return 'main' return 'main'
@ -114,6 +116,7 @@ class Encyclopedia(callbacks.PluginRegexp):
db,channel = fallback db,channel = fallback
if channel not in self.databases: if channel not in self.databases:
self.databases[channel] = sqlite.connect(os.path.join(datadir, '%s.db' % db)) self.databases[channel] = sqlite.connect(os.path.join(datadir, '%s.db' % db))
self.databases[channel].name = db
return self.databases[channel] return self.databases[channel]
def searchfactoid(self, irc, msg, match): def searchfactoid(self, irc, msg, match):
@ -183,7 +186,7 @@ class Encyclopedia(callbacks.PluginRegexp):
try: try:
factoid = get_factoid(db, factoid, channel) factoid = get_factoid(db, factoid, channel)
if not factoid: if not factoid:
irc.reply('I know nothing about %s - try searching bots.ubuntulinux.nl, help.ubuntu.com and wiki.ubuntu.com' % match.group('factoid')) irc.reply('I know nothing about %s - try searching http://bots.ubuntulinux.nl/factoids.cgi?db=%s' % (match.group('factoid'),db.name))
return return
# Output factoid # Output factoid
if noalias: if noalias:
@ -401,9 +404,10 @@ class Encyclopedia(callbacks.PluginRegexp):
if not self._precheck(irc, msg, timeout=(msg.args[0],match.group('package'), match.group('distro'))): if not self._precheck(irc, msg, timeout=(msg.args[0],match.group('package'), match.group('distro'))):
return return
distro = 'dapper' distro = 'dapper'
if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas')): if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas','dapper-buntudot')):
distro = match.group('distro') distro = match.group('distro')
data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', match.group('package'))) data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', match.group('package')))
data2 = commands.getoutput(self.aptcommand % (distro, distro, distro, 'showsrc', match.group('package')))
if not data or 'E: No packages found' in data: if not data or 'E: No packages found' in data:
irc.reply('Package %s does not exist in %s' % (match.group('package'), distro)) irc.reply('Package %s does not exist in %s' % (match.group('package'), distro))
else: else:
@ -418,9 +422,23 @@ class Encyclopedia(callbacks.PluginRegexp):
if apt_pkg.VersionCompare(maxp['Version'], p['Version']) < 0: if apt_pkg.VersionCompare(maxp['Version'], p['Version']) < 0:
maxp = p maxp = p
del parser del parser
irc.reply("%s: %s. In repository %s, is %s. Version %s (%s), package size %s kB, installed size %s kB" % maxp2 = {'Version': '0'}
packages2 = [x.strip() for x in data2.split('\n\n')]
for p in packages2:
if not p.strip():
continue
parser = FeedParser.FeedParser()
parser.feed(p)
p = parser.close()
if apt_pkg.VersionCompare(maxp2['Version'], p['Version']) < 0:
maxp2 = p
del parser
archs = ''
if maxp2['Architecture'] not in ('all','any'):
archs = ' (Only available for %s)' % maxp2['Architecture']
irc.reply("%s: %s. In repository %s, is %s. Version %s (%s), package size %s kB, installed size %s kB%s" %
(maxp['Package'], maxp['Description'].split('\n')[0], r(distro, maxp['Section']), (maxp['Package'], maxp['Description'].split('\n')[0], r(distro, maxp['Section']),
maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'])) maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'], archs))
def find(self, irc, msg, match): def find(self, irc, msg, match):
r"^!?find\s+(?P<package>\S+)(\s+(?P<distro>\S+))?" r"^!?find\s+(?P<package>\S+)(\s+(?P<distro>\S+))?"

View File

@ -41,10 +41,10 @@ def diff(delta):
if delta.seconds > 3600: if delta.seconds > 3600:
h = '%d hour%s ' % (int(delta.seconds/3600),s) h = '%d hour%s ' % (int(delta.seconds/3600),s)
s = '' s = ''
seconds = delta.seconds % 3600 minutes = (delta.seconds % 3600) / 60
if seconds > 120 or seconds < 60: if minutes != 1:
s = 's' s = 's'
return '%s%d minute%s' % (h,(seconds/60),s) return '%s%d minute%s' % (h,minutes,s)
class Webcal(callbacks.Plugin): class Webcal(callbacks.Plugin):
"""@schedule <timezone>: display the schedule in your timezone""" """@schedule <timezone>: display the schedule in your timezone"""
@ -89,7 +89,7 @@ class Webcal(callbacks.Plugin):
if ev0.startDate < now or (delta.days == 0 and delta.seconds < 10 * 60): if ev0.startDate < now or (delta.days == 0 and delta.seconds < 10 * 60):
preamble = 'Current meeting: %s' % ev0.summary.replace('Meeting','').strip() preamble = 'Current meeting: %s' % ev0.summary.replace('Meeting','').strip()
if num_events == 1: if num_events == 1:
return '%s in %s' % (preamble, diff(delta)) return preamble
events = events[1:] events = events[1:]
preamble += ' | ' preamble += ' | '
# n_e = 1 -> next meeting # n_e = 1 -> next meeting

View File

@ -15,7 +15,8 @@
<h1>Plugins</h1> <h1>Plugins</h1>
<p> <p>
The plugins used by these bots can be found in the bzr branch located at The plugins used by these bots can be found in the bzr branch located at
http://bots.ubuntulinux.nl https://bots.ubuntulinux.nl - Tarballs of the plugins can be found in <a
href="/tarballs">the tarballs folder</a>
</p> </p>
<p> <p>
Bugs and feature requests can be filed at <a Bugs and feature requests can be filed at <a