def writeToFile(rowValue, dateAndTime): # DATA DATA = Config.configReader() STUDENTS = DATA["students"] CONFIG = DATA["config"] # UPDATE SUBMISSION SECRET_CODE_COL = CONFIG["SECRET_CODE_COL"] PROBLEM_CODE_COL = CONFIG["PROBLEM_CODE_COL"] CODE_COL = CONFIG["CODE_COL"] FILE_TYPE = CONFIG["FILE_TYPE"] # FOLDER URL FILE_OUT_AT = CONFIG["FILE_OUT_AT"] if not os.path.exists(FILE_OUT_AT): os.makedirs(FILE_OUT_AT) # PRINT timestamp = time.mktime(time.strptime(dateAndTime, '%m/%d/%Y %H:%M:%S')) timestamp = int(timestamp) studentName = STUDENTS.get(rowValue[SECRET_CODE_COL], None) if (studentName == None): return timestamp problemName = rowValue[PROBLEM_CODE_COL] fileName = "{}{}[{}][{}].{}".format(FILE_OUT_AT, timestamp, studentName, problemName, FILE_TYPE) code = rowValue[CODE_COL] fp = open(fileName, "w") fp.write(code) fp.close() return timestamp
def readConfig(self): cf = configReader(CONFIG_NAME) self.config = {} self.config['button_student_choose_on'] = fun.toRgb( cf.readConfig('Colour', 'button_student_choose_on')) self.config['button_file_choose_on'] = fun.toRgb( cf.readConfig('Colour', 'button_file_choose_on')) self.config['button_choose_on'] = fun.toRgb( cf.readConfig('Colour', 'button_choose_on')) self.config['button_choose_off'] = fun.toRgb( cf.readConfig('Colour', 'button_choose_off')) self.config['host'] = cf.readConfig('Server', 'host') self.config['port'] = int(cf.readConfig('Server', 'port')) self.config['text_ctrl_colour'] = cf.readConfig( 'Font', 'text_ctrl_colour') self.config['text_ctrl_fontsize'] = cf.readConfig( 'Font', 'text_ctrl_fontsize') self.config['server_store_file_path'] = cf.readConfig( 'File', 'server_store_file_path') self.config['server_send_file_path'] = cf.readConfig( 'File', 'server_send_file_path') self.config['client_send_file_path'] = cf.readConfig( 'Client', 'client_send_file_path') self.config['client_store_file_path'] = cf.readConfig( 'Client', 'client_store_file_path') self.config['split_sep'] = cf.readConfig('File', 'split_sep') self.config['task'] = True self.config['job'] = False self.config['file'] = False
def __init__(self): self.mailHelper = mailHelper() self.configReader = configReader(self.CONFIGPATH) commandDict = self.configReader.getDict(self.KEY_COMMAND) self.timeLimit = int( self.configReader.readConfig(self.KEY_BOSS, self.KEY_TIMELIMIT)) self.excutor = executor(commandDict) self.toRun()
def __init__(self): self.mccLog = mccLog() cfReader = configReader(self.CONFIGPATH) self.username = cfReader.readConfig('Slave', 'username') self.password = cfReader.readConfig('Slave', 'password') self.bossMail = cfReader.readConfig('Boss', 'mail') self.account = None self.loginMail() self.configSlaveMail()
def __init__(self, configurationFile, runInteractive=False): print("Setting up program...") self.runInteractive = runInteractive self.setInteractive(runInteractive) self.configReader = configReader(configurationFile, runInteractive) self.getImageFileList() self.getDarkfieldFileList() self.getBackgroundFileList() self.imagePreprocessor = imagePreprocessor(self.configReader) self.imagePreprocessor.loadDarkfield( self.darkfieldList) # load darkfield images self.imagePreprocessor.loadBackground( self.backgroundList) # load background images self.setupClContext() self.setupManagementQueue() self.setupClVariables() self.printAvailableOpenclDevices() self.printTrackingSetupInformation() self.configReader.runConfigChecks() self.setupContourTracker() if self.configReader.nrOfFramesToSaveFitInclinesFor: self.fitInclines = np.empty( (self.configReader.nrOfContourPoints, self.configReader.nrOfFramesToSaveFitInclinesFor), dtype=np.float64) if self.configReader.snrRoi is not None: self.imageSnr = np.zeros((1, self.totalNrOfImages), dtype=np.float64) self.imageIntensity = np.zeros((1, self.totalNrOfImages), dtype=np.float64) self.contourCoordinatesX = np.empty( (self.configReader.nrOfContourPoints, self.totalNrOfImages), dtype=np.float64) self.contourCoordinatesY = np.empty( (self.configReader.nrOfContourPoints, self.totalNrOfImages), dtype=np.float64) self.contourNormalVectorsX = np.empty( (self.configReader.nrOfContourPoints, self.totalNrOfImages), dtype=np.float64) self.contourNormalVectorsY = np.empty( (self.configReader.nrOfContourPoints, self.totalNrOfImages), dtype=np.float64) self.contourCenterCoordinatesX = np.empty(self.totalNrOfImages, dtype=np.float64) self.contourCenterCoordinatesY = np.empty(self.totalNrOfImages, dtype=np.float64) self.nrOfIterationsPerContour = np.zeros(self.totalNrOfImages, dtype=np.int32) self.executionTimePerContour = np.zeros(self.totalNrOfImages, dtype=np.float64)
def __init__(self): #self.mccLog = mccLog() cfReader = configReader(self.CONFIGPATH) self.pophost = cfReader.readConfig("Slave", "pophost") self.smtphost = cfReader.readConfig("Slave", "smtphost") self.port = cfReader.readConfig("Slave", "port") self.username = cfReader.readConfig("Slave", "username") self.password = cfReader.readConfig("Slave", "password") self.bossMail = cfReader.readConfig("Slave", "bossMail") self.loginMail()
def __init__(self, ctrlog=None): self.ctrLog = ctrlog cfReader = configReader(self.CONFIGPATH) self.pophost = cfReader.readConfig('Slave', 'pophost') self.smtphost = cfReader.readConfig('Slave', 'smtphost') self.port = cfReader.readConfig('Slave', 'port') self.username = cfReader.readConfig('Slave', 'username') self.password = cfReader.readConfig('Slave', 'password') self.bossMail = cfReader.readConfig('Boss', 'mail') self.loginMail() self.configSlaveMail()
def __init__(self,ctrlog,username='',password=''): self.ctrLog = ctrlog cfReader = configReader(self.CONFIGPATH) self.pophost = cfReader.readConfig('Slave', 'pophost') self.smtphost = cfReader.readConfig('Slave', 'smtphost') self.port = cfReader.readConfig('Slave', 'port') self.username = username self.password = password self.ok=False self.loginMail() self.configSlaveMail()
def __init__(self): self.mcclog = mcclog() cfReader = configReader(self.CONFIGPATH) self.pophost = cfReader.readConfig('Slave','pophost') self.smtphost = cfReader.readConfig('Slave','smtphost') self.port = cfReader.readConfig('Slave','port') self.username = cfReader.readConfig('Slave','username') self.password = cfReader.readConfig('Slave','password') self.bossMail = cfReader.readConfig('Boss','mail') self.loginMail() self.configSlaveMail()
def __init__(self): self.mccLog = logging.getLogger('mcc') cfReader = configReader(self.CONFIGPATH) self.pophost = cfReader.readConfig('Slave', 'pophost') self.smtphost = cfReader.readConfig('Slave', 'smtphost') self.port = cfReader.readConfig('Slave', 'port') self.username = cfReader.readConfig('Slave', 'username') self.password = cfReader.readConfig('Slave', 'password') self.bossMail = cfReader.readConfig('Boss', 'mail') self.loginMail() self.configSlaveMail()
def __init__(self, ctrlog, username='', password=''): self.ctrLog = ctrlog cfReader = configReader(self.CONFIGPATH) self.pophost = cfReader.readConfig('Slave', 'pophost') self.smtphost = cfReader.readConfig('Slave', 'smtphost') self.port = cfReader.readConfig('Slave', 'port') self.username = username self.password = password self.ok = False self.loginMail() self.configSlaveMail()
def readConfig(self): self.config = {} self.cf = configReader(CONFIG_PATH) self.config['host'] = self.cf.readConfig('Server', 'host') self.config['port'] = int(self.cf.readConfig('Server', 'port')) self.config['timeOut'] = int(self.cf.readConfig('Server', 'timeOut')) self.config['sendDialog'] = self.cf.readConfig('Info', 'sendDialog') self.config['sendSuccess'] = self.cf.readConfig('Info', 'sendSuccess') self.config['sendError'] = self.cf.readConfig('Info', 'sendError') self.config['uploadDialog'] = self.cf.readConfig('Info', 'uploadDialog') self.config['uploadSuccess'] = self.cf.readConfig('Info', 'uploadSuccess') self.config['uploadError'] = self.cf.readConfig('Info', 'uploadError') self.config['waitTask'] = self.cf.readConfig('Info', 'waitTask')
def readConfig(self): cf = configReader(CONFIG_NAME) self.config = {} self.config['button_student_choose_on'] = fun.toRgb(cf.readConfig('Colour', 'button_student_choose_on')) self.config['button_file_choose_on'] = fun.toRgb(cf.readConfig('Colour', 'button_file_choose_on')) self.config['button_choose_on'] = fun.toRgb(cf.readConfig('Colour', 'button_choose_on')) self.config['button_choose_off'] = fun.toRgb(cf.readConfig('Colour', 'button_choose_off')) self.config['host'] = cf.readConfig('Server','host') self.config['port'] = int(cf.readConfig('Server','port')) self.config['text_ctrl_colour'] = cf.readConfig('Font','text_ctrl_colour') self.config['text_ctrl_fontsize'] = cf.readConfig('Font','text_ctrl_fontsize') self.config['server_store_file_path'] = cf.readConfig('File','server_store_file_path') self.config['server_send_file_path'] = cf.readConfig('File', 'server_send_file_path') self.config['client_send_file_path'] = cf.readConfig('Client', 'client_send_file_path') self.config['client_store_file_path'] = cf.readConfig('Client', 'client_store_file_path') self.config['split_sep'] = cf.readConfig('File','split_sep') self.config['task'] = True self.config['job'] = False self.config['file'] = False
import RPi.GPIO as GPIO import time from configReader import configReader config = configReader('config.ini') def keypadMsge(): global config GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) #Holds the values entered on keypad entry = '' #Key layout on keypad KEYS = config.getKeypadConfig('keypadLayout') #Set the GPIO pins for colums and rows, # make sure they are in the right order or keys will be backwards ROW = config.getKeypadConfig('rowPins') COL = config.getKeypadConfig('columnPins') try: #Set all Column pins to output high for j in range(len(COL)): GPIO.setup(COL[j], GPIO.OUT) GPIO.output(COL[j], 1)
from __future__ import print_function import os, sys, json, codecs, subprocess, re import happyfuntokenizing import configReader import wikiEngine2 import thread_run import Queue import threading if len(sys.argv) < 2: print("Usage: {:s} <configure_file_path>".format(sys.argv[0]), file = sys.stderr) exit(-1) #sys.stdout = codecs.getwriter('utf-8')(sys.__stdout__) cfg_reader = configReader.configReader(sys.argv[1]) ret = cfg_reader.load_config() if ret != 0: print("Configure file invalid", file = sys.stderr) exit(-1) wiki = wikiEngine2.wikiEngine2() job_queue = Queue.Queue(cfg_reader.get_proxy_num()) fail_queue = Queue.Queue() ts = [] for i in range(0, cfg_reader.get_proxy_num()): ts.append(threading.Thread(target=thread_run.thread_run, args=(wiki, cfg_reader.get_proxy(i)[0], cfg_reader.get_proxy(i)[1], cfg_reader.max_phrase_length(), job_queue, fail_queue))) ts[-1].start()
def __init__(self,ctrlog): self.ctrLog = ctrlog cfReader = configReader(self.CONFIGPATH) self.mailHelper=mailHelper(self.ctrLog) self.bossMail = cfReader.readConfig('Boss', 'mail') self.cmdDic=self.getcmd()
from authentification import userVerified from CSV_Functions import get_row_count, get_remote_info from SSH_Subprocess import run_ssh_command import sys import time from lcd_driver import lcdInit, lcdMessage, lcdClear from configReader import configReader from logWriter import logWriter config = configReader('config.ini') #Get information from config file log = logWriter() #Initialize logWriter #Function to run program def runShutdown(file_name): #Start with the row after the header info. row_number = 1 #Determine the number of rows in the csv file. row_count = get_row_count(file_name) #Loop through and run the ssh command for every row in the csv file. while (row_number < row_count): machine_name, ip, rmt_user, sht_dwn_cmd = get_remote_info( file_name, row_number) run_ssh_command(machine_name, ip, rmt_user, sht_dwn_cmd) row_number += 1 #Check for user verification
def __init__(self): config = configReader('config.ini') #Get configuration file self.logFile = config.getLogConfig('logFile') #Get log file path self.time = timeKeeper()
values = values + " ," + str(v1) #print values q1 = q1.replace("#####", colNames) q1 = q1.replace("$$$$$", values) print q1 if tStamp == currTS: print 'duplicate time stamp' else: self.execQuery(q1) print 'execRow is finished' def close(self): print 'DB connection closing' self.dbConn.close() if __name__ == '__main__': cfg = cr.configReader("eav.xml") cfg.parseParams() dbop = DBOperator(cfg) dbop.connect() #dbop.execEAVQuery(cfg, "/FakeDAQ/ch0", 1234, '10000') #dbop.execQuery("select * from test;") dbop.execRowQuery(cfg, ["FakeDAQ/0", "FakeDAQ/1"], 1211342323.1234, [0, 1]) dbop.close() dstr = dbop.convertTime("yyyy-MM-dd HH:mm:ss.SSS", 1211342323.1234) print dstr
def __init__(self, commandDict, openDict): self.mccLog = logging.getLogger('mcc') cfReader = configReader(self.CONFIGPATH) self.commandDict = commandDict self.openDict = openDict self.bossMail = cfReader.readConfig('Boss', 'mail')
print "start times: ", self.chStartTimes def findChStartTimes (self, cfg, sapi): self.chNodes = self.chTree.iterator() self.chTimeNames = [] self.chStartTimes = [] self.chDurationTimes = [] self.chEndTimes = [] while (self.chNodes.hasNext()): tempChNode = self.chNodes.next() if tempChNode.getType() == self.chTree.CHANNEL: self.chTimeNames.append(tempChNode.getFullName()) self.chStartTimes.append(tempChNode.getStart()) self.chDurationTimes.append(tempChNode.getDuration()) self.chEndTimes.append(tempChNode.getStart() + tempChNode.getDuration()) if __name__ == '__main__': from sys import argv cf = configReader.configReader(argv[1]) cf.parseParams() sc = DT2DBManager(cf)
def get_config(sectionName): config = configReader.configReader() config_path = "/path/to/config/file/config.ini" srcVal = config.getSectionDict(config_path, sectionName) return srcVal
from __future__ import print_function import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests import Request import configReader as Config import supportFunction as SFunc import time from datetime import datetime # If modifying these scopes, delete the file token.pickle. SCOPES = ['https://www.googleapis.com/auth/spreadsheets'] # READ FROM FILE DATA = Config.configReader() STUDENTS = DATA[ "students" ] CONFIG = DATA[ "config" ] # UPDATE SUBMISSION start_row = CONFIG[ "START_READING_ROW" ] SECRET_CODE_COL = CONFIG[ "SECRET_CODE_COL" ] PROBLEM_CODE_COL = CONFIG[ "PROBLEM_CODE_COL" ] CODE_COL = CONFIG[ "CODE_COL" ] # WAITING TIME RELOAD_AFTER_SEC = CONFIG[ "RELOAD_AFTER_SEC" ] # The ID and range of a sample spreadsheet. SHEET_INPUT_ID = CONFIG[ 'SHEET_INPUT_ID' ] SHEET_OUTPUT_ID = CONFIG[ 'SHEET_OUTPUT_ID' ]
for v1 in vals: values = values + " ," + str(v1) #print values q1 = q1.replace ("#####", colNames) q1 = q1.replace ("$$$$$", values) print q1 if tStamp == currTS: print 'duplicate time stamp' else: self.execQuery (q1) print 'execRow is finished' def close(self): print 'DB connection closing' self.dbConn.close() if __name__=='__main__': cfg = cr.configReader("eav.xml") cfg.parseParams() dbop = DBOperator (cfg) dbop.connect() #dbop.execEAVQuery(cfg, "/FakeDAQ/ch0", 1234, '10000') #dbop.execQuery("select * from test;") dbop.execRowQuery(cfg, ["FakeDAQ/0", "FakeDAQ/1"], 1211342323.1234, [0,1]) dbop.close() dstr = dbop.convertTime("yyyy-MM-dd HH:mm:ss.SSS", 1211342323.1234) print dstr
def __init__(self, ctrlog): self.ctrLog = ctrlog cfReader = configReader(self.CONFIGPATH) self.mailHelper = mailHelper(self.ctrLog) self.bossMail = cfReader.readConfig('Boss', 'mail') self.cmdDic = self.getcmd()
def userVerified(): config = configReader('config.ini') #Get information from config file #Pin needed from user to authorize access pin = config.getAuthConfig('pin') maxAttempts = config.getAuthConfig('maxAttempts') lockoutTime = config.getAuthConfig('lockoutTime') exitAuth = config.getAuthConfig('exitAuthenticatorCode') attempt = 1 #Tell user to input pin on keypad print('User Authentification Required!') print('Please input your pin on the keypad') while (True): global log try: #record that authenticator is being used to log log.write(f'Authenticator Initialized: Asking user for pin') #Tell user to input password on lcd lcdMessage('', 'Input Password') #Get user inputed message code = keypadMsge() print(f'User inputed: {code}') #For debuging #Record user input to log log.write(f'User inputed: {code}') lcdMessage('', 'Analysing...') time.sleep(1) #If user enters the authenticator exit code then pass False to mainShutdown if (code == exitAuth): log.write(f'User entered {code} which is the exit code') log.write(f'Exiting program') return False #Check to see if code is equal to pin elif (code == pin): print('User verified') lcdMessage('', 'Password Valid') lcdMessage('', 'Proceeding...') #log the a user was verified log.write(f'User was verified proceeding with program') return True #See if user made maximum attempts elif (attempt == maxAttempts): print(f'Max attempts made, try again in {lockoutTime} seconds') lcdMessage('', f'{maxAttempts} Attempts Made') lcdMessage('', f'{lockoutTime} sec Timeout') #Log that user was locked out log.write(f'User used max number of attempts\n') log.write(f'User being locked out for {lockoutTime} seconds') #Wait for lockoutTime to expire time.sleep(lockoutTime) attempt = 1 print(f'Try again') else: print('Incorrect pin: User not verified') print('Try Again') lcdMessage('', f'X Attempt {attempt} of {maxAttempts}') #Log that a user inputed the wrong pin log.write( f'User inputed the wrong pin, attempts are at {attempt} of {maxAttempts}' ) attempt += 1 except Exception as e: #Tell the console something went wrong. print( f'Something went wrong while running the authenticator: {str(e)} \n' ) log.write(f'Authenticator Failed.') log.write(f'Exception: {str(e)}') break