Remove print unhandled in daemon mode

This commit is contained in:
nemunaire 2015-07-16 20:38:04 +02:00
parent f9f54989fe
commit a4fd04c310
6 changed files with 8 additions and 13 deletions

View File

@ -393,9 +393,10 @@ class Bot(threading.Thread):
# Overwrite print built-in
def prnt(*args):
print("[%s]" % module_name, *args)
if hasattr(module, "logger"):
module.logger.info(" ".join([str(s) for s in args]))
else:
logger.info("[%s] %s", module_name, " ".join([str(s) for s in args]))
module.print = prnt
# Create module context

View File

@ -40,7 +40,6 @@ class HooksManager:
if trigger not in self.hooks:
self.hooks[trigger] = list()
#print("ADD hook: %s => %s" % (trigger, hook))
self.hooks[trigger].append(hook)
@ -86,7 +85,6 @@ class HooksManager:
if trigger.find(key) == 0:
res += self.hooks[key]
#print("GET hooks: %s => %d" % (trigger, len(res)))
return res

View File

@ -31,11 +31,9 @@ class ModuleFinder(Finder):
self.add_module = add_module
def find_module(self, fullname, path=None):
# print ("looking for", fullname, "in", path)
# Search only for new nemubot modules (packages init)
if path is None:
for mpath in self.modules_paths:
# print ("looking for", fullname, "in", mpath)
if os.path.isfile(os.path.join(mpath, fullname + ".py")):
return ModuleLoader(self.add_module, fullname,
os.path.join(mpath, fullname + ".py"))
@ -44,7 +42,6 @@ class ModuleFinder(Finder):
os.path.join(
os.path.join(mpath, fullname),
"__init__.py"))
# print ("not found")
return None

View File

@ -26,7 +26,6 @@ def convert_legacy_store(old):
elif old == "all_pre":
return "pre"
else:
print("UNKNOWN store:", old)
return old
@ -115,7 +114,7 @@ class ModuleContext:
return context.del_event(evt, module_src=module)
def send_response(server, res):
print(res)
module.logger.info("Send response: %s", res)
def save():
context.datastore.save(module_name, self.data)

View File

@ -96,7 +96,7 @@ class IRC(SocketServer):
import nemubot
self.ctcp_capabilities["ACTION"] = lambda msg, cmds: print ("ACTION receive: %s" % cmds)
self.ctcp_capabilities["ACTION"] = lambda msg, cmds: None
self.ctcp_capabilities["CLIENTINFO"] = _ctcp_clientinfo
#self.ctcp_capabilities["DCC"] = _ctcp_dcc
self.ctcp_capabilities["FINGER"] = lambda msg, cmds: "VERSION nemubot v%s" % nemubot.__version__

View File

@ -109,9 +109,9 @@ def load_file(filename, context):
# Add the server in the context
if context.add_server(srv, get_boolean(server, "autoconnect")):
print("Server '%s' successfully added." % srv.id)
logger.info("Server '%s' successfully added." % srv.id)
else:
print("Can't add server '%s'." % srv.id)
logger.error("Can't add server '%s'." % srv.id)
# Load module and their configuration
for mod in config.getNodes("module"):
@ -130,7 +130,7 @@ def load_file(filename, context):
# Other formats
else:
print (" Can't load `%s'; this is not a valid nemubot "
logger.error("Can't load `%s'; this is not a valid nemubot "
"configuration file." % filename)
# Unexisting file, assume a name was passed, import the module!