db stuff
This commit is contained in:
parent
3fde4692d1
commit
16ddabfe2a
5 changed files with 12 additions and 147 deletions
|
@ -45,6 +45,7 @@ def get_logger():
|
|||
logger.addHandler(sh)
|
||||
return logger
|
||||
|
||||
|
||||
class Bot(threading.Thread):
|
||||
def __init__(self):
|
||||
# basic variables
|
||||
|
@ -163,4 +164,4 @@ class Bot(threading.Thread):
|
|||
def restart(self, reason=None):
|
||||
"""shuts the bot down and restarts it"""
|
||||
self.do_restart = True
|
||||
self.stop(reason)
|
||||
self.stop(reason)
|
|
@ -106,7 +106,7 @@ class SendThread(threading.Thread):
|
|||
def run(self):
|
||||
while not self.shutdown:
|
||||
line = self.output_queue.get().splitlines()[0][:500]
|
||||
#print u"{}> {}".format(self.conn_name, line)
|
||||
print u"{}> {}".format(self.conn_name, line)
|
||||
self.output_buffer += line.encode('utf-8', 'replace') + '\r\n'
|
||||
while self.output_buffer:
|
||||
sent = self.socket.send(self.output_buffer)
|
||||
|
|
12
core/main.py
12
core/main.py
|
@ -73,6 +73,10 @@ def run(bot, func, input):
|
|||
except:
|
||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||
return
|
||||
finally:
|
||||
if uses_db:
|
||||
print "Close"
|
||||
input.db.close()
|
||||
else:
|
||||
kw = dict((key, input[key]) for key in args if key in input)
|
||||
try:
|
||||
|
@ -80,6 +84,10 @@ def run(bot, func, input):
|
|||
except:
|
||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||
return
|
||||
finally:
|
||||
if uses_db:
|
||||
print "Close"
|
||||
input.db.close()
|
||||
else:
|
||||
try:
|
||||
out = func(input.inp)
|
||||
|
@ -89,10 +97,6 @@ def run(bot, func, input):
|
|||
if out is not None:
|
||||
input.reply(unicode(out))
|
||||
|
||||
if uses_db:
|
||||
# close SQLAlchemy session
|
||||
input.db.close()
|
||||
|
||||
|
||||
def do_sieve(sieve, bot, input, func, type, args):
|
||||
try:
|
||||
|
|
Reference in a new issue