def parse_optional(configparser): date_range, sort = None, None if "filter" in configparser: options = configparser["filter"].keys() if "date_range" in options: date = configparser.get("filter", "date_range") date = json.loads(date) # string to list date_range = { "_and": [{ "_gte": { "patent_date": date[0] } }, { "_lte": { "patent_date": date[1] } }] } if "sort" in options: sort = configparser.get("filter", "sort") sort = json.loads(sort) return date_range, sort
def _check_config(configparser, filename): api_id = configparser.get('telegram_api', 'api_id') api_hash = configparser.get('telegram_api', 'api_hash') if api_id == '*api_id here*' or api_hash == 'api_hash': print('Please, edit the config file: ' + filename) exit(1)
def create_conf(configparser, bool): if bool == False: configparser["bot"] = {'prefix': '!', 'token': '{AddBotTokenHere}'} configparser.write(open('config.ini', 'w')) else: local_prefix = configparser.get('bot', 'prefix') local_token = configparser.get('bot', 'token') configparser["bot"] = {'prefix': local_prefix, 'token': local_token} configparser.write(open('config.ini', 'w'))
def sectionToBoardDefinition(configparser, sectionname): """Create a Transformer definition object from file""" items = configparser.items(sectionname) LOG.debug("sectionToBoardDefinition: Item List: " + str(items)) myinput = _readBoardFileRightSideArgs(configparser.get(sectionname, "input"), sectionname) output = _readBoardFileRightSideArgs(configparser.get(sectionname, "output"), sectionname) mytype = configparser.get(sectionname, "type") from pydsl.Memory.File.BoardSection import BoardDefinitionSection return BoardDefinitionSection(sectionname, mytype, myinput, output)
def _check_config(configparser, filename): user_name = configparser.get("spotify_api", "user_name") client_id = configparser.get("spotify_api", "client_id") client_secret = configparser.get("spotify_api", "client_secret") if (client_id == "*your application ID*" or client_secret == "*your application secret*" or user_name == "*your spotify username*"): print("You need to configure: " + filename) exit(1)
def get(self, *args, **kwargs): if sys.version_info[0] > 2: return ConfigParser.get(self, *args, **kwargs) result = ConfigParser.get(self, *args, **kwargs) matches = self.r.search(result) while matches: env_key = matches.group(1) if env_key in os.environ: result = result.replace(matches.group(0), os.environ[env_key]) matches = self.r.match(result) return result
def get_log_path(): """ 获取日志路径 :return: """ try: import configparser configparser = configparser.ConfigParser() configparser.read(config_file) file_handler_args = configparser.get("handler_fileHandler", "args") logargs = str(file_handler_args).replace("(", "").replace(")", "").split(",") logfile = os.path.join(root_path, str(logargs[0]).replace("'", "")) # 创建日志目录 logdir = os.path.dirname(logfile) if not os.path.exists(logdir): os.makedirs(logdir) logargs.pop(0) logargs.insert(0, "'{0}'".format(logfile)) logargs = "({0})".format(",".join(logargs)) configparser.set("handler_fileHandler", "args", logargs) except Exception as ex: traceback.print_stack() return config_file else: return configparser
def decrypt_config_section(config_map, encrypted_sections): decrypted_config_map = {} config_value = '' for config_map_section in config_map: if config_map_section in encrypted_sections: config_names = config.items(config_map_section) for config_name in config_names: config_value = configparser.get(config_map_section, config_name) decrypted_config_map[config_name] = decrypt_config_value(config_value) return decrypted_config_map
def passwordCheck(user, password): configparser = getConfigParser('password.conf') passwordMd5 = getPasswordMd5(password) try: userPassword = configparser.get(user, 'password') except Exception: logging.debug('user is not correct') return False else: if (userPassword == passwordMd5): return True logging.debug('password is not correct') return False
def submit_reader(projectpath, default_description=None, excludes=None, project=None, project_counter=0): """ Read and yield all tasks from the project in path For 'submitted' projects that already have manifests and should not be altered in any way. """ for root, dirs, files in os.walk(projectpath, topdown=True): walkdirs = list(dirs) for file in files: if file == 'ht.manifest.bz2': dirs[:] = [] if root.endswith('.finished'): filepath = os.path.join(root, file) dirpath = root runs = glob.glob(os.path.join(dirpath, "ht.run.*")) runs = sorted(runs, key=lambda d: datetime.datetime.strptime(os.path.basename(d)[7:], "%Y-%m-%d_%H.%M.%S")) if len(runs) >= 1: rundir = runs[-1] dates = [datetime.datetime.strptime(os.path.basename(run)[7:], "%Y-%m-%d_%H.%M.%S") for run in runs] now = datetime.datetime.now() if os.path.exists(os.path.join(dirpath, 'ht_steps')): f = open(os.path.join(dirpath, 'ht_steps')) ht_steps_file = f.readlines() f.close() # Handle runs I did before policy of code name and version in ht_steps script... if ht_steps_file[2].strip() == "# PREINIT run. Runs two relaxations, without being overly concerned with": code = Code('httk formation energy relaxation runs', '0.9') else: codename = ht_steps_file[2][1:].strip() codeversion = ht_steps_file[3][1:].strip() code = Code(codename, codeversion) else: code = Code('unknown', '0') if os.path.exists(os.path.join(dirpath, 'ht.config')): configparser = configparser.ConfigParser() configparser.read(os.path.join(dirpath, 'ht.config')) if configparser.has_option('main', 'description'): description = configparser.get('main', 'description') else: description = default_description else: description = default_description (manifest_hash, signatures, project_key, keys) = read_manifest(filepath, verify_signature=False) relpath = os.path.relpath(root, projectpath) computation = Computation.create(computation_date=dates[-1], added_date=now, description=description, code=code, manifest_hash=manifest_hash, signatures=signatures, keys=keys, relpath=relpath, project_counter=project_counter) if project is not None: computation.add_project(project) yield dirpath, computation
def get_map(section, config_parser): conf_dict = {} try: options = config_parser.options(section) except: log.warning('No section \'{}\' in configuration'.format(section)) return conf_dict for option in options: try: value = config_parser.get(section, option) if value != '': conf_dict[option] = value except: log.warning('Exception on configuration entry: {}'.format(option)) return conf_dict
def decrypt_config_section(config_map, encrypted_sections): decrypted_config_map = {} config_value = '' for config_map_section in config_map: if config_map_section in encrypted_sections: config_names = config.items(config_map_section) for config_name in config_names: config_value = configparser.get(config_map_section, config_name) decrypted_config_map[config_name] = decrypt_config_value( config_value) return decrypted_config_map
def _get_config_setting(self, configparser, section, setting, fn=None): """ Get a section.setting value from the config parser. Takes a configparser instance, a section, a setting, and optionally a post-processing function (typically int). Always returns a value of the appropriate type. """ value = "" try: value = configparser.get(section, setting) value = value.strip() if fn: value = fn(value) except: if fn: value = fn() else: value = "" return value
def main(args): try: resp = cohesity_client.protection_jobs.get_protection_jobs( environments=EnvironmentEnum.KGENERICNAS, names=args.job_name) if len(resp) == 0: # No protection Job exist. print("No protection job with : %s" % args.job_name) exit(1) if len(resp) > 1: print("More than one protection job exists with this prefix." "Provide the Protection job name more specifically.") exit(1) for job in resp: cohesity_nfs_name = args.cohesity_nfs_name body = RecoverTaskRequest() body.name = 'Recover-' + cohesity_nfs_name body.mtype = "kMountFileVolume" body.view_name = cohesity_nfs_name body.objects = [] body.objects.append(RestoreObjectDetails()) body.objects[0].job_id = job.id body.objects[0].protection_source_id = job.source_ids[0] body.restore_view_parameters = UpdateViewParam() body.restore_view_parameters.protocol_access = ProtocolAccessEnum.KNFSONLY body.restore_view_parameters.qos = QoS() body.restore_view_parameters.qos.principal_name = \ configparser.get('cohesity', 'nfs_target_qos') cohesity_client.restore_tasks.create_recover_task(body=body) print("Scheduled to create NFS share %s." % cohesity_nfs_name) #TODO: poll for the restore task and copy NFS mount path. except APIException as ex: SystemExit("Unable to create Cohesity NFS share. Error: %s" % ex.message) print("Successfully created NFS share %s on Cohesity." % args.cohesity_nfs_name)
def randomword(length): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(length)) ################# # # # CONFIG # # # ################# configparser = configparser.RawConfigParser() configFilePath = r'conf/app.conf' configparser.read(configFilePath) host = configparser.get('ServerSettings', 'host') port = configparser.get('ServerSettings', 'port') autoreload = configparser.get('ServerSettings', 'autoreload') debug = configparser.get('ServerSettings', 'debug') db = configparser.get('ServerSettings', 'db') conn = sqlite3.connect(db) c = conn.cursor() print(banner + "\n" + "Version: " + version) # Main Webseite @route('/', method=['GET']) def index(): uhrzeit = time.strftime(" " + "%H:%M:%S")
opts, args = getopt.getopt(sys.argv[1:], "t:") except getopt.GetoptError: print("Usage: {0} [-t tags] url [url ...]".format(sys.argv[0])) sys.exit(2) for opt, arg in opts: if opt == "-t": tags = arg config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "jopleet.config") configparser = configparser.RawConfigParser() configparser.read(config) jurl = configparser.get('authentication', 'joplin_url') token = configparser.get('authentication', 'token') parent_folder = configparser.get('authentication', 'parent_folder') ConsumerKey = configparser.get('authentication', 'ConsumerKey') ConsumerSecret = configparser.get('authentication', 'ConsumerSecret') AccessToken = configparser.get('authentication', 'AccessToken') AccessTokenSecret = configparser.get('authentication', 'AccessTokenSecret') auth = tweepy.OAuthHandler(ConsumerKey, ConsumerSecret) auth.set_access_token(AccessToken, AccessTokenSecret) api = tweepy.API(auth) for url in args: status_id = url.split('/')[-1]
from flask_migrate import Migrate import configparser import hashlib # Internal Libraries are loaded after we set up logging import data app = Flask(__name__) app.secret_key = b'h14ot89rx8901prnz179tr59c1p8r89podumail' app.config["JSONIFY_PRETTYPRINT_REGULAR"] = True configparser = configparser.RawConfigParser() configFilePath = r'config.conf' configparser.read(configFilePath) host = configparser.get('sql', 'host') user = configparser.get('sql', 'user') password = configparser.get('sql', 'password') database = configparser.get('sql', 'database') app.config['SQLALCHEMY_DATABASE_URI'] = 'mssql+pymssql://{}:{}@{}/{}'.format( user, password, host, database) saDB = SQLAlchemy(app) migrate = Migrate(app, saDB) from models import Users, Conversations, Messages, db version = '0.0.1' def checkLoggedIn():
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'))
'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'afscheck.wsgi.application' # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'HOST': configparser.get('mysql', 'host'), 'NAME': configparser.get('mysql', 'database'), 'USER': configparser.get('mysql', 'username'), 'PASSWORD': configparser.get('mysql', 'password'), 'PORT': '3306', 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" } } } # Password validation # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ {
#!/usr/bin/env python3 import os, sys, json, glob, argparse, configparser from datetime import datetime, timedelta import pandas, requests ini_path = os.path.abspath(os.path.dirname(sys.argv[0])) #config Datei im gleichen Verzeichnis ausfindig machen configparser = configparser.RawConfigParser() configFilePath = ini_path + '/' + 'config.ini' configparser.read(configFilePath) #Loginwerte var_clockodo_api = configparser.get('Login', 'api key') var_clockodo_user = configparser.get('Login', 'user') var_user_id = configparser.get('Login', 'user id') #Variabeln fuer die richtigen Projektzuordnung ProjectIdentfier1 = configparser.get('ProjectIdentfier', 'ProjectIdentfier1') ProjectIdentfier2 = configparser.get('ProjectIdentfier', 'ProjectIdentfier2') ProjectIdentfier3 = configparser.get('ProjectIdentfier', 'ProjectIdentfier3') ProjectIdentfier4 = configparser.get('ProjectIdentfier', 'ProjectIdentfier4') ProjectIdentfier5 = configparser.get('ProjectIdentfier', 'ProjectIdentfier5') ProjectIdentfier6 = configparser.get('ProjectIdentfier', 'ProjectIdentfier6') ProjectIdentfier7 = configparser.get('ProjectIdentfier', 'ProjectIdentfier7') #Code fuer die Projekte def Project1():
def Project7(): global var_projects_id, var_customer_id, var_services_id, var_billable var_projects_id = configparser.get('Project7', 'Project ID') var_customer_id = configparser.get('Project7', 'Customer ID') var_services_id = configparser.get('Project7', 'Services ID') var_billable = configparser.get('Project7', 'Billable')
content += '\n' content += 'TODO: \n\n' content += 'Thanks, \n' content += 'Flyn \n' return content date = time.strftime('%Y%m%d', time.localtime(time.time())) title = 'Daily_Report_Flyn_%s' % date configparser = configparser.ConfigParser() configparser.read(os.path.dirname(os.path.realpath(__file__)) + '\\config.txt') mail_sender = MailSender() mail_sender.to_address = configparser.get("Info", "to_address") mail_sender.from_address = configparser.get("Info", "from_address") mail_sender.my_name = configparser.get("Info", "my_name") mail_sender.password = configparser.get("Info", "password") mail_sender.smtp_server = configparser.get("Info", "smtp_server") mail_sender.smtp_server_port = configparser.get("Info", "smtp_server_port") paths = configparser.get("Info", "path") # type:str path_list = paths.split(",") git_logs = git.get_commit_logs(path_list, 'flyn.yu') content = get_mail_content(git_logs) app = QApplication(sys.argv) mail_ui = MailUI()
# SQLITE fuer die Stechuhr # ############################## import sqlite3 from typing import List import configparser import random, string ################# # # # CONFIG # # # ################# configparser = configparser.RawConfigParser() configFilePath = r'conf/app.conf' configparser.read(configFilePath) db = configparser.get('ServerSettings', 'db') def randomword(length): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(length)) verbindung = sqlite3.connect(db) cursor = verbindung.cursor() befehle = [] ############ SQL-Section ############ print( "SQL-Tool zur Zeiterfassung"
from pygame import mixer import os import configparser configparser = configparser.RawConfigParser() configFilePath = os.path.join(os.path.dirname(__file__), 'space_odyssey.cfg') configparser.read(configFilePath) # Intialize the pygame pygame.init() # create the screen screen = pygame.display.set_mode((1000, 950)) # Background backgroundimage = configparser.get("images", "backgroundimage") background = pygame.image.load(backgroundimage) # mixer.music.load("background.wav") # mixer.music.play(-1) mixer.music.load("explosion.wav") mixer.music.play(-1) # game name and title pygame.display.set_caption("mygame") #icon = pygame.image.load('icon.png') #pygame.display.set_icon(icon) asteroid_speed = configparser.getint("integers", "asteroid_speed") rocket1_img = pygame.image.load('rocket1.png') rocket1_x = configparser.getint("integers", "rocket1_x")
os.umask(originalumask) if err.errno != errno.EEXIST or not os.path.isdir(newdir) and os.path.splitdrive(newdir)[1]: raise os.umask(originalumask) ### raise this if something is wrong in this config file class LeginonConfigError(Exception): pass configparser = configparser.configparser # drive mapping drives = configparser.options('Drive Mapping') for drive in drives: drivepath = drive.upper() + ':' pathmapping[drivepath] = configparser.get('Drive Mapping', drive) # image path IMAGE_PATH = configparser.get('Images', 'path') # project try: default_project = configparser.get('Project', 'default') except: default_project = None # check to see if image path has been set, then create it if not IMAGE_PATH: raise LeginonConfigError('set IMAGE_PATH in leginonconfig.py') try: mkdirs(mapPath(IMAGE_PATH))
os.umask(originalumask) ### raise this if something is wrong in this config file class LeginonConfigError(Exception): pass configparser = configparser.configparser # drive mapping if configparser.has_section('Drive Mapping'): drives = configparser.options('Drive Mapping') for drive in drives: drivepath = drive.upper() + ':' pathmapping[drivepath] = configparser.get('Drive Mapping', drive) # image path if configparser.has_section('Images'): IMAGE_PATH = configparser.get('Images', 'path') else: sys.stderr.write( 'Warning: You have not configured Images path in leginon.cfg! Using current directory.\n' ) IMAGE_PATH = os.path.abspath(os.curdir) if sys.platform == 'win32': mapped_path = mapPath(IMAGE_PATH) else: mapped_path = IMAGE_PATH if not os.access(mapped_path, os.W_OK):
import pandas_profiling import time import configparser as configParser import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from sklearn.preprocessing import LabelEncoder start_time = time.time() #getting data from configuration file configParser = configParser.RawConfigParser() configFilePath = 'configuration.txt' configParser.read(configFilePath) input_path = configParser.get('input', 'path') output_path = configParser.get('output', 'path') input_file = configParser.get('input', 'input_file') target_variable = configParser.get('input', 'target_variable') #reading the dataset train = pd.read_csv(input_path + input_file + ".csv", encoding='ISO-8859-1') #removing the unique column fields: for i in train.columns: if (len(train[i]) == train[i].nunique()): train.drop([i], axis=1, inplace=True) #converting few numerical values into objects based on unique values for i in train.columns: if (train.dtypes[i] != np.object):
def user_configuration(self,configFile=None): # get a logger logger = logging.getLogger("configuration") # load and parse the provided configFile, if provided if not configFile: logger.warn('no user configuration file provided; using only built-in default settings') return # load the config file try: configparser = configparser.ConfigParser() configparser.readfp(open(configFile)) logger.debug('successfully read and parsed user configuration file %s' % configFile) except: logger.fatal('error reading user configuration file %s' % configFile) raise #work_dir must be provided before initialising other directories self.work_dir = None if self.work_dir == None: try: self.work_dir = configparser.get('Paths', 'work') except (configparser.NoSectionError, configparser.NoOptionError): if self.work_dir == None: logger.critical('Paths:work has no value!') raise Exception # default place for some data self.data_dir = os.path.join(self.work_dir, 'data') self.tensorflow_dir = os.path.join(self.work_dir, 'tensorflow') self.gen_dir = os.path.join(self.tensorflow_dir, 'gen') self.model_dir = os.path.join(self.tensorflow_dir, 'models') self.stats_dir = os.path.join(self.tensorflow_dir, 'stats') self.inter_data_dir = os.path.join(self.work_dir, 'inter_module') self.def_inp_dir = os.path.join(self.inter_data_dir, 'nn_no_silence_lab_norm_425') self.def_out_dir = os.path.join(self.inter_data_dir, 'nn_norm_mgc_lf0_vuv_bap_187') impossible_int=int(-99999) impossible_float=float(-99999.0) user_options = [ # Paths ('work_dir', self.work_dir, 'Paths','work'), ('data_dir', self.data_dir, 'Paths','data'), ('inp_feat_dir', self.def_inp_dir, 'Paths', 'inp_feat'), ('out_feat_dir', self.def_out_dir, 'Paths', 'out_feat'), ('model_dir', self.model_dir, 'Paths', 'models'), ('stats_dir', self.stats_dir, 'Paths', 'stats'), ('gen_dir' , self.gen_dir, 'Paths', 'gen'), ('file_id_scp', os.path.join(self.data_dir, 'file_id_list.scp'), 'Paths', 'file_id_list'), ('test_id_scp', os.path.join(self.data_dir, 'test_id_list.scp'), 'Paths', 'test_id_list'), # Input-Output ('inp_dim', 425, 'Input-Output', 'inp_dim'), ('out_dim', 187, 'Input-Output', 'out_dim'), ('inp_file_ext', '.lab', 'Input-Output', 'inp_file_ext'), ('out_file_ext', '.cmp', 'Input-Output', 'out_file_ext'), ('inp_norm', 'MINMAX', 'Input-Output', 'inp_norm'), ('out_norm', 'MINMAX', 'Input-Output', 'out_norm'), # Architecture ('hidden_layer_type', ['TANH', 'TANH', 'TANH', 'TANH', 'TANH', 'TANH'], 'Architecture', 'hidden_layer_type'), ('hidden_layer_size', [ 1024 , 1024 , 1024 , 1024 , 1024 , 1024], 'Architecture', 'hidden_layer_size'), ('batch_size' , 256, 'Architecture', 'batch_size'), ('num_of_epochs', 1, 'Architecture', 'training_epochs'), ('dropout_rate' , 0.0, 'Architecture', 'dropout_rate'), ('output_layer_type', 'linear', 'Architecture', 'output_layer_type'), ('optimizer' , 'adam', 'Architecture', 'optimizer'), ('loss_function' , 'mse', 'Architecture', 'loss_function'), # RNN ('sequential_training', False, 'Architecture', 'sequential_training'), ('stateful' , False, 'Architecture', 'stateful'), ('use_high_batch_size', False, 'Architecture', 'use_high_batch_size'), ('training_algo', 1, 'Architecture', 'training_algo'), ('merge_size' , 1, 'Architecture', 'merge_size'), ('seq_length' , 200, 'Architecture', 'seq_length'), ('bucket_range' , 100, 'Architecture', 'bucket_range'), #encoder_decoder ('encoder_decoder' , False , 'Architecture','encoder_decoder'), ('attention' , False , 'Architecture', 'attention'), ("cbhg" , False , "Architecture", "cbhg"), # Data ('shuffle_data', False, 'Data', 'shuffle_data'), ('train_file_number', impossible_int, 'Data','train_file_number'), ('valid_file_number', impossible_int, 'Data','valid_file_number'), ('test_file_number' , impossible_int, 'Data','test_file_number'), # Processes ('NORMDATA' , False, 'Processes', 'NORMDATA'), ('TRAINMODEL', False, 'Processes', 'TRAINMODEL'), ('TESTMODEL' , False, 'Processes', 'TESTMODEL') ] # this uses exec(...) which is potentially dangerous since arbitrary code could be executed for (variable,default,section,option) in user_options: # default value value=None try: # first, look for a user-set value for this variable in the config file value = configparser.get(section,option) user_or_default='user' except (configparser.NoSectionError, configparser.NoOptionError): # use default value, if there is one if (default == None) or \ (default == '') or \ ((type(default) == int) and (default == impossible_int)) or \ ((type(default) == float) and (default == impossible_float)) : logger.critical('%20s has no value!' % (section+":"+option) ) raise Exception else: value = default user_or_default='default' if type(default) == str: exec('self.%s = "%s"' % (variable,value)) elif type(default) == int: exec('self.%s = int(%s)' % (variable,value)) elif type(default) == float: exec('self.%s = float(%s)' % (variable,value)) elif type(default) == bool: exec('self.%s = bool(%s)' % (variable,value)) elif type(default) == list: exec('self.%s = list(%s)' % (variable,value)) elif type(default) == dict: exec('self.%s = dict(%s)' % (variable,value)) else: logger.critical('Variable %s has default value of unsupported type %s',variable,type(default)) raise Exception('Internal error in configuration settings: unsupported default type') logger.info('%20s has %7s value %s' % (section+":"+option,user_or_default,value) )
def _read_from_config(configparser, section, value, fallback=None): try: return configparser.get(section, value) except Exception: return fallback
import pygame import random import math import os import configparser configparser = configparser.RawConfigParser() configFilePath = os.path.join(os.path.dirname(__file__), 'myconfig.cfg') configparser.read(configFilePath) gameName = configparser.get("basicinfo", "name") gaovt1 = configparser.get("gameoverinfo", "g1t") gaovt2 = configparser.get("gameoverinfo", "g2t") gaovt3 = configparser.get("gameoverinfo", "g3t") gaovt4 = configparser.get("gameoverinfo", "g4t") gaovt5 = configparser.get("gameoverinfo", "g5t") gaovt6 = configparser.get("gameoverinfo", "g6t") gaovt7 = configparser.get("gameoverinfo", "g7t") gfont = configparser.get("basicinfo", "gamefont") gamelevel = configparser.get("basicinfo", "lvl") sp = configparser.getint("basicinfo", "plsp") speedobj = configparser.getfloat("basicinfo", "obsp") colout_mutable = [] coloutlist = str(configparser.get("basicinfo", "black")).split(',') for val in coloutlist: colout_mutable.append(int(val)) coloutb = tuple(colout_mutable) colout_mutablew = [] coloutlistw = str(configparser.get("basicinfo", "white")).split(',') for val in coloutlistw: colout_mutablew.append(int(val)) coloutw = tuple(colout_mutablew)
def reader(projectpath, inpath, excludes=None, default_description=None, project_counter=0, force_remake_manifests=False): """ Read and yield all tasks from the project in path """ keydir = os.path.join(projectpath, 'ht.project', 'keys') pk = None sk = None for root, dirs, files in os.walk(inpath, topdown=True): walkdirs = list(dirs) for dir in walkdirs: if dir.startswith('ht.task.'): dirs.remove(dir) if dir.endswith('.finished'): dirpath = os.path.join(root, dir) filepath = os.path.join(dirpath, 'ht.manifest.bz2') runs = glob.glob(os.path.join(dirpath, "ht.run.*")) runs = sorted(runs, key=lambda d: datetime.datetime.strptime(os.path.basename(d)[7:], "%Y-%m-%d_%H.%M.%S")) if len(runs) < 1: continue rundir = runs[-1] dates = [datetime.datetime.strptime(os.path.basename(run)[7:], "%Y-%m-%d_%H.%M.%S") for run in runs] now = datetime.datetime.now() if os.path.exists(os.path.join(dirpath, 'ht_steps')): f = open(os.path.join(dirpath, 'ht_steps')) ht_steps_file = f.readlines() f.close() # Handle runs I did before policy of code name and version in ht_steps script... codename = ht_steps_file[2][1:].strip() codeversion = ht_steps_file[3][1:].strip() code = Code(codename, codeversion) else: code = Code('unknown', '0') if os.path.exists(os.path.join(dirpath, 'ht.config')): configparser = configparser.ConfigParser() configparser.read(os.path.join(dirpath, 'ht.config')) if configparser.has_option('main', 'description'): description = configparser.get('main', 'description') else: description = default_description else: description = default_description if not os.path.exists(os.path.join(dirpath, 'ht.manifest.bz2')) or force_remake_manifests: if pk is None: sk, pk = read_keys(keydir) sys.stderr.write("Warning: generating manifest for "+str(dirpath)+", this takes some time.\n") manifestfile = bz2.BZ2File(os.path.join(dirpath, 'ht.tmp.manifest.bz2'), 'w') manifest_dir(dirpath, manifestfile, os.path.join(dirpath, 'ht.config'), keydir, sk, pk, force=force_remake_manifests) manifestfile.close() os.rename(os.path.join(dirpath, 'ht.tmp.manifest.bz2'), os.path.join(dirpath, 'ht.manifest.bz2')) (manifest_hash, signatures, project_key, keys) = read_manifest(os.path.join(dirpath, 'ht.manifest.bz2'), verify_signature=False) #(input_manifest, input_hexhash) = check_or_generate_manifest_for_dir(code.name,code.version, path, excluderuns, None, False) # Relpath is this tasks path relative to the *project* path. relpath = os.path.relpath(root, projectpath) computation = Computation.create(computation_date=dates[-1], added_date=now, description=description, code=code, manifest_hash=manifest_hash, signatures=signatures, keys=keys, relpath=relpath, project_counter=project_counter) yield rundir, computation
def debug_log(self, line): self.connection.debug_log(line) def error_log(self, line): self.connection.error_log(line) def update(self): err = self.handle_input() while err and not self.quitting: print("Disconnected from server. Reconnecting.. ") self.error_log("Disconnected from server. Reconnecting.. ") err = self._init() if __name__=="__main__": parser = parser.SafeConfigParser(allow_no_value=True) parser.read(["bot.cfg"]) server = parser.get("bot","server") port = parser.getint("bot","port") passw = parser.get("bot","pass") user = parser.get("bot","user") realname = parser.get("bot","realname") nick = parser.get("bot","nick") log = parser.get("bot","log") debug = parser.getint("bot","debug") ssl = parser.getint("bot","ssl") bot = IrcBot(server, port, passw, user, realname, nick, log, debug, ssl) while not bot.quitting: bot.update()
# Check if the config file exists (If not, exit script) if not os.path.isfile(sys.argv[1]): print("Please provide a valid file for the config.\nYour provided: " + str(sys.argv[1])) raise SystemExit(0) else: print("Config file found.") configFilePath = sys.argv[1] # Pull in variables from config file configparser = configparser.RawConfigParser() configparser.read(configFilePath) # General group outputPath = configparser.get('General', 'outputPath') subfolderToggle = configparser.get('General', 'subfolderToggle') getComments = configparser.get('General', 'getComments') getImage = configparser.get('General', 'getImage') imageNameType = configparser.get('General', 'imageNameType') runHeadless = configparser.get('General', 'runHeadless') buildHTML = configparser.get('General', 'buildHTML') # Comic group comicName = configparser.get('Comic', 'comicName') comicStartPage = configparser.get('Comic', 'comicStartPage') commentPath = configparser.get('Comic', 'commentPath') imageTitlePath = configparser.get('Comic', 'imageTitlePath') nextButtonPath = configparser.get('Comic', 'nextButtonPath') nextButtonType = configparser.get('Comic', 'nextButtonType') imagePath = configparser.get('Comic', 'imagePath') initialClick = configparser.get('Comic', 'initialClick')
fh.setLevel(logging.DEBUG) formatter = logging.Formatter('[%(asctime)s] - %(message)s', '%Y-%m-%d %H:%M:%S') fh.setFormatter(formatter) logger.addHandler(fh) logger.debug('') logger.debug('') logger.debug('') logger.info('=== Primetime Started ===') logger.debug('Initializing Flask App') # start our flask app and define endpoints app = Flask(__name__) app.secret_key = configparser.get('general', 'appSecret') logger.info('Flask Initialized') # Keys for providing OAuth app.config['DISCORD_CLIENT_ID'] = configparser.getint('discord', 'client') app.config['DISCORD_CLIENT_SECRET'] = configparser.get('discord', 'secret') app.config['DISCORD_REDIRECT_URI'] = configparser.get('discord', 'callback') # Checking guild/role applicability, effectivly handing off authentication to Discord app.config['DISCORD_GUILD_ID'] = configparser.getint('discord', 'guild') app.config['DISCORD_REQUIRE_ROLE'] = configparser.getboolean( 'discord', 'requireRole') app.config['DISCORD_ROLE_ID'] = configparser.getint('discord', 'role') app.config['STREAM_LOCATION'] = configparser.get('general', 'streamLocation')
# new rule: v-tubers aren't idols # plus there's too many of them import time from flask import Flask, render_template, request, Response, Markup import idol import traceback import configparser import logging from threading import Thread configparser = configparser.RawConfigParser() configFilePath = r'config.conf' configparser.read(configFilePath) matrixCom = configparser.get('general', 'matrixCom') matrixType = configparser.get('general', 'matrixType') musicSource = configparser.get('general', 'musicSource') dtvSources = configparser.get('general', 'dtvSources').split(',') sourceNames = configparser.get('general', 'sourceNames').split(',') numberOfTargets = configparser.get('general', 'numberOfTargets') projectorLayout = configparser.get('general', 'projectorLayout') # "twos" or "threes" zones = configparser.get('general', 'zones') numberOfZones = len(zones.split(',')) zoneNames = configparser.get('general', 'zoneNames').split(',') targetIPs = configparser.get('general','targetIPs').split(',') # hook into the logger logger = idol.logger # initialize our flask app
# new rule: v-tubers aren't idols # plus there's too many of them import time from flask import Flask, render_template, request, Response, Markup import idol import traceback import configparser import logging from threading import Thread configparser = configparser.RawConfigParser() configFilePath = r'config.conf' configparser.read(configFilePath) matrixCom = configparser.get('general', 'matrixCom') matrixType = configparser.get('general', 'matrixType') musicSource = configparser.get('general', 'musicSource') dtvSources = configparser.get('general', 'dtvSources').split(',') sourceNames = configparser.get('general', 'sourceNames').split(',') numberOfTargets = configparser.get('general', 'numberOfTargets') projectorLayout = configparser.get('general', 'projectorLayout') # "twos" or "threes" zones = configparser.get('general', 'zones') numberOfZones = len(zones.split(',')) zoneNames = configparser.get('general', 'zoneNames').split(',') targetIPs = configparser.get('general', 'targetIPs').split(',') # hook into the logger logger = idol.logger