Exemple #1
0
	def __init__(self, source_file, user_file = None):
		self.options = odict()

		self.allowChanges = True
		if not user_file:
			self.allowChanges = False
		
		# read main file, which contains include commands
		main_conf = read_file(source_file)

		# m4 parses the include commands and read files
		conf_dir = os.path.dirname(source_file)
		proc = KPopen(main_conf, "/usr/bin/m4", "-I", conf_dir)

		out = proc.stdout
		err = proc.stderr
		status = proc.return_code

		if status != 0:
			raise Exception("Could not read config")

		# out is a string containing all included files in tbxsosd.conf
		self.load_string(out)

		# Open the local configuration file if it exists.
		if user_file:
			local_conf = read_file(user_file)
			self.load_string(local_conf, setChanged = True)
Exemple #2
0
    def __init__(self, source_file, user_file=None):
        self.options = odict()

        self.allowChanges = True
        if not user_file:
            self.allowChanges = False

        # read main file, which contains include commands
        main_conf = read_file(source_file)

        # m4 parses the include commands and read files
        conf_dir = os.path.dirname(source_file)
        proc = KPopen(main_conf, "/usr/bin/m4", "-I", conf_dir)

        out = proc.stdout
        err = proc.stderr
        status = proc.return_code

        if status != 0:
            raise Exception("Could not read config")

        # out is a string containing all included files in tbxsosd.conf
        self.load_string(out)

        # Open the local configuration file if it exists.
        if user_file:
            local_conf = read_file(user_file)
            self.load_string(local_conf, setChanged=True)
Exemple #3
0
def convert_mc_to_python(data):
    if isinstance(data, AbstractConfigNode):
        d = odict()
        for key, prop in data.prop_set.items():
            d[key] = convert_mc_to_python(prop.__get__(data))
        return d
    if isinstance(data, tuple):
        d = odict()
        for key, value in data:
            d[key] = convert_mc_to_python(value)
        return d
    elif isinstance(data, list):
        l = []
        for item in data:
            l.append(convert_mc_to_python(item))
        return l
    else:
        return data
Exemple #4
0
def convert_mc_to_python(data):
    if isinstance(data, AbstractConfigNode):
        d = odict()
        for key, prop in data.prop_set.items():
            d[key] = convert_mc_to_python(prop.__get__(data))
        return d
    if isinstance(data, tuple):
        d = odict()
        for key, value in data:
            d[key] = convert_mc_to_python(value)
        return d
    elif isinstance(data, list):
        l = []
        for item in data:
            l.append(convert_mc_to_python(item))
        return l
    else:
        return data
Exemple #5
0
 def show_kws_mgt_query_page(self):
    
     # Define the session variables, if required.
     if not web_session.has_key("kws_mgt_query_offset"):
         self.reset_kws_mgt_query()
     
     # Obtain the Teambox list.
     kws_list = self.get_kws_mgt_kws_list(web_session["kws_mgt_query_offset"], web_session["kws_mgt_query_limit"])
     
     # Obtain the information about the Teamboxes.
     kws_dict = odict()
     for kws_id in kws_list: kws_dict[kws_id] = self.get_kws_mgt_kws_info(kws_id)
     
     # Show the information.
     action_url = url_for('teamboxes')
     
     # Get the Teambox list content.
     s = ""
     for kws_info in kws_dict.values():
         kws_href = action_url + "?kws_mgt_specific_kws=%i" % (kws_info.kws_id)
         s += '    <tr>\n'
         s += '      <td><input type="checkbox" name="kws_mgt_kws_cb_%i"/></td>\n' % (kws_info.kws_id)
         s += '      <td class="kwstableid">%i</td>\n' % (kws_info.kws_id)
         s += '      <td class="kwstablename"><a href="%s">%s</a></td>\n' % \
              (kws_href, kweb_lib.html_text_escape(kws_info.name))
         s += '      <td class="kwstablestats">%i</td>\n' % (len(kws_info.user_list))
         s += '      <td class="kwstablestats">%s MiB</td>\n' % (self.format_as_mb(kws_info.file_size, 2))
         s += '      <td class="kwstablestats">%s</td>\n' % (self.format_kws_date(kws_info.creation_date))
         s += '      <td class="kwstablestats">%s</td>\n' % (kweb_lib.html_text_escape(kws_info.org_name))
         s += '    </tr>\n'
     kws_table_body = s
    
     # Push variables to template.  
     c.action_url = action_url
     c.kws_table_body = kws_table_body
     c.kws_mgt_query_offset = web_session["kws_mgt_query_offset"] + 1
     c.kws_mgt_query_limit = web_session["kws_mgt_query_limit"]
     
     return render('/teamboxes/query.mako')
Exemple #6
0
 def __init__(self, doc=None):
     self.doc = doc
     self.sections = odict()
Exemple #7
0
 def __init__(self, doc=None):
     self.doc = doc
     self.sections = odict()