def main(data): chart_id = data.get('chart_id_from', '') file_path = os.path.join(BASE_DIR, 'omformflow', 'production', flow_uuid, str(version)) if chart_id == 'FITEM_1': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_2' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_2': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_4' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_4': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = '' OmEngine(flow_uuid, data).checkActive()
def main(data): chart_id = data.get('chart_id_from', '') file_path = os.path.join(BASE_DIR, 'omformflow', 'production', flow_uuid, str(version)) if chart_id == 'FITEM_1': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_10' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_2': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_11' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_4': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = '' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_10': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_2' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_11': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_14'] != '22': data['chart_id_to'] = 'FITEM_4' if chart_input['FORMITM_14'] == '22': data['chart_id_to'] = 'FITEM_10' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid, data).checkActive()
def main(data): chart_id = data.get('chart_id_from', '') file_path = os.path.join(BASE_DIR, 'omformflow', 'production', flow_uuid, str(version)) if chart_id == 'FITEM_1': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_5' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_2': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_4' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_3': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_6'] == '0': data['chart_id_to'] = 'FITEM_2' if chart_input['FORMITM_6'] == '1': data['chart_id_to'] = 'FITEM_7' if chart_input['FORMITM_6'] == '2': data['chart_id_to'] = 'FITEM_8' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_4': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = '' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_5': try: autoinstall = data.get('autoinstall', False) load_balance = data.get('load_balance', False) chart_input = data['chart_input'] chart_input_str = json.dumps(chart_input) chart_input_c = json.loads(chart_input_str) import_error = False package = '' key = flow_uuid + '_' + chart_id compileObj = GlobalObject.__chartCompileObj__.get(key, '') chart_file_path = os.path.join(file_path, chart_id + '.py') if load_balance: with open(chart_file_path, 'r', encoding='UTF-8') as f: chart_file = f.read() f.close() else: if not compileObj: with open(chart_file_path, 'r', encoding='UTF-8') as f: chart_file = f.read() f.close() import_str = '' chart_file_to_list = chart_file.split('\n') for line in chart_file_to_list: line_lstrip = line.lstrip() if (line_lstrip[:7] == 'import ') or (line_lstrip[:5] == 'from '): import_str += line_lstrip + '\n' compile_import_str = compile(import_str, '', 'exec') loop = True last_package = '' while loop: try: exec(compile_import_str) compileObj = compile(chart_file, '', 'exec') loop = False package = '' except Exception as e: if 'No module named ' in e.__str__(): import subprocess import sys package = e.__str__()[17:-1] if package == last_package or ( not autoinstall): import_error = True loop = False data['error'] = True data['error_message'] = e.__str__() else: last_package = package try: subprocess.check_call([ 'C:/Program Files/OMFLOW Server/Python/python.exe', '-m', 'pip', 'install', package ]) except Exception as e: import_error = True loop = False data['error'] = True data['error_message'] = e.__str__() else: import_error = True loop = False data['error'] = True data['error_message'] = e.__str__() if not import_error: GlobalObject.__chartCompileObj__[key] = compileObj if not import_error: exec(compileObj, chart_input_c) for key in list(chart_input.keys()): output_value = chart_input_c[key] if isinstance(output_value, list) or isinstance( output_value, dict): output_value_str = json.dumps(output_value) else: output_value_str = str(output_value) chart_input[key] = output_value_str data['error'] = False except Exception as e: if package: data['error_message'] = '找不到符合的條件。' + package else: data['error_message'] = e.__str__() data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_6' if load_balance: try: from ommonitor.views import sendPython sendPython(flow_uuid, data, chart_file) except: OmEngine(flow_uuid, data).checkActive() else: OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_6': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_3' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_7': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_4' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_8': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_4' OmEngine(flow_uuid, data).checkActive()
def main(data): chart_id = data.get('chart_id_from', '') file_path = os.path.join(BASE_DIR, 'omformflow', 'production', flow_uuid, str(version)) if chart_id == 'FITEM_1': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_2' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_2': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_3' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_3': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_4'] == 'dispatch': data['chart_id_to'] = 'FITEM_2' if chart_input['FORMITM_4'] == 'dispatch_done': data['chart_id_to'] = 'FITEM_5' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_4': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = '' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_5': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_7' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_6': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_8' OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_7': try: chart_input = data['chart_input'] data['error'] = False if 'work_done' == chart_input['FORMITM_4']: data['chart_id_to'] = 'FITEM_6' if 'work' == chart_input['FORMITM_4']: data['chart_id_to'] = 'FITEM_5' if 'work_fail' == chart_input['FORMITM_4']: data['chart_id_to'] = 'FITEM_2' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid, data).checkActive() elif chart_id == 'FITEM_8': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_4'] == 'check_done': data['chart_id_to'] = 'FITEM_4' if chart_input['FORMITM_4'] == 'check_fail': data['chart_id_to'] = 'FITEM_5' if chart_input['FORMITM_4'] == 'check': data['chart_id_to'] = 'FITEM_6' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid, data).checkActive()
def main(data): chart_id = data.get('chart_id_from','') file_path = os.path.join(BASE_DIR, 'omformflow', 'production', flow_uuid, str(version)) if chart_id == 'FITEM_1': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = 'FITEM_15' OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_4': try: data['error'] = False except: data['error_message'] = '' data['error'] = True data['error_pass'] = False data['chart_id_to'] = '' OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_15': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_27' data['flow_uuid'] = '7d0e2cb825e1452a8290c630677d42b4' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_16': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_24' data['flow_uuid'] = '9097310f4960430c8f2d7dd7d588386b' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_17': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_29' data['flow_uuid'] = '0f342529fb854afeadde3aa486664964' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_18': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_25' data['flow_uuid'] = '9097310f4960430c8f2d7dd7d588386b' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_19': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_30' data['flow_uuid'] = '731d5316d4c949d7bb21ecd4e878b9a3' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_20': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_31' data['flow_uuid'] = 'f22366ebecc244d9ad7b72abfae78c86' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_22': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_23' data['flow_uuid'] = '9097310f4960430c8f2d7dd7d588386b' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_23': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_4' data['flow_uuid'] = 'a93c6eb3b09941c38b8cb2588b75be70' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_24': try: chart_input = data['chart_input'] data['error'] = False if chart_input['ap_status'] == '00': data['chart_id_to'] = 'FITEM_17' if chart_input['ap_status'] == '11': data['chart_id_to'] = 'FITEM_15' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_25': try: chart_input = data['chart_input'] data['error'] = False if chart_input['ap_status'] == '00': data['chart_id_to'] = 'FITEM_19' if chart_input['ap_status'] == '11': data['chart_id_to'] = 'FITEM_17' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_27': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_11'] != '8': data['chart_id_to'] = 'FITEM_16' if chart_input['FORMITM_11'] == '8': data['chart_id_to'] = 'FITEM_28' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_28': try: data_str = json.dumps(data) content = json.loads(data_str) content['chart_id_to'] = 'FITEM_34' data['flow_uuid'] = 'c8450b76a94b4d7885b6f684c2dfe2d6' data['chart_id_from'] = '' data['chart_id_to'] = 'FITEM_1' data['flow_value'] = {} data['content'] = content data['error'] = False except Exception as e: data['error_message'] = '' data['error'] = True data['error_pass'] = False OmEngine(data['flow_uuid'],data).checkActive() elif chart_id == 'FITEM_29': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_11'] != '8': data['chart_id_to'] = 'FITEM_18' if chart_input['FORMITM_11'] == '8': data['chart_id_to'] = 'FITEM_28' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_30': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_11'] != '8': data['chart_id_to'] = 'FITEM_20' if chart_input['FORMITM_11'] == '8': data['chart_id_to'] = 'FITEM_28' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_31': try: chart_input = data['chart_input'] data['error'] = False if chart_input['FORMITM_11'] != '8': data['chart_id_to'] = 'FITEM_22' if chart_input['FORMITM_11'] == '8': data['chart_id_to'] = 'FITEM_28' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive() elif chart_id == 'FITEM_34': try: chart_input = data['chart_input'] data['error'] = False if chart_input['status'] == '0': data['chart_id_to'] = 'FITEM_15' if chart_input['status'] == '8': data['chart_id_to'] = 'FITEM_4' except: data['error'] = True data['error_pass'] = False if not data['chart_id_to']: data['error_message'] = '找不到符合的條件。' data['error'] = True OmEngine(flow_uuid,data).checkActive()