def getIniPath(): global iniPath global filename while ~iniset: try: configparser.sections() configparser.read(iniPath) filename = configparser['LOGPATH']['filename'] return iniPath break except: iniPath = input("Geben sie den INI Pfad an")
def getConfig(self): # print(type(cf.sections())) for section in cf.sections(): print() section print() type(cf.options(section)) for option in cf.options(section): print() option
def checkEnabled(conf): """ """ enset = OrderedDict() for sect in conf.sections(): en = False for key in conf[sect].keys(): if key.lower() == 'enabled': en = conf[sect].getboolean(key) if en is True: enset.update({sect: conf[sect]}) return enset
def checkEnabled(conf, enableKey='enabled'): """ Expects that conf is still a configparser instance. Check the conf for sections with a paramater matching the 'enableKey' parameter and return that section IFF (if and only if) it is True. If the 'enableKey' is not found, it's assumed to be a disabled section and it is NOT returned. """ enset = {} for sect in conf.sections(): en = False try: en = conf[sect].getboolean(enableKey) if en is True: enset.update({sect: conf[sect]}) except KeyError: pass return enset
import json import configparser configparser = configparser.ConfigParser() configparser.read('auto_capture_config.txt') print(configparser.sections()) ids_str = configparser['content']['webcam_ids'] # print(ids_str) # print(configparser['content']['img_width']) print(configparser.get('content', 'webcam_ids')) v = json.loads(configparser.get('content','webcam_ids'))
def parseRegularSections(configparser): definitionlist = [] for section in configparser.sections(): definitionlist.append(sectionToBoardDefinition(configparser, section)) return definitionlist
from tkinter import * import asyncio from datetime import datetime import tkinter.messagebox import psutil import socket from enum import Enum import configparser from Alarm import alarm from Alarm import getIniPath import os #Variablen iniPath = getIniPath() configparser = configparser.ConfigParser() configparser.sections() configparser.read(iniPath) window = Tk() logCpu = False logRam = False logHdd = False wasCritical = False runningProcess = True alertProcessCount = int(configparser['ALERTVALUES']['alertProcessCount']) criticalProcessCount = int(configparser['ALERTVALUES']['criticalProcessCount']) alertRamCount = int(configparser['ALERTVALUES']['alertRamCount']) criticalRamCount = int(configparser['ALERTVALUES']['criticalRamCount']) alertHddCount = int(configparser['ALERTVALUES']['alertHddCount']) criticalHddCount = int(configparser['ALERTVALUES']['criticalHddCount']) logFilePath = configparser['LOGPATH']['filename'] critical = " Kritisch: "
def get_sections(): configparser.read_file(open(configfile)) return configparser.sections()
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue Mar 30 22:13:55 2021 @author: qiwang """ import os import configparser as cp os.listdir(os.getcwd()) cp = cp.ConfigParser() cp.read('UP_2D_FA7.ini') sections = cp.sections() # laod database to dict parser_dict = {s: dict(cp.items(s)) for s in cp.sections()}
def getSections(self, cf): return cf.sections()
from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement from selenium.common.exceptions import TimeoutException from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys IGNORED_EXCEPTIONS = (NoSuchElementException, ) TIME_OUT = 30 #30秒 #解析配置 configparser = configparser.ConfigParser() configparser.read("conf.ini", encoding='utf8') config = {} for section in configparser.sections(): sectionStr = {} config[section] = sectionStr for option in configparser.options(section): sectionStr[option] = configparser.get(section, option) driver_type = config['driver']['driver'] driver_position = config['driver']['driver_path'] + '\chromedriver.exe' driver_env = config['driver']['driver_user_dir'] chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("start-maximized") chrome_options.add_argument('--user-data-dir=' + driver_env) try: driver = webdriver.Chrome(executable_path=driver_position, chrome_options=chrome_options)