Exemple #1
0
	def load_plugin(self, plugin_path):
		config_file = open( os.path.join(plugin_path, "manifest.conf") )
		name = os.path.split(plugin_path)[1]
		plugin_config = ConfigParser.RawConfigParser()
		debug( message("Reading plugin %s " % name ) )
		plugin_config.read(config_file)
		# do stuff.
#		__import__("plugins.%s.plugin" % name)
		__import__("plugins.%s.plugin" % name)
		plugin = sys.modules["plugins.%s.plugin" % name]

		self.plugins[name] = {
			"config" : plugin_config,
			"path" : plugin_path,
			"object" : plugin
		}
		if plugin.HasAttr("set_parent") :
			plugin.set_parent(self.parent)

		if plugin.hasattr("events") :
			for event in plugin["events"] :
				self.set_event_plugin(event, plugin_path)

		if plugin.hasattr("interfaces") :
			for interface in plugin["interfaces"] :
				self.set_interface_plugin(interface, plugin_path)
Exemple #2
0
	def process_template (self, str):
		""" Function doc """
		if re.search('\$\{([a-zA-Z_]+)\}', str)!=None :
			debug( message("processing : %s" % str) )
			template = string.Template(str)
			output = template.substitute(self.__dict__)
			return output
		else :
			debug( message("not a template string","warning") )
			return str
Exemple #3
0
	def ensure_dir(self, path) :
		"""
			Looks for a folder at provided path, creates it if it does not exist.
			Returns the folder.
		"""
		folder = os.path.exists(path)
		if not folder:
			debug( message("Folder [ %s ] does not exist, creating it." % path,"warning") )
			folder = os.makedirs(path)
		return folder
Exemple #4
0
	def __init__(self,parent,path=None):
		debug( message("Plugin Manager Loading",'header') )
		self.MODULE_PATH = os.path.abspath(os.path.dirname(__file__))
		self.plugins = {}
		self.events = {}
		self.interfaces = {}
		self.parent = parent
		self.process_template = self.parent.process_template
		self.required_plugin_files = [ "manifest.conf", "plugin.py" ]
		self.plugin_dir = path
		self.load_plugins()
		debug( message("Plugin Manager Ready",'success') )
Exemple #5
0
def quit():
    debug.debug("quitting")
    try:
        os.remove(app_lock_file)
    except:
        debug.error(sys.exc_info())
    if (utilsTray.username != "bluepixels"):
        utilsTray.deleteUserData()
        idleIn()

    QtCore.QCoreApplication.instance().quit()
    os._exit(0)
Exemple #6
0
	def load_profile (self,name):
		""" Function doc """
		if not name:
			raise BaseException, "Profile Name Required"

		profile_name = self.get_expanded_profile_name(name)

		debug( message("Loading setttings"), name)

		self.set_current_profile(name)
		output = {}
		for item in self.config.options(profile_name):
			output[item] = self.config.get(profile_name, item)
		return output
Exemple #7
0
	def render_interface(self):
		self.window = self.builder.get_object('window_main')
		self.notebook = self.builder.get_object('notebook')
		plugin_builder = gtk.Builder()
		for name,data in self.parent.plugins.plugins.items() :
			plugin_config_path = os.path.join(data["path"],"config.glade")
			# check for and load the interface.glade
			if os.path.isfile( plugin_config_path ):
				debug( message("Loading Config Plugin : "), name )
				plugin_builder.add_from_file( plugin_config_path );

				Tab = gtk.Label()
				Tab.set_text(name)

				Page = gtk.HBox()
				Page.pack_start( plugin_builder.get_object("plugin") )

				self.notebook.append_page(Page, Tab)
Exemple #8
0
	def ensure_file (self, path, default_content=None):
		"""
			Looks for  file at provided path,
			creates it if it does not exist,
			files it with default content if provided
			Returns the file.
		"""
		path = self.process_template(path) #expand template vars

		if not os.path.exists(path) :
			debug( message("File [ %s ] does not exist, creating it." % path,"warning") )
			self.ensure_dir(os.path.dirname(path))
			file = open(path, 'w')
			if default_content != None:
				file.write(default_content)
			file.close()
			file = path
		else :
			debug( message("file is available\n\t>%s" % path) )
			file = path

		return file
Exemple #9
0
	def __init__(self,parent=None, path = None):
		self.parent = parent
		self.USER_HOME = os.path.abspath(os.getenv("HOME"))
		self.USERNAME = os.path.abspath(os.getenv("USER"))
		self.MODULE_PATH = os.path.abspath(os.path.dirname(__file__))
		if path != None :
			self.CONFIG_PATH = path
		else :
			msg = "Can't continue without a configuration file. Please provide a path to a valid ini based configuration file."
			debug( message(msg,"error") )
			raise BaseException, msg

		self.APP_PATH = os.path.abspath(os.path.dirname(__file__))
		self.APP_NAME = parent.APP_NAME

		self.process_template = self.parent.process_template
		self.data = None
		self.config = ConfigParser.RawConfigParser()

		self.DEFAULT_CONFIG="""[main]
default-profile=default

[profile-default]
entry_admin_dn=cn=admin, dc=domain, dc=domain
entry_admin_password=password
entry_server_dn=dc=hostname, dc=domain
entry_server_fqdn=subdomain.hostname.domain
	"""
		self.SELECTED_PROFILE_NAME = None
		self.SELECTED_PROFILE = None
		self.DEFAULT_PROFILE_NAME = "default"

		self.read_config_file(self.config,self.CONFIG_PATH )

		self.set_default_profile_name( self.config.get("main",'default-profile') )
		self.set_current_profile_name( self.get_default_profile_name() )
		self.set_current_profile()
Exemple #10
0
	def load_plugins(self):
		path = self.plugin_dir
		debug( message("Processing Plugins", "header"), " : ", message(path) )
		#sys.path.append(path)

		# for directory in os.path.listdirs(self.plupathgin_dir) :
		for item in os.listdir(path):
			folder_has_plugin_files = False
			folder = os.path.join(path, item)
			if os.path.isdir( folder ):
				debug( message("Inspecting : %s" % folder ) )
				files = os.listdir( folder )
				if len( set(self.required_plugin_files) & set(files) ) == len(self.required_plugin_files) :
					self.load_plugin( folder )
				else:
					debug( message("folder is not a valid plugin", "error"), name )
Exemple #11
0
	def debug(self,*args):
		debug(args)
Exemple #12
0
def idleOut():
    debug.debug("out Idle State")
    # if (options_dict['render-auto'] == QtCore.Qt.Checked):
    myHostConfig.hDisable()
    myHostConfig.hStop()
Exemple #13
0
def idleIn():
    debug.debug("in Idle State")
Exemple #14
0
 def add_listener(self, listener):
     # Register a listener
     debug("Adding listener")
     self.listeners.append(listener)
Exemple #15
0
 def emit(self, msg):
     # Send a message to all listeners
     # TODO: rename as broadcast?
     debug("Received message: %s" % msg)
     for listener in self.listeners:
         listener.handle_msg(msg)
Exemple #16
0
 def remove_listener(self, listener):
     # Remove a listener from the list
     debug("Removing listener")
     self.listeners.remove(listener)
Exemple #17
0
 def add_listeners(self, listeners):
     # Register a list of listeners
     debug("Adding listeners")
     self.listeners.extend(listeners)
Exemple #18
0
 def add_listener(self, listener):
     # Register a listener
     debug("Adding listener")
     self.listeners.append(listener)
Exemple #19
0
 def emit(self, msg):
     # Send a message to all listeners
     # TODO: rename as broadcast?
     debug("Received message: %s" % msg)
     for listener in self.listeners:
         listener.handle_msg(msg)
Exemple #20
0
 def remove_listener(self, listener):
     # Remove a listener from the list
     debug("Removing listener")
     self.listeners.remove(listener)
Exemple #21
0
 def add_listeners(self, listeners):
     # Register a list of listeners
     debug("Adding listeners")
     self.listeners.extend(listeners)
Exemple #22
0
	def get_current_profile (self):
		profile = self.SELECTED_PROFILE
		profile_name = self.get_current_profile_name()
		debug( message("Retrieving Profile","header"), profile_name )
		debug( message(" %s has %s elements" % (profile_name, len( profile.keys() )) ) )
		return profile
Exemple #23
0
	def set_default_profile_name (self,name):
		debug( message("Storing Default Profile","header"),name)
		self.DEFAULT_PROFILE_NAME = name
		self.config.set("main", 'default-profile', name )
		self.save_config_file(self.config,self.CONFIG_PATH)