aboutsummaryrefslogtreecommitdiff
path: root/cgi/weabot.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/weabot.py')
-rwxr-xr-xcgi/weabot.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/cgi/weabot.py b/cgi/weabot.py
index 3c5d0f5..f92e777 100755
--- a/cgi/weabot.py
+++ b/cgi/weabot.py
@@ -8,6 +8,7 @@ import time
import datetime
import random
import cgi
+import logging
import _mysql
from Cookie import SimpleCookie
@@ -33,6 +34,9 @@ _LOG = False
class weabot(object):
def __init__(self, environ, start_response):
global _DEBUG
+
+ logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO)
+
self.environ = environ
if self.environ["PATH_INFO"].startswith("/weabot.py/"):
self.environ["PATH_INFO"] = self.environ["PATH_INFO"][11:]
@@ -48,7 +52,6 @@ class weabot(object):
'weabot', './locale', languages=[Settings.LANG])
lang.install()
- logTime("**Start**")
if _DEBUG:
import cProfile
@@ -61,6 +64,8 @@ class weabot(object):
except UserError, message:
self.error(message)
except Exception, inst:
+ logging.exception(inst)
+
import sys
import traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
@@ -70,12 +75,6 @@ class weabot(object):
# close database and finish
CloseDb()
- logTime("**End**")
-
- if _LOG:
- logfile = open(Settings.ROOT_DIR + "weabot.txt", "w")
- logfile.write(logTimes())
- logfile.close()
def __iter__(self):
self.handleResponse()
@@ -732,8 +731,6 @@ class weabot(object):
if board["slip"] == '2':
if hide_end:
host = '★'
- elif addressIsTor(ip):
- host = 'onion'
else:
host = getHost(ip)
if host:
@@ -767,7 +764,7 @@ class weabot(object):
if hide_end or addressIsTor(ip):
country = '??'
else:
- country = getCountry(ip)
+ country = getCountry(ip) or '??'
post["name"] += " <em>[%s]</em>" % country
# set expiration date if necessary
@@ -812,7 +809,7 @@ class weabot(object):
post["message"]), _mysql.escape_string(board["id"]), _mysql.escape_string(str(postid))))
# do operations if replying to a thread (bump, autoclose, update cache)
- logTime("Updating thread")
+ logging.debug("Updating thread")
thread_length = None
if post["parentid"]:
# get length of the thread
@@ -1086,7 +1083,7 @@ if __name__ == "__main__":
# Psyco is not required, however it will be used if available
try:
import psyco
- logTime("Psyco se ha instalado")
+ logging.debug("Psyco se ha instalado")
psyco.bind(tenjin.helpers.to_str)
psyco.bind(weabot.run, 2)
psyco.bind(getFormData)