def __init__(self, channel, filename): self.channel = channel self.filename = filename conf = ConfigObj('pyGBot.ini') try: print "Opening log file..." log.addScreenHandler(log.logger, log.formatter) log.addLogFileHandler(log.logger,conf['IRC']['logfile'],log.formatter) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.logger,'pyGBot.log',log.formatter)
def __init__(self, channel, filename): self.channel = channel self.filename = filename conf = ConfigObj('pyGBot.ini') try: print "Opening log file..." log.addScreenHandler(log.logger, log.formatter) log.addLogFileHandler(log.logger, conf['IRC']['logfile'], log.formatter) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.logger, 'pyGBot.log', log.formatter)
class GBotFactory(protocol.ClientFactory): """A factory for tbots. A new protocol instance will be created each time we connect to the server. """ # the class of the protocol to build when new connection is made protocol = GBot def __init__(self, channel, filename): self.channel = channel self.filename = filename conf = ConfigObj('pyGBot.ini') try: print "Opening log file..." log.addScreenHandler(log.logger, log.formatter) log.addLogFileHandler(log.logger, conf['IRC']['logfile'], log.formatter) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.logger, 'pyGBot.log', log.formatter) except KeyError: print "No log file config found. Defaulting to local." log.addLogFileHandler(log.logger, 'pyGBot.log', log.formatter)
try: print "Opening log file..." log.addScreenHandler(log.logger, log.formatter) log.addLogFileHandler(log.logger,conf['IRC']['logfile'],log.formatter) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.logger,'pyGBot.log',log.formatter) except KeyError: print "No log file config found. Defaulting to local." log.addLogFileHandler(log.logger,'pyGBot.log',log.formatter) try: print "Opening log file..." log.addLogFileHandler(log.chatlog,conf['IRC']['chatlogfile'],log.cformat) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.chatlog,'chat.log',log.cformat) except KeyError: print "No log file config found. Defaulting to local." log.addLogFileHandler(log.chatlog,'chat.log',log.cformat) def clientConnectionLost(self, connector, reason): """If we get disconnected, reconnect to server.""" connector.connect() def clientConnectionFailed(self, connector, reason): log.logger.critical('connection failed: %s', (str(reason),))
try: print "Opening log file..." log.addScreenHandler(log.logger, log.formatter) log.addLogFileHandler(log.logger, conf['IRC']['logfile'], log.formatter) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.logger, 'pyGBot.log', log.formatter) except KeyError: print "No log file config found. Defaulting to local." log.addLogFileHandler(log.logger, 'pyGBot.log', log.formatter) try: print "Opening log file..." log.addLogFileHandler(log.chatlog, conf['IRC']['chatlogfile'], log.cformat) except IOError, msg: print "Unable to open log file: ", msg print "Defaulting to local." log.addLogFileHandler(log.chatlog, 'chat.log', log.cformat) except KeyError: print "No log file config found. Defaulting to local." log.addLogFileHandler(log.chatlog, 'chat.log', log.cformat) def clientConnectionLost(self, connector, reason): """If we get disconnected, reconnect to server.""" connector.connect() def clientConnectionFailed(self, connector, reason): log.logger.critical('connection failed: %s', (str(reason), ))