def _check_module_change(submodule): modtup = _loaded_module_objects[submodule] oldtime = modtup[1] curtime = _get_mtime(modtup[0].__file__) if curtime > oldtime: dlog("The %s module has changed, refreshing..." % submodule) refresh(submodule)
def signedOn(self): # Join channels self.join(self.mainchannel) self.join(self.logchannel) self.msg('ChanServ', "op %s" % self.logchannel) # Mark service as signed on self.factory.signed_on = True dlog("Succesfully logged on as %s" % self.nickname)
def refresh( submodule ): if submodule in _loaded_module_objects: module, mtime = _loaded_module_objects[submodule] dlog("Attempting reload '%s'..." % submodule) try: module = reload(module) except Exception, e: dtrace("There was an error reloading %s :" % module.__file__) return False finally:
def get( module, submodule ): if submodule in _loaded_module_objects: return _loaded_module_objects[ submodule ][0].exported_class full_path = '.'.join( ['urb', module, submodule, 'exported_class'] ) try: cls, mod = _get_class(full_path) dlog("Dynamically loaded %s from %s" % (cls, mod.__file__)) _loaded_module_objects[ submodule ] = mod, _get_mtime(mod.__file__) return cls except Exception, e: dtrace("Exception dynamically importing %s.%s" % (module, submodule)) return None
def dccDoChat(self, user, channel, address, port, data): user = user.split('!', 1)[0] dlog(address) u = User.get(nickname=user) if u: self.bind(user, address) else: self.msg(user, "You must be registered to login.") self.msg(user, "To register type the following:") self.msg(user, "/msg %s register [email] [password]" % self.nickname) self.msg(user, "") self.msg(user, " email: if you want to be able to recover your password") self.msg(user, " make sure this is valid.") self.msg(user, "") self.msg(user, " password: required, but only used for logging in over") self.msg(user, " telnet. On IRC, being identified to nickserv") self.msg(user, " is good enough.")
def left(self, channel): dlog('Parted %s' % channel) if channel in self.channels: self.channels.remove(channel)
def joined(self, channel): dlog('Joined %s' % channel) self.channels.add(channel)
def connectionMade(self): dlog("Successfully connected to %s" % self.network) IRCClient.connectionMade(self)
def clientConnectionFailed(self, connector, reason): dlog("IRC Client failed to connect : %s" % reason) self.client = None connector.port = self.next_port() protocol.ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
def clientConnectionLost(self, unused_connector, unused_reason): dlog("DCC Chat connection lost to %s" % (unused_reason)) self.unbind(self.client.remote_nick) self.client = None
def clientConnectionFailed(self, unused_connector, unused_reason): dlog("DCC Chat connection failed to %s" % (unused_reason)) self.client = None
def lineReceived(self, line): dlog("%s said via DCC: %s" % (self.remote_nick, line)) parts = line.split() command, args = parts[0], parts[1:] #try: self.app.do_command(self.remote_nick, command, args)
def connectionLost(self, reason=None): self.factory.unbind(self.remote_nick) dlog("Lost DCC connection with %s" % self.remote_nick)
def connectionMade(self): dlog("Established DCC Chat with %s" % self.remote_addr) if self.remote_nick == None: self.sendExternalIPError() else: self.factory.bind(self.remote_nick, self)
_check_module_change(submodule) if __debug__: LoopingCall(_check_for_changes).start(0.5) def refresh( submodule ): if submodule in _loaded_module_objects: module, mtime = _loaded_module_objects[submodule] dlog("Attempting reload '%s'..." % submodule) try: module = reload(module) except Exception, e: dtrace("There was an error reloading %s :" % module.__file__) return False finally: dlog("Successfully refreshed %s." % submodule) _loaded_module_objects[submodule] = (module, _get_mtime(module.__file__)) return True else: return False def load_all(modulename): submodules = get_all(modulename) dynamics = {} for sub in submodules: dynamics[sub] = get(modulename, sub) return dynamics def get_all( modulename ): module = _get_module('urb.%s' % modulename) module_list = []