def optionnal_param_file(): global anal # input global uranus # output global filetool global optionsDict list_dict = OrderedDict2.OrderedDict() blacklist_dict = OrderedDict2.OrderedDict() # 1) check si les elements de la ligne correspondent au elements en input # 2) si la ligne est valide, chercher l'ID dans list_dict. # 3) Si l'id n'est pas la, ajouter une entree. list_dict[ID] = valid_list() # 4) Si l'id est present, Set.From() ou add_To() sur l'element concerne. if optionsDict["mfast"] == 1: init_mfast_mode() else: init_normal_mode() init_arguments_for_multi() nb_line = 0 i = 0 old = datetime.datetime.now() for line in filetool.get_fd(): if i == 1000: filetool.cli_progress_test(nb_line) i = 0 nb_line = nb_line + 1 i = i + 1 if "from=<" not in line and "to=<" not in line: continue anal.clean() anal.Line_func(line) # SCOPE CHECK BETWEEN ELEMENTIN AND ELEMENTOUT if uranus.Get_Full_Date_Start() is not None and anal.Get_Date() < uranus.Get_Full_Date_Start(): continue if uranus.Get_Full_Date_Start() is not None and anal.Get_Date() > uranus.Get_Full_Date_End(): continue if uranus.Get_Id() is not None and uranus.Get_Id() not in anal.Get_Id(): continue if anal.Get_To() is not None and ( uranus.Get_Status() is not None and uranus.Get_Status() not in str(anal.Get_Status()) ): continue if anal.Get_To() is not None: if uranus.Get_Filters(): check = False for elem in uranus.Get_Filters(): if elem in str(anal.Get_Desc()): check = True break if check is not True: continue if uranus.Get_From() is not None and uranus.Get_To() is not None: if anal.Get_From() is not None: if uranus.Get_From() not in anal.Get_From(): if anal.Get_Id() not in list_dict: blacklist_dict[anal.Get_Id()] = True continue elif anal.Get_To() is not None: if uranus.Get_To() not in anal.Get_To(): continue else: if anal.Get_Id() not in list_dict and anal.Get_Id() not in blacklist_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() else: continue elif uranus.Get_From() is not None and anal.Get_To() is None: if uranus.Get_From() not in str(anal.Get_From()): continue else: if anal.Get_Id() not in list_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() elif uranus.Get_To() is not None and anal.Get_From() is None: if uranus.Get_To() not in str(anal.Get_To()): continue else: if anal.Get_Id() not in list_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() elif uranus.Get_From() is None and uranus.Get_To() is None: if anal.Get_To() is not None: if anal.Get_Id() not in list_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() # SCOPE THAT ADD THE VALID ELEMENTS IN THE LIST ## if anal.Get_Id() in list_dict: if anal.Get_To() is not None: if anal.Prepare_To_Valid() is not None: list_dict[anal.Get_Id()].add_To(anal.Prepare_To_Valid()) filetool.get_fd().seek(0) print "" nb_line = 0 i = 0 for line in filetool.get_fd(): if i == 1000: filetool.cli_progress_test(nb_line) i = 0 nb_line = nb_line + 1 i = i + 1 if "from=<" in line: anal.clean() anal.Line_func(line) if anal.Get_Id() in list_dict and anal.Get_From() is not None: if anal.Prepare_From_Valid() is not None and list_dict[anal.Get_Id()].From is None: tmp1 = anal.Prepare_From_Valid() list_dict[anal.Get_Id()].set_From(tmp1) print "" new = datetime.datetime.now() # SCOPE THAT DISPLAY THE INFORMATION STORED IN THE LIST tmp_pop_list = [] for key, value in list_dict.iteritems(): if value.From is not None: if len(value.To) > 0: print "_________________________________\n" print value.From.Get_output() else: tmp_pop_list.append(key) if value.From is not None and value.To is not None: for elem in value.To: if elem is not None: print " " + elem.Get_output() print " " + Colors.change_color("\n Temps passe total= ", "FAIL") + str(new - old) if tmp_pop_list: for item in tmp_pop_list: list_dict.popitem(item) print "La taille de la liste est : " + str(len(list_dict)) list_dict.clear() uranus = elementShell.elementShell() go_trhough_multi()
def optionnal_param_file(): global anal # input global uranus # output global filetool global optionsDict list_dict = OrderedDict2.OrderedDict() blacklist_dict = OrderedDict2.OrderedDict() # 1) check si les elements de la ligne correspondent au elements en input # 2) si la ligne est valide, chercher l'ID dans list_dict. # 3) Si l'id n'est pas la, ajouter une entree. list_dict[ID] = valid_list() # 4) Si l'id est present, Set.From() ou add_To() sur l'element concerne. if (optionsDict['mfast'] == 1): init_mfast_mode() else: init_normal_mode() init_arguments_for_multi() nb_line = 0 i = 0 old = datetime.datetime.now() for line in filetool.get_fd(): if i == 1000: filetool.cli_progress_test(nb_line) i = 0 nb_line = nb_line + 1 i = i + 1 if ('from=<' not in line and 'to=<' not in line): continue anal.clean() anal.Line_func(line) # SCOPE CHECK BETWEEN ELEMENTIN AND ELEMENTOUT if (uranus.Get_Full_Date_Start() is not None and anal.Get_Date() < uranus.Get_Full_Date_Start()): continue if (uranus.Get_Full_Date_Start() is not None and anal.Get_Date() > uranus.Get_Full_Date_End()): continue if (uranus.Get_Id() is not None and uranus.Get_Id() not in anal.Get_Id()): continue if (anal.Get_To() is not None and (uranus.Get_Status() is not None and uranus.Get_Status() not in str(anal.Get_Status()))): continue if anal.Get_To() is not None: if (uranus.Get_Filters()): check = False for elem in uranus.Get_Filters(): if (elem in str(anal.Get_Desc())): check = True break if check is not True: continue if uranus.Get_From() is not None and uranus.Get_To() is not None: if anal.Get_From() is not None: if uranus.Get_From() not in anal.Get_From(): if anal.Get_Id() not in list_dict: blacklist_dict[anal.Get_Id()] = True continue elif anal.Get_To() is not None: if uranus.Get_To() not in anal.Get_To(): continue else: if (anal.Get_Id() not in list_dict and anal.Get_Id() not in blacklist_dict): list_dict[anal.Get_Id()] = elementFile.valid_list() else: continue elif uranus.Get_From() is not None and anal.Get_To() is None: if uranus.Get_From() not in str(anal.Get_From()): continue else: if anal.Get_Id() not in list_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() elif uranus.Get_To() is not None and anal.Get_From() is None: if uranus.Get_To() not in str(anal.Get_To()): continue else: if anal.Get_Id() not in list_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() elif uranus.Get_From() is None and uranus.Get_To() is None: if anal.Get_To() is not None: if anal.Get_Id() not in list_dict: list_dict[anal.Get_Id()] = elementFile.valid_list() # SCOPE THAT ADD THE VALID ELEMENTS IN THE LIST ## if anal.Get_Id() in list_dict: if (anal.Get_To() is not None): if anal.Prepare_To_Valid() is not None: list_dict[anal.Get_Id()].add_To(anal.Prepare_To_Valid()) filetool.get_fd().seek(0) print '' nb_line = 0 i = 0 for line in filetool.get_fd(): if i == 1000: filetool.cli_progress_test(nb_line) i = 0 nb_line = nb_line + 1 i = i + 1 if ('from=<' in line): anal.clean() anal.Line_func(line) if anal.Get_Id() in list_dict and anal.Get_From() is not None: if (anal.Prepare_From_Valid() is not None and list_dict[anal.Get_Id()].From is None): tmp1 = anal.Prepare_From_Valid() list_dict[anal.Get_Id()].set_From(tmp1) print '' new = datetime.datetime.now() # SCOPE THAT DISPLAY THE INFORMATION STORED IN THE LIST tmp_pop_list = [] for key, value in list_dict.iteritems(): if value.From is not None: if len(value.To) > 0: print '_________________________________\n' print value.From.Get_output() else: tmp_pop_list.append(key) if value.From is not None and value.To is not None: for elem in value.To: if (elem is not None): print ' ' + elem.Get_output() print ' ' + Colors.change_color('\n Temps passe total= ', 'FAIL') + str(new - old) if tmp_pop_list: for item in tmp_pop_list: list_dict.popitem(item) print 'La taille de la liste est : ' + str(len(list_dict)) list_dict.clear() uranus = elementShell.elementShell() go_trhough_multi()
if filetool.checkfile_shell(sys.argv[2]) is False: Message = "Le module Postfix prend un fichier en paramètre" exit("\n %s" % Colors.change_color(Message, "FAIL")) check_first_and_last_line_postfix() check_param() try: postfix_shell() except KeyboardInterrupt: Message = "\n KeyboardInterrupt" exit(Colors.change_color(Message, "FAIL")) anal = elementFile.elementFile() uranus = elementShell.elementShell() filetool = None function = {"1": partial(GetStatsFromString), "2": partial(optionnal_param_file)} optionsDict = { "start=": None, "end=": None, "command=": None, "status=": None, "from=": None, "to=": None, "id=": None, "filters=": None, "mfast": 0, }
if (filetool.checkfile_shell(sys.argv[2]) is False): Message = "Le module Postfix prend un fichier en paramètre" exit('\n %s' % Colors.change_color(Message, 'FAIL')) check_first_and_last_line_postfix() check_param() try: postfix_shell() except KeyboardInterrupt: Message = '\n KeyboardInterrupt' exit(Colors.change_color(Message, 'FAIL')) anal = elementFile.elementFile() uranus = elementShell.elementShell() filetool = None function = { '1': partial(GetStatsFromString), '2': partial(optionnal_param_file) } optionsDict = { 'start=': None, 'end=': None, 'command=': None, 'status=': None, 'from=': None, 'to=': None, 'id=': None,