Beispiel #1
0
	def reloadplugin(self, name):
		"""broken"""
		if not name in self.plugins:
			Log.error("Plugin %s not loaded" % name)
			return
		try:
			if "ondestroy" in dir(self.plugins[name]):
				self.plugins[name].ondestroy()
			Log.notice("%s Unloaded" % name)
		except Exception:
			Log.error("Cannot unload plugin %s" % name)
			Log.error("Use forceunload to remove it anyway")
			Log.error(traceback.print_exc())
		try:
			code = reload(sys.modules[name])
		except Exception:
			Log.error("Cannot reload plugin %s!" % name)
			return
		self.plugins.update([(name, code.Main())])
		self.plugins[name].socket = self.app.tasclient.socket
		try:
			if "onload" in dir(self.plugins[name]):
				self.plugins[name].onload(self.app.tasclient)
		except Exception:
			Log.error("Cannot load plugin   " + name)
			Log.error(traceback.print_exc())
			return
		Log.loaded("Plugin " + name)
Beispiel #2
0
			self.plugins.update([(name, code.Main(name, tasc))])
		except TypeError, t:
			Log.exception(t)
			self.plugins.update([(name, code.Main())])
			Log.error('loaded old-style plugin %s. Please derive from IPlugin' % name)
		self.plugins[name].socket = tasc.socket

		try:
			if "onload" in dir(self.plugins[name]):
				self.plugins[name].onload(tasc)
			if "onloggedin" in dir(self.plugins[name]) and self.app.connected:
				self.plugins[name].onloggedin(tasc.socket)
		except Exception, e:
			Log.exception(e)
			return
		Log.loaded("Plugin " + name)

	def unloadplugin(self, name):
		""" unload plugin, stop all its threads
		via ondestroy and remove from interal list"""
		if not name in self.plugins:
			Log.error("Plugin %s not loaded" % name)
			return
		try:
			if "ondestroy" in dir(self.plugins[name]):
				self.plugins[name].ondestroy()
			self.plugins.pop(name)
			Log.notice("%s Unloaded" % name)
		except Exception, e:
			Log.error("Cannot unload plugin %s" % name)
			Log.error("Use forceunload to remove it anyway")