Implement Ctrl-C handling and fix a large number of small bugs
This commit is contained in:
15
utils/cleanup.py
Normal file
15
utils/cleanup.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import main
|
||||
from twisted.internet import reactor
|
||||
from utils.logging.debug import debug
|
||||
from utils.logging.log import *
|
||||
import sys
|
||||
|
||||
def handler(sig, frame):
|
||||
log("Received SIGINT, cleaning up")
|
||||
cleanup()
|
||||
|
||||
def cleanup():
|
||||
debug("Flushing Redis database")
|
||||
main.r.flushdb()
|
||||
reactor.stop()
|
||||
#sys.exit(1)
|
||||
@@ -1,6 +1,6 @@
|
||||
from os import listdir
|
||||
from importlib import reload
|
||||
from sys import modules
|
||||
import sys
|
||||
|
||||
from utils.logging.debug import debug
|
||||
from utils.logging.log import *
|
||||
@@ -13,8 +13,8 @@ def loadSingle(commandName):
|
||||
className = commandName.capitalize()+"Command"
|
||||
try:
|
||||
if commandName in CommandMap.keys():
|
||||
reload(modules["commands."+commandName])
|
||||
CommandMap[commandName] = getattr(modules["commands."+commandName], className)
|
||||
reload(sys.modules["commands."+commandName])
|
||||
CommandMap[commandName] = getattr(sys.modules["commands."+commandName], className)
|
||||
debug("Reloaded command: %s" % commandName)
|
||||
return "RELOAD"
|
||||
module = __import__('commands.%s' % commandName)
|
||||
|
||||
Reference in New Issue
Block a user