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 # Overwrite print built-in
def prnt(*args): def prnt(*args):
print("[%s]" % module_name, *args)
if hasattr(module, "logger"): if hasattr(module, "logger"):
module.logger.info(" ".join([str(s) for s in args])) 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 module.print = prnt
# Create module context # Create module context

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ class IRC(SocketServer):
import nemubot 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["CLIENTINFO"] = _ctcp_clientinfo
#self.ctcp_capabilities["DCC"] = _ctcp_dcc #self.ctcp_capabilities["DCC"] = _ctcp_dcc
self.ctcp_capabilities["FINGER"] = lambda msg, cmds: "VERSION nemubot v%s" % nemubot.__version__ 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 # Add the server in the context
if context.add_server(srv, get_boolean(server, "autoconnect")): 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: else:
print("Can't add server '%s'." % srv.id) logger.error("Can't add server '%s'." % srv.id)
# Load module and their configuration # Load module and their configuration
for mod in config.getNodes("module"): for mod in config.getNodes("module"):
@ -130,8 +130,8 @@ def load_file(filename, context):
# Other formats # Other formats
else: 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) "configuration file." % filename)
# Unexisting file, assume a name was passed, import the module! # Unexisting file, assume a name was passed, import the module!
else: else: