aboutsummaryrefslogtreecommitdiff
path: root/cgi/weabot.py
diff options
context:
space:
mode:
authorLibravatar Renard 2020-07-30 21:24:11 -0400
committerLibravatar Renard 2020-07-30 21:24:11 -0400
commit299fd02d0616380ed60d180763483b004c004ad9 (patch)
treea2b5357e3d1d7c6c179ddc0602b4adf86d9873ad /cgi/weabot.py
parenta9f0898128901b824aa339fccf4ccf8d691993ad (diff)
parent89630525f6d84cd58ffa6df79751bf4ff3946fcb (diff)
downloadweabot-299fd02d0616380ed60d180763483b004c004ad9.tar.gz
weabot-299fd02d0616380ed60d180763483b004c004ad9.tar.xz
weabot-299fd02d0616380ed60d180763483b004c004ad9.zip
Merge branch 'master' of https://git.bienvenidoainternet.org/priv/www
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)