#!/usr/bin/python import time import re import cgi import urllib import cgitb; cgitb.enable() SOracleDir="/var/jbot/" #STemplateFile="/Users/jojoo/code/py/jabberbot/main.tmpl" STemplateFile="/home/jojoo/jabberbot/main.tmpl" def spit_orakel(): '''returns a string with the complete oracles''' #Soraclefile = SOracleDir + str(time.localtime()[2]) + "-" + str(time.localtime()[1]) + "-" + str(time.localtime()[0]) + ".spoken_fortunes" Soraclefile = SOracleDir + str(time.localtime()[2]) + "-" + str(time.localtime()[1]) + "-" + str(time.localtime()[0]) + ".spoken_fortunes" Sspits="Orakel fuer den " + str(time.localtime()[2]) + "." + str(time.localtime()[1]) + "

\n" try: Forakel = open (Soraclefile, "r") except IOError: return("Sorry, no oracels till now. want to give a try?") while True: Sline = Forakel.readline() if len(Sline) == 0: return (Sspits) Loracel = Sline.split("|") Sartikel= Loracel[1] Sartikel=Sartikel.rstrip("\n") #Sspits = Sspits + Loracel[0] + ' ist heute ' + urllib.quote(Sartikel) + '

' + "\n" Sspits = Sspits + Loracel[0] + ' ist heute ' + Sartikel + '

' + "\n" def ausdrucken(Sspits): try: Ftmpl = open (STemplateFile, "r") except IOError: print "templatefile not found: i searched", STemplateFile Rorakel=re.compile('[[orakel]]') while True: Sline = Ftmpl.readline() if (Rorakel.search(Sline)): print Sspits elif(len(Sline)==0): return ("1") else: print Sline, print "Content-Type: text/html\n\n" ausdrucken(spit_orakel())