Fixy fixy!
This commit is contained in:
@ -351,7 +351,6 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
|
||||
def turlSnarfer(self, irc, msg, match):
|
||||
r"(?P<tracker>https?://\S*?)/(Bugs/0*|str.php\?L|show_bug.cgi\?id=|bugreport.cgi\?bug=|(bugs|\+bug)/|ticket/|tracker/|\S*aid=)(?P<bug>\d+)(?P<sfurl>&group_id=\d+&at_id=\d+)?"
|
||||
print match
|
||||
if msg.args[0][0] == '#' and not self.registryValue('bugSnarfer', msg.args[0]):
|
||||
return
|
||||
nbugs = msg.tagged('nbugs')
|
||||
@ -380,6 +379,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
irc.reply("https://devpad.canonical.com/~jamesh/oops.cgi/%s" % oopsid, prefixNick=False)
|
||||
|
||||
def get_tracker(self,snarfurl,sfdata):
|
||||
snarfurl = snarfurl.replace('sf.net','sourceforge.net')
|
||||
snarfhost = snarfurl.replace('http://','').replace('https://','')
|
||||
if '/' in snarfurl:
|
||||
snarfhost = snarfhost[:snarfhost.index('/')]
|
||||
@ -527,10 +527,10 @@ class Malone(IBugtracker):
|
||||
try:
|
||||
statuses = ['Rejected', 'Fix Released', 'Fix Committed', 'Unconfirmed', 'Needs Info', 'In Progress', 'Confirmed']
|
||||
severities = ['Undecided', 'Wishlist', 'Minor', 'Low', 'Normal', 'Medium', 'Major', 'High', 'Critical']
|
||||
if task1['status'] not in statuses and task2['status'] in statuses: return 1
|
||||
if task1['status'] in statuses and task2['status'] not in statuses: return -1
|
||||
if task1['importance'] not in severities and task2['importance'] in severities: return 1
|
||||
if task1['importance'] in severities and task2['importance'] not in severities: return -1
|
||||
if task1['status'] not in statuses and task2['status'] in statuses: return -1
|
||||
if task1['status'] in statuses and task2['status'] not in statuses: return 1
|
||||
if task1['importance'] not in severities and task2['importance'] in severities: return -1
|
||||
if task1['importance'] in severities and task2['importance'] not in severities: return 1
|
||||
if not (task1['status'] == task2['status']):
|
||||
if statuses.index(task1['status']) < statuses.index(task2['status']):
|
||||
return -1
|
||||
@ -677,7 +677,6 @@ class Trac(IBugtracker):
|
||||
severity = l[l.find('>')+1:l.find('</')]
|
||||
if 'headers="h_owner"' in l:
|
||||
assignee = l[l.find('>')+1:l.find('</')]
|
||||
#print [(id, package, title, severity, status, assignee, "%s/%s" % (self.url, id))]
|
||||
return [(id, package, title, severity, status, assignee, "%s/%s" % (self.url, id))]
|
||||
|
||||
class WikiForms(IBugtracker):
|
||||
@ -753,13 +752,11 @@ class Sourceforge(IBugtracker):
|
||||
_sf_url = 'http://sf.net/support/tracker.php?aid=%d'
|
||||
def get_bug(self, id):
|
||||
url = self._sf_url % id
|
||||
print url
|
||||
try:
|
||||
bugdata = utils.web.getUrl(url)
|
||||
except Exception, e:
|
||||
s = 'Could not parse data returned by %s: %s' % (self.description, e)
|
||||
raise BugtrackerError, s
|
||||
print bugdata
|
||||
try:
|
||||
reo = sfre.search(bugdata)
|
||||
status = reo.group('status')
|
||||
|
@ -55,7 +55,7 @@ you want to show by default.
|
||||
|
||||
To get package lookup working, you need to set the variable
|
||||
supybot.plugins.encyclopedia.aptdir to the name of a new, empty directory. In
|
||||
this directory, you creae sources.list files for every distrorelease you want to
|
||||
this directory, you create sources.list files for every distrorelease you want to
|
||||
search. The name of the file is important, since the filename (without the .list
|
||||
suffix) is the name that is used to refer to the distrorelease.
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
import sys
|
||||
sys.path.append('/home/dennis/public_html')
|
||||
from commoncgi import *
|
||||
|
||||
for file in sorted(os.listdir('/home/dennis/public_html/botlogs'),reverse=True)[1:101]:
|
||||
print '<a href="/botlogs/%s">%s</a><br/>' % (file, file)
|
||||
|
||||
send_page('plain.tmpl')
|
@ -1,109 +1,124 @@
|
||||
#!/usr/bin/python
|
||||
###
|
||||
# Copyright (c) 2006,2007 Dennis Kaarsemaker
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of version 2 of the GNU General Public License as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
###
|
||||
|
||||
import sqlite
|
||||
import datetime
|
||||
import cgi, cgitb
|
||||
from math import ceil
|
||||
import re
|
||||
cgitb.enable
|
||||
import sys
|
||||
sys.path.append('/var/www/bots.ubuntulinux.nl')
|
||||
from commoncgi import *
|
||||
|
||||
### Variables
|
||||
NUM_PER_PAGE=50.0
|
||||
datadir = '/home/dennis/ubugtu/data/facts'
|
||||
default_database = 'ubuntu'
|
||||
|
||||
buf = ''
|
||||
def out(txt):
|
||||
global buf
|
||||
buf += str(txt)
|
||||
databases = [x for x in os.listdir(datadir)]
|
||||
|
||||
# Initialize
|
||||
database = default_database
|
||||
order_by = 'popularity DESC'
|
||||
page = 0
|
||||
search = ''
|
||||
factoids = []
|
||||
total = 0
|
||||
|
||||
# Read POST
|
||||
if 'db' in form:
|
||||
database = form['db'].value
|
||||
if database not in database:
|
||||
database = default_database
|
||||
con = sqlite.connect(os.path.join(datadir, database + '.db'))
|
||||
cur = con.cursor()
|
||||
|
||||
try: page = int(form['page'].value)
|
||||
except: pass
|
||||
|
||||
if 'order' in form:
|
||||
if form['order'].value in ('added DESC', 'added ASC', 'name DESC', 'name ASC', 'popularity DESC','popularity ASC'):
|
||||
order_by = form['order'].value
|
||||
if 'search' in form:
|
||||
search = form['search'].value
|
||||
|
||||
# Select factoids
|
||||
if search:
|
||||
keys = [x.strip() for x in search.split() if len(x.strip()) >2][:5]
|
||||
query1 = "SELECT name, value, author, added, popularity FROM facts WHERE name NOT LIKE '%-also' AND ("
|
||||
query2 = "SELECT COUNT(name) FROM facts WHERE "
|
||||
bogus = False
|
||||
for k in keys:
|
||||
k = k.replace("'","\'")
|
||||
if bogus:
|
||||
query1 += ' OR '
|
||||
query2 += ' OR '
|
||||
query1 += "name LIKE '%%%s%%' OR VAlUE LIKE '%%%s%%'" % (k, k)
|
||||
query2 += "name LIKE '%%%s%%' OR VAlUE LIKE '%%%s%%'" % (k, k)
|
||||
bogus=True
|
||||
|
||||
query1 += ') ORDER BY %s LIMIT %d, %d' % (order_by, NUM_PER_PAGE*page, NUM_PER_PAGE)
|
||||
cur.execute(query1)
|
||||
factoids = cur.fetchall()
|
||||
cur.execute(query2)
|
||||
total = cur.fetchall()[0][0]
|
||||
else:
|
||||
cur.execute("SELECT name, value, author, added, popularity FROM facts WHERE value NOT LIKE '<alias>%%' AND name NOT LIKE '%%-also' ORDER BY %s LIMIT %d, %d" % (order_by, page*NUM_PER_PAGE, NUM_PER_PAGE))
|
||||
factoids = cur.fetchall()
|
||||
cur.execute("""SELECT COUNT(*) FROM facts WHERE value NOT LIKE '<alias>%%'""")
|
||||
total = cur.fetchall()[0][0]
|
||||
|
||||
# Pagination links
|
||||
npages = int(math.ceil(total / float(NUM_PER_PAGE)))
|
||||
print '·'
|
||||
for i in range(npages):
|
||||
print '<a href="factoids.cgi?db=%s&search=%s&order=%s&page=%s">%d</a> ·' % (database, search, order_by, i, i+1)
|
||||
|
||||
print '<br />Order by<br />·';
|
||||
print ' <a href="factoids.cgi?db=%s&search=%s&order=%s&page=0">%s</a> ·' % (database, search, 'name ASC', 'Name +')
|
||||
print ' <a href="factoids.cgi?db=%s&search=%s&order=%s&page=0">%s</a> ·' % (database, search, 'name DESC', 'Name -')
|
||||
print ' <a href="factoids.cgi?db=%s&search=%s&order=%s&page=0">%s</a> ·' % (database, search, 'popularity ASC', 'Popularity +')
|
||||
print ' <a href="factoids.cgi?db=%s&search=%s&order=%s&page=0">%s</a> ·' % (database, search, 'popularity DESC', 'Popularity -')
|
||||
print ' <a href="factoids.cgi?db=%s&search=%s&order=%s&page=0">%s</a> ·' % (database, search, 'added ASC', 'Date added +')
|
||||
print ' <a href="factoids.cgi?db=%s&search=%s&order=%s&page=0">%s</a> ·' % (database, search, 'added DESC', 'Date added -')
|
||||
|
||||
print '<table cellspacing="0"><tr><th>Factoid</th><th>Value</th><th>Author</th></tr>'
|
||||
|
||||
url_re = re.compile('(?P<url>(https?://\S+|www\S+))')
|
||||
def q(x):
|
||||
x = str(x).replace('&','&').replace('<','<').replace('>','>').replace('\n','<br />')
|
||||
return url_re.sub(link, x)
|
||||
def link(match):
|
||||
url = match.group('url')
|
||||
txt = url
|
||||
if len(txt) > 30:
|
||||
txt = txt[:20] + '…' + txt[-10:]
|
||||
return '<a href="%s">%s</a>' % (url, txt)
|
||||
|
||||
def q(txt):
|
||||
txt = str(txt).replace('&','&').replace('<','<').replace('>','>').replace('"','"').replace('\n','<br />').replace('$hr$','<hr />')
|
||||
# linkify
|
||||
rx = re.compile('(?P<url>(https?://\S+|www\S+))')
|
||||
return rx.sub(link, txt)
|
||||
|
||||
database = 'ubuntu'
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
if 'db' in form:
|
||||
database = form['db'].value
|
||||
try:
|
||||
page = int(form['page'].value)
|
||||
except:
|
||||
page = 0
|
||||
order_by = 'added DESC'
|
||||
try:
|
||||
order_by = form['order'].value
|
||||
if order_by not in ('added DESC', 'added ASC', 'name DESC', 'name ASC', 'popularity DESC','popularity ASC'):
|
||||
order_by = 'added DESC'
|
||||
except:
|
||||
order_by = 'added DESC'
|
||||
|
||||
con = sqlite.connect('/home/dennis/ubugtu/data/facts/%s.db' % database)
|
||||
cur = con.cursor()
|
||||
|
||||
if 'search' not in form:
|
||||
cur.execute("""SELECT COUNT(*) FROM facts WHERE value NOT LIKE '<alias>%%'""")
|
||||
num = cur.fetchall()[0][0]
|
||||
npages = int(ceil(num / float(NUM_PER_PAGE)))
|
||||
out('·')
|
||||
for i in range(npages):
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%s">%d</a> ·' % (database, order_by, i, i+1))
|
||||
out('<br />Order by<br />·')
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'name ASC', page, 'Name +'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'name DESC', page, 'Name -'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'popularity ASC', page, 'Popularity +'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'popularity DESC', page, 'Popularity -'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'added ASC', page, 'Date added +'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'added DESC', page, 'Date added -'))
|
||||
|
||||
out('<table cellspacing="0"><tr><th>Factoid</th><th>Value</th><th>Author</th></tr>')
|
||||
|
||||
if 'search' in form:
|
||||
keys = form['search'].value.split()[:5]
|
||||
ret = {}
|
||||
for k in keys:
|
||||
k = k.replace("'","\'")
|
||||
cur.execute("SELECT name, value, author, added, popularity FROM facts WHERE name LIKE '%%%s%%' OR VAlUE LIKE '%%%s%%'" % (k, k))
|
||||
res = cur.fetchall()
|
||||
for r in res:
|
||||
r0 = r[0]
|
||||
try:
|
||||
ret[r][1] += 1
|
||||
except:
|
||||
ret[r0] = (r, 1)
|
||||
keys = sorted(ret.keys(), lambda x, y: cmp(ret[x][1], ret[y][1]))
|
||||
factoids = []
|
||||
for k in keys[:50]:
|
||||
factoids.append(ret[k][0])
|
||||
else:
|
||||
cur.execute("SELECT name, value, author, added, popularity FROM facts WHERE value NOT LIKE '<alias>%%' AND name NOT LIKE '%%-also' ORDER BY %s LIMIT %d, %d" % (order_by, page*NUM_PER_PAGE, NUM_PER_PAGE))
|
||||
factoids = cur.fetchall()
|
||||
i = 0
|
||||
for f in factoids:
|
||||
f = list(f)
|
||||
f[2] = f[2][:30]
|
||||
if '.' in f[3]:
|
||||
f[3] = f[3][:f[3].find('.')]
|
||||
cur.execute("SELECT value FROM facts WHERE name = %s", f[0] + '-also')
|
||||
more = cur.fetchall()
|
||||
if len(more):
|
||||
f[1] += ' $hr$' + ' $hr$'.join([x[0] for x in more])
|
||||
cur.execute("SELECT name FROM facts WHERE value LIKE %s", '<alias> ' + f[0])
|
||||
f[0] += ' \n' + ' \n'.join([x[0] for x in cur.fetchall()])
|
||||
out('<tr')
|
||||
if i % 2: out(' class="bg2"')
|
||||
print '<tr'
|
||||
if i % 2: print ' class="bg2"'
|
||||
i += 1
|
||||
out('><td>%s</td><td>%s</td><td>%s<br />Added on: %s<br />Requested %s times</td>' % tuple([q(x) for x in f]))
|
||||
print '><td>%s</td><td>%s</td><td>%s<br />Added on: %s<br />Requested %s times</td>' % tuple([q(x) for x in f])
|
||||
|
||||
out('</table>')
|
||||
print '</table>'
|
||||
|
||||
print "Content-Type: text/html; charset=UTF-8"
|
||||
print ""
|
||||
|
||||
fd = open('factoids.tmpl')
|
||||
tmpl = fd.read()
|
||||
fd.close()
|
||||
print tmpl % (buf)
|
||||
send_page('factoids.tmpl')
|
||||
|
@ -151,7 +151,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
text = text.strip()
|
||||
if text.lower() == self.registryValue('prefixchar') + irc.nick.lower():
|
||||
return irc.nick.lower()
|
||||
if text[0] == self.registryValue('prefixchar'):
|
||||
if len(text) and text[0] == self.registryValue('prefixchar'):
|
||||
text = text[1:]
|
||||
if text.lower().startswith(irc.nick.lower()) and (len(text) < 5 or not text[5].isalnum()):
|
||||
t2 = text[5:].strip()
|
||||
@ -201,20 +201,17 @@ class Encyclopedia(callbacks.Plugin):
|
||||
factoids = cur.fetchall()
|
||||
if len(factoids):
|
||||
f = factoids[0]
|
||||
n = f[0]
|
||||
if '-#' in n:
|
||||
n = n[:n.find('-#')]
|
||||
return Factoid(n,f[1],f[2],f[3],f[4])
|
||||
return Factoid(f[0],f[1],f[2],f[3],f[4])
|
||||
|
||||
def resolve_alias(self, channel, factoid, loop=0):
|
||||
if loop >= 10:
|
||||
return Factoid('','Error: infinite <alias> loop detected','','',0)
|
||||
return Factoid('','<reply> Error: infinite <alias> loop detected','','',0)
|
||||
if factoid and factoid.value.lower().startswith('<alias>'):
|
||||
new_factoids = self.get_factoids(factoid.value[7:].lower().strip(), channel, False)
|
||||
for x in ['channel_primary', 'global_primary']:
|
||||
if getattr(new_factoids, x):
|
||||
return self.resolve_alias(channel, getattr(new_factoids, x), loop+1)
|
||||
return Factoid('','Error: unresolvable <alias>','','',0)
|
||||
return Factoid('','<reply> Error: unresolvable <alias> to %s' % factoid.value[7:].lower().strip(),'','',0)
|
||||
else:
|
||||
return factoid
|
||||
|
||||
@ -301,9 +298,9 @@ class Encyclopedia(callbacks.Plugin):
|
||||
(msg.args[0], msg.nick, msg.args[1])))
|
||||
return
|
||||
ret = self.factoid_edit(text, channel, msg.prefix)
|
||||
elif ' is ' in text and ('|' not in text or text.find(' is ') > text.find('|')):
|
||||
elif ' is ' in text and '|' not in text:
|
||||
if not capab(msg.prefix, 'editfactoids'):
|
||||
if len(text[:text.find('is')]) > 20:
|
||||
if len(text[:text.find('is')]) > 15:
|
||||
irc.error("I am only a bot, please don't think I'm intelligent :)")
|
||||
else:
|
||||
irc.reply("Your edit request has been forwarded to %s. Thank you for your attention to detail" %
|
||||
@ -329,6 +326,9 @@ class Encyclopedia(callbacks.Plugin):
|
||||
ret = None
|
||||
|
||||
if not ret:
|
||||
if len(text) > 15:
|
||||
irc.error("I am only a bot, please don't think I'm intelligent :)")
|
||||
return
|
||||
retmsg = ''
|
||||
ret = self.registryValue('notfoundmsg')
|
||||
if ret.count('%') == ret.count('%s') == 1:
|
||||
@ -418,6 +418,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
ret = self.check_aliases(channel, factoid)
|
||||
if ret:
|
||||
return ret
|
||||
print("UPDATE facts SET value=%s where name=%s", (factoid.value,factoid.name))
|
||||
cs.execute("UPDATE facts SET value=%s where name=%s", (factoid.value,factoid.name))
|
||||
db.commit()
|
||||
return retmsg
|
||||
@ -465,9 +466,12 @@ class Encyclopedia(callbacks.Plugin):
|
||||
elif order == 'secondary':
|
||||
ret.append(factoid.value.strip().replace('$chan',channel))
|
||||
else:
|
||||
ret.append('%s is %s' % (factoid.name, factoid.value.replace('$chan',channel)))
|
||||
n = factoid.name
|
||||
if '-#' in n:
|
||||
n = n[:n.find('-#')]
|
||||
ret.append('%s is %s' % (n, factoid.value.replace('$chan',channel)))
|
||||
if not display_info:
|
||||
break
|
||||
break
|
||||
return ret
|
||||
|
||||
def search_factoid(self, factoid, channel):
|
||||
|
@ -6,7 +6,7 @@ for DIST in "$DIR"/*.list; do
|
||||
DIST=${DIST:${#DIR}}
|
||||
DIST=${DIST/.list}
|
||||
touch "$DIR/$DIST.status"
|
||||
mkdir -p "$DIR/$DIST"
|
||||
mkdir -p "$DIR/$DIST/partial"
|
||||
apt-get -qq -o "Dir::State::Lists=$DIR/$DIST" \
|
||||
-o "Dir::etc::sourcelist=$DIR/$DIST.list" \
|
||||
-o "Dir::State::status=$DIR/$DIST.status" \
|
||||
|
Reference in New Issue
Block a user