def runTasks(task_list, data, result_fn): if not (isinstance(task_list, list)): return -1 createWorkFile(data) for task in task_list: taskFileName = env.SCRIPTS_DIR_PATH + task if os.path.exists(taskFileName): execT.execTaskAndWriteResultToFile([taskFileName], result_fn) sysloger.log(env.EVENT_RUN_TASK + taskFileName) else: sysloger.log(env.ERROR_FILE_NOT_FOUND + taskFileName)
def main(): flag = sys.argv[1] if flag == "-he": # python main.py -he executeTasks(env.MAIN_CONFIG_FILE_PATH) elif flag == "-ne": # python main.py -ne email_addr password email_addr, password = sys.argv[2], sys.argv[3] getSettingsFromNetAndExecuteTasks(email_addr, password) else: sysloger.log(env.INVALID_START_PARAM + flag) sys.exit(-1)
def getConfData(email_addr, password): emailStruct = rGmail.readGmail(email_addr, password, \ env.DBS_CONF_SUBJECT_TYPE) jsonStruct = emailStruct.get_body() sysloger.log(env.EVENT_GET_CONF) return pConf.strToJsonConfStruct(jsonStruct)
def getData(email_addr, password): emailS = rGmail.readGmail(email_addr, password, \ env.DBS_DATA_SUBJECT_TYPE) sysloger.log(env.EVENT_GET_DATA) return emailS.get_body()
def getReport(email_addr, password): emailS = rGmail.readGmail(email_addr, password, \ env.DBS_REPORT_SUBJECT_TYPE) sysloger.log(env.EVENT_GET_REPORT) return emailS
def sendConfData(email_from, email_to, password, confData, confName): sGmail.sendGmail(email_from, email_to, env.DBS_CONF_SUBJECT_TYPE, \ password, confData, confName) sysloger.log(env.EVENT_SEND_CONF)
def sendData(email_from, email_to, password, data, fname): sGmail.sendGmail(email_from, email_to, env.DBS_DATA_SUBJECT_TYPE,\ password, data, fname) sysloger.log(env.EVENT_SEND_DATA)
def sendReport(): sReport.sendReport(env.MAIN_CONFIG_FILE_PATH) sysloger.log(env.EVENT_SEND_REPORT)
def clearWordSpace(fname): pConf.removef(fname) sysloger.log(env.EVENT_CLEAR_WORK_SPACE + fname)
def createWorkFile(wordData): pConf.writef(env.MAIN_DATA_FILE_PATH, wordData) sysloger.log(env.EVENT_CREATE_WORD_SPACE)