Example #1
0
def get_url(path):
	path, section = get_opt(path)
	fullpath = os.path.join(path, settings.SPEC_URL_FILE_NAME)

	if len(config.sections(fullpath)) > 1:
		urls = []
		result = {}
		for section in config.sections(fullpath):
			result['url'] = config.get(fullpath, section, 'url')
			result['title'] = config.get(fullpath, section, 'title')

		return result

	if os.path.exists(fullpath):
		return config.get(fullpath, section, 'url')
Example #2
0
    def Admin(self, handler, query):
        #Read config file new each time in case there was any outside edits
        config = ConfigParser.ConfigParser()
        config.read(config_file_path)

        shares_data = []
        for section in config.sections():
            if not(section.startswith('_tivo_') or section.startswith('Server')):
                if not(config.has_option(section,'type')):
                    shares_data.append((section, dict(config.items(section, raw=True))))
                elif config.get(section,'type').lower() != 'admin':
                    shares_data.append((section, dict(config.items(section, raw=True))))
        
        subcname = query['Container'][0]
        cname = subcname.split('/')[0]
        handler.send_response(200)
        handler.end_headers()
        t = Template(file=os.path.join(SCRIPTDIR,'templates', 'settings.tmpl'))
        t.container = cname
        t.server_data = dict(config.items('Server', raw=True))
        t.server_known = buildhelp.getknown('server')
        t.shares_data = shares_data
        t.shares_known = buildhelp.getknown('shares')
        t.tivos_data = [ (section, dict(config.items(section, raw=True))) for section in config.sections() \
                         if section.startswith('_tivo_')]
        t.tivos_known = buildhelp.getknown('tivos')
        t.help_list = buildhelp.gethelp()
        handler.wfile.write(t)
Example #3
0
    def Admin(self, handler, query):
        #Read config file new each time in case there was any outside edits
        config = ConfigParser.ConfigParser()
        config.read(config_file_path)

        shares_data = []
        for section in config.sections():
            if not (section.startswith('_tivo_')
                    or section.startswith('Server')):
                if not (config.has_option(section, 'type')):
                    shares_data.append(
                        (section, dict(config.items(section, raw=True))))
                elif config.get(section, 'type').lower() != 'admin':
                    shares_data.append(
                        (section, dict(config.items(section, raw=True))))

        subcname = query['Container'][0]
        cname = subcname.split('/')[0]
        handler.send_response(200)
        handler.end_headers()
        t = Template(
            file=os.path.join(SCRIPTDIR, 'templates', 'settings.tmpl'))
        t.container = cname
        t.server_data = dict(config.items('Server', raw=True))
        t.server_known = buildhelp.getknown('server')
        t.shares_data = shares_data
        t.shares_known = buildhelp.getknown('shares')
        t.tivos_data = [ (section, dict(config.items(section, raw=True))) for section in config.sections() \
                         if section.startswith('_tivo_')]
        t.tivos_known = buildhelp.getknown('tivos')
        t.help_list = buildhelp.gethelp()
        handler.wfile.write(t)
Example #4
0
def getBoards():
    res = []
    config = ConfigParser.RawConfigParser()
    config.read("BOARDS")
    for i in config.sections():
        res.append([i, config.get(i, "size")])
    return res
Example #5
0
def getBoards():
	res = []
	config = ConfigParser.RawConfigParser()
	config.read('BOARDS')
	for i in config.sections():
		res.append([i, config.get(i, 'size')])
	return res;
Example #6
0
    def fetch_channels(self):
        config = Config.get()
        bucket = storage.bucket("yada-comp451.appspot.com")

        channel_path = Path(channel_module_directory)
        if not channel_path.exists():
            channel_path.mkdir()

        for key in filter(lambda section: section.startswith("channel/"),
                          config.sections()):
            config.remove_section(key)

        for root, dirs, files in os.walk(channel_module_directory):
            for file in files:
                os.remove(os.path.join(root, file))

        template = self.template_snapshot.to_dict()
        for channel_name, filename in template["channels"].items():
            blob = bucket.blob(f"{PREFIX}{filename['script']}")
            blob.download_to_filename(
                f"{channel_module_directory}{channel_name}.py")

            config[f"channel/{channel_name}"] = {
                "module": filename['script'].replace(".py", "")
            }

        config["config"]["template_modified_date"] = template["modified"]
Example #7
0
def get_config_str(section='', options='', config=None):
    if section != '':
        try:
            size_s = int(section)
        except ValueError as e:
            section = section
        else:
            if config != None and size_s >= 0 and size_s < len(config):
                section = config.sections()[size_s]
            else:
                section = section
    else:
        raise ValueError('错误使用')
    if options != '':
        try:
            size_o = int(options)
        except ValueError as e:
            options = options
        else:
            if config.has_section(section) and size_o >= 0 and size_o < len(
                    config[section]):
                options = config.options(section)[size_o]
            else:
                options = options
    return [section, options]
Example #8
0
def show_context(request, path):
	document_root = contrib.get_document_root(path)
	fullpath = contrib.get_full_path(document_root, path)
	log.debug('show context of %s (%s %s)' % (fullpath, document_root, path))

	result = ""

	sections = config.sections(context.get(fullpath).inifile)
	for section_name in sections:
		ctx = context.get(fullpath, section=section_name)
		context_ini = context.render_ini(path, ctx, request.get_host(), section_name)
		result += context_ini

	return HttpResponse(result)
Example #9
0
 def migrateOldConfig(self): #Legacy support code
   import ConfigParser, ast
   config = ConfigParser.ConfigParser()
   if os.path.exists(self.getOldConfigFile()):
     with codecs.open(self.getOldConfigFile(), "r", "utf8") as fp:
       config.readfp(fp)
   if not config.has_section("__SYSTEM__"):
     config.add_section("__SYSTEM__")
   self.settings = dict(config.items("__SYSTEM__"))
   for name in config.sections():
     if name != "__SYSTEM__":
       dat = dict(config.items(name))
       if dat["program"] and dat["program"].startswith("["):
         args = ast.literal_eval(dat["program"])
       else:
         args = shlex.split(str(dat["program"]))
       dat["program"] = args[0]
       if "\\\\" in dat["program"]:
         dat["program"] = ast.literal_eval('"'+dat["program"]+'"')
       dat["arguments"] = args[1:]
       self.shortcutData[name] = dat
Example #10
0
	def sections(self):
		log.debug('reading sections: %s' % config.sections(self.inifile))
		return config.sections(self.inifile)
Example #11
0
import requests
from bs4 import BeautifulSoup
from collections import defaultdict
from collections import deque
import re
import logging
import config

logging.basicConfig(format=config.CONFIG.FORMAT_STRING)
log = logging.getLogger(__name__)
log.setLevel(config.CONFIG.LOGLEVEL)

config = configparser.ConfigParser()
# Reading the configuration
config.read('dinakaran.ini')
print(config.sections())
URL = config['URL']['Address']
DELAY = config['URL']['Delay']
ROOT_PAGE = config['URL']['Page']
OUTPUT_FILENAME = config['URL']['OutputFileName']
LINKS_FILENAME = config['URL']['LinksFileName']
print(URL, DELAY)

link_dict = defaultdict(list)
link_visited = []
paragraphs = []
prev_len = len(link_dict)
web_link = deque()
active_link = URL
MAX_COUNT = 1000000000000
processed_page = 0
Example #12
0
import smbus
import config
import os
import time
import threading

bus = smbus.SMBus(1)
sections = list(config.sections())


def setup():
    #	sections = list(config.sections())
    #print(sections)

    #	print(len(sections))

    for i in range(len(sections)):
        c = i - 1
        device = config.get(sections[c], 'device')
        #		print(device)
        if device == 'expander':
            address = int(config.get(sections[c], 'address'), base=16)
            port = int(config.get(sections[c], 'port'), base=16)
            mode = int(config.get(sections[c], 'mode'), base=16)
            default = config.get(sections[c], 'default')
            bus_define(address, mode)
            set = bus_write(address, port, int(default, base=2))
            if set == 1:
                config.set(sections[c], 'value', default)
                config.write()
                print("ok")