Делаем RSS ленту всех проектов Trac`a
Categories: Python, Trac on Sep.11, 2008
Написал небольшой скрипт на python. Для получения RSS ленты по всем проектам trac системы, что иногда очень полезно. Это оценил мой менеджер проектов как удобное средство. Вот привожу на вольный суд.
Чтоб получить ленту пишем http://192.168.0.129/index.py?user= md5( хеш пароля)
Тоесть уже захешированый пароль еще в md5
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | # Author: Vladimir Boichentsov <sakrist@sakrist.org.ua> import time import calendar import sys import string import Cookie import os import fileinput import sqlite3 as sqlite import cgi import base64 from md5 import md5 from StringIO import StringIO def index(req): # building the output buff = StringIO() # you type ticket plist = ['blocker','critical','high','major','medium','minor','trivial','low'] # directory by trac projects DIR = '/home/pub/trac' # adress trac projects url = 'http://192.168.0.129/trac' i = 0 owner = ' ' if req.form.has_key('user'): user = req.form['user'].value #passwords for users trac projects for line in fileinput.input('/home/pub/.htpasswd'): line = line.replace('\n','') temp = line.split(':') if md5(line).hexdigest() == user: owner = temp[0] if owner != ' ' : buff.write('<?xml version="1.0"?>\n') buff.write('<rss version="2.0">\n') buff.write('<channel>\n') buff.write('\t<title>All My Tickets</title>\n') buff.write('\t<link>' + url + '/org/wiki/AllTikets</link>\n') buff.write('\t<description>Trac Report - All My Tickets</description>') buff.write('\t<language>en-us</language>\n') buff.write('\t<generator>RSS SAKrisT</generator>\n') buff.write('\t<image>\n') buff.write('\t<title>Organizational</title>\n') buff.write('\t<url>' + url + '_banner.png</url>\n') buff.write('\t<link>' + url + '/org/wiki/AllTikets</link>\n') buff.write('\t</image>\n') for p in plist: for project in os.listdir(DIR): if (i == 0): con = sqlite.connect(DIR + '/' + project +'/db/trac.db') cur = con.cursor() cur.execute("SELECT t.id,t.summary,t.owner,t.status,t.description,t.time,t.priority,t.type FROM ticket t, ticket_custom tc where tc.ticket=t.id and t.owner='" + owner +"' and t.priority='" + p + "'") while (1): row = cur.fetchone() if row == None: buff.write('') break else: status = row[3] description = row[4] description = description.replace('[[BR]]', '<br>') description = description.replace('<', '<') description = description.replace('>', '>') timee = time.strftime('%d %m %Y %H:%M:%S GMT',time.localtime(row[5])) if(row[3] != 'closed'): buff.write('\t<item>\n') buff.write('\t\t<author>' + owner + '</author>\n') buff.write('\t\t<pubDate>' + timee + '</pubDate>\n') buff.write('\t\t<title>' + row[1] + '</title>\n') buff.write('\t\t<link>%(url)s/%(p)s/ticket/%(id)i</link>\n' % {'id' : row[0], 'p' : project, 'url' : url, }) buff.write('\t\t<guid isPermaLink="false">%(url)s/%(p)s/ticket/%(id)i</guid>\n' % {'id' : row[0], 'p' : project, 'url' : url, }) buff.write('\t\t<description>' + description +'</description>\n') buff.write('\t\t<category>Report</category>\n') buff.write('\t</item>\n') buff.write('</channel>\n</rss>') table = buff.getvalue() buff.close() return table return 'error' |
Similar posts:

Оставить отзыв