def initConfigFile(self): """ 初始化配置文件 :return: """ config = ConfigFile() self.configParams = config.readConfigParams()
def __init__(self, tipi_io): self.tipi_io = tipi_io self.specreg = { ClockFile.filename(): ClockFile(self.tipi_io), ConfigFile.filename(): ConfigFile(self.tipi_io), CurlFile.filename(): CurlFile(self.tipi_io), PioFile.filename(): PioFile(self.tipi_io), RebootFile.filename(): RebootFile(self.tipi_io), ShutdownFile.filename(): ShutdownFile(self.tipi_io), StatusFile.filename(): StatusFile(self.tipi_io), TcpFile.filename(): TcpFile(self.tipi_io), UpgradeFile.filename(): UpgradeFile(self.tipi_io), VariablesFile.filename(): VariablesFile(self.tipi_io) }
def ReadConfig(self): self.configFile = ConfigFile() configItems=self.configFile.ReadConfig() for item in configItems: part=item.strip('\n').split('&&') if len(part)!=1: if part[0]=='attrFilePath': self.attrFilePath=part[1] self.LoadJson() elif part[0]=='plugeDictionaryFilePath': self.plugeDictionaryFilePath=part[1] self.PlugeDict() elif part[0]=='saveCorpusFilePath': self.saveCorpusFilePath=part[1] self.SaveCorpus() elif part[0]=='readCorpusFilePath': self.readCorpusFilePath=part[1] self.LoadCorpus() elif part[0]=='historyInputList': self.historyInputList=part[1].split('||')
from ConfigFile import ConfigFile from ConfigFile import LogFile # variables used for debugging the code DEBUG = False WIN_DEBUG = False # specifies the root directory for the program to be run in. ROOT_DIR = '/users/groups/cs235ta/submission_driver/' # if running on a windows machine, adjust accordingly. if WIN_DEBUG: ROOT_DIR = 'path' # create the config file object from the file. config_file_object = ConfigFile(ROOT_DIR + 'compiler_global.cfg') #=====================================================# # store_grade # # ammends the given file, updating the # # net_id's score, or inserting it if the first # # submission. # # # # the file that this function will update is # # "LabXXgrades.csv". This file is located in # # the "/public_html/XX20XX_submissions" folder # # # # Parameters: # # file_name (str): e.g. "Lab01grades.csv" # net_id (): The student's net ID
from LogFile import LogFile #my logging mechs from LogFile import ErrorMsg #the error struct from datetime import date from LogFile import SeverityLevel import datetime import os import re import pandas as pn import xlrd import shutil ##### methods ###### #entry point #load up our config. only place with out a log Cfg = ConfigFile("File2JsonConfig.xml") Log = LogFile(Cfg.logpath) TotalFilesProcessed = 0 TotalRecordsProcessed = 0 TotalErrors = 0 try: xlspattern = re.compile(r"\w+\.xl(s|sm|sx)") #we'll loop through the files, and process them indvidually. for thefiles in os.listdir(Cfg.source_directory): sumJson = "[" try: print("Processing File " + str(TotalFilesProcessed)) TotalFilesProcessed = TotalFilesProcessed + 1
main() my_generator = (letter for letter in 'abcdefg') #import tempfile #[fh,filename]=tempfile.mkstemp(prefix="tmp."); #print(filename,fh) #os.close(fh) import TempFilename filename=TempFilename.generate() fh=open(filename,'w') print(fh) x=0 while(x<10): fh.write(str(x)); x+=3 fh.close() os.remove(filename) config=ConfigFile("test/data/ice.0-43.config") print(config.lookup("donor-consensus")) a=[1.1, 6.4, 9.3, 3.4, 9.2, 4.6, 1.6, 0.3] b=list(map(lambda x:x+random.uniform(-10,10),a)) [mean,SD,min,max]=SummaryStats.summaryStats(a) print(mean,"+/-",SD) print("sum=",SummaryStats.sum(a)) print("r=",SummaryStats.correlation(a,b))
def main(activation_path,logFile): startTime = datetime.now() conf_file = ConfigFile("config.json") attri = conf_file.readJson() path = activation_path logs_text = attri['logsText']["main"] if os.path.isdir(path): activation_code = os.path.basename(path) try: dirct_arr = [] #save the retunr of each function valid to storage the shapefile array that after is insert in geopdf #hacer que guarde todas dentro del diccionario ver como lo actualiza para luego cuando valla ala otra carpeta tire de estas values={} for dirs in os.listdir(path): #walk inside each main folder "VECTOR, RASTER and RTP" gdb = attri["FoldersToCheck"][0] lyr = attri["FoldersToCheck"][1] report = attri["FoldersToCheck"][2] has_gdb = False if path.find("AEM") != -1: pass else: #check the different folders inside the product_version folder. #1.Check the VECTOR folder if gdb in dirs: root2 = os.path.join(path, gdb) for root3, dirs_gdb, files in os.walk(root2): #get the different vector layer names if len(dirs_gdb) > 0: for dir in dirs_gdb: if attri["VectorFormats"]["GDB"]["types"][0] in dir: path = os.path.join(root3, dir) VectorLayer = globals()[attri["VectorFormats"]["GDB"]["className"]] vectortype = VectorLayer(root3,attri,activation_code) vectortype.checkextension(path) has_gdb= True elif len(dirs_gdb) == 0 and len(files) > 0 and has_gdb== False: err = logs_text["no_gdb"].copy() initial_err = activation_code + "|" + splitroot(root3,activation_code) + "|" + gdb + "|" + logFile.getCatValue( attri['VectorFormats']['GDB']['not_correct_file']) + "|" + logFile.getIssueValue(attri['VectorFormats']['GDB']['not_correct_file']) +"|" err.insert(0,initial_err) logFile.writelogs(err) for file in files: err2 = logs_text["extension"].copy() initial_err = activation_code + "|" + splitroot(root3,activation_code) + "|" + gdb + "|" + logFile.getCatValue( attri['VectorFormats']['GDB']['not_correct_file']) + "|" + logFile.getIssueValue(attri['VectorFormats']['GDB']['not_correct_file']) +"|" err2.insert(0,initial_err) err2.insert(2,file) logFile.writelogs(err2) #validate each vector layer elif lyr in dirs: root2 = os.path.join(path, lyr) for root3, dirs_lyr, files in os.walk(root2): VectorLayer = globals()[attri["VectorFormats"]["symbology"]["className"]] vectortype = VectorLayer(root3,attri,activation_code) vectortype.checkextension(files) elif report in dirs: root2 = os.path.join(path, report) for root3, dirs_lyr, files in os.walk(root2): VectorLayer = globals()[attri["VectorFormats"]["report"]["className"]] vectortype = VectorLayer(root3,attri,activation_code) vectortype.checkextension(files) time = logs_text["time"] #shutil.rmtree(attri["Temp_root"]) time.append(str(datetime.now() - startTime)) #logFile.writelogs(time) #print("FINISH") except Exception as ex: e = logs_text["e"] e.append(str(ex)) logFile.writelogs(e) time = logs_text["time"] time.append(str(datetime.now() - startTime)) logFile.writelogs(time)
import sys from ConfigFile import ConfigFile cd = ConfigFile('config_file.txt') if len(sys.argv) == 3: key = sys.argv[1] value = sys.argv[2] print('writing data: {0}, {1}'.format(key, value)) cd[key] = value else: print('reading data') for key in cd.keys(): print(' {0} = {1}'.format(key, cd[key]))
def __init__(self): cfg = ConfigFile(FILE_COPY_CONFIG_PATH) self.copier = FileCopier(cfg.file_copier_spec())