def save_pop_pro(vertex_list, sample_list, vertex_list_file, sample_list_file): vertex_list_str = "" for vertex in vertex_list: vertex_list_str += str(vertex) + " " write_to_file(vertex_list_file, vertex_list_str.strip()) sample_list_str = "" for sample in sample_list: sample_list_str += str(sample) + " " write_to_file(sample_list_file, sample_list_str)
def old_main(): #Define the current date today = datetime.date.today() today = str(today.strftime('%d%m%Y')) #Read the yaml file with credentials for devices devices = read_yml_file(CREDS) # Run the script to connect to devices and save config files for device in devices: if ping_check(device['ip']): write_to_file(send_show_command(device, COMMAND), device['ip'] + '-' + today + '.backup')
def get_event_group(event_users_file, event_group_file): col_names = ["event", "users"] event_group_str = "" df = pd.read_csv(event_users_file, sep="::", header=None, names=col_names, engine='python') for index, row in df.iterrows(): if len(str(row["users"]).split(" ")) > 1: event_group_str += str(row["event"]) + "::" + str( row["users"]) + "\n" write_to_file(event_group_file, event_group_str)
def save_pop_pro_in_group(vertex_list, group_sample_list_dict, vertex_list_file, group_sample_list_dict_file): vertex_list_str = "" for vertex in vertex_list: vertex_list_str += str(vertex) + " " write_to_file(vertex_list_file, vertex_list_str.strip()) group_sample_list_dict_str = "" for group, sample_list in group_sample_list_dict.items(): group_sample_list_dict_str += str(group) + "\t" sample_str = "" for sample in sample_list: sample_str += str(sample) + " " group_sample_list_dict_str += sample_str.strip() write_to_file(group_sample_list_dict_file, group_sample_list_dict_str)
def test_multitrade_telnet_main(): #Define the current date today = datetime.date.today() today = str(today.strftime('%d%m%Y')) #Read the yaml file with credentials for devices devices = read_yml_file(CREDS_TELNET) result = multithread_send_show_command(telnet_show_command, devices, command=COMMAND) for conf in result: if isinstance(conf, str): write_to_file( conf, BACKUP_PATH + parse_hostname(conf) + '-' + today + '.backup')
def main(): report_results = [] for keyword in read_keywords(CURRENT_KEYWORDS_IDX): try: endeca_props, _ = se.find_endeca_props(keyword) solr_props = se.find_solr_props(keyword) result_tuple = (keyword, len(endeca_props), len(solr_props)) report_results.append(result_tuple) print("Keyword: {}, Endeca qty: {}, Solr qty: {}".format( result_tuple[0], result_tuple[1], result_tuple[2])) except Exception as e: print("Error processing keyword: {}".format(keyword)) print(e) logging.exception(e) write_to_file(CURRENT_KEYWORDS_IDX, report_results, ('Endeca Qty', 'Solr Qty'))
def ssh_main(): #Define the current date today = datetime.date.today() today = str(today.strftime('%d%m%Y')) #Read the yaml file with credentials for devices devices = read_yml_file(CREDS) result = multithread_send_show_command(send_show_command, devices, COMMAND) for conf in result: if isinstance(conf, str): write_to_file( conf, BACKUP_PATH + parse_hostname(conf) + '-' + today + '.backup') else: logging.warning( f"The loaded config file of some device is empty, unable to write it" )
def write_to_event_users_file(user_events_file,event_users_file): df = pd.read_csv(user_events_file) event_users_str = "" event_users_dict = dict() for index, row in df.iterrows(): for event in str(row["event_id"]).split(" "): if event not in event_users_dict: event_users_dict[event] = [str(row["uid"])] else: event_users_dict[event].append(str(row["uid"])) for event,users in event_users_dict.items(): event_users_str += event+"\t" for user in users: event_users_str += user+" " event_users_str+="\n" write_to_file(event_users_file,event_users_str)
def telnet_main(): #Define the current date today = datetime.date.today() today = str(today.strftime('%d%m%Y')) #Read the yaml file with credentials for devices devices = read_yml_file(CREDS_TELNET) commands = ['show running-config', 'show version'] result = [] for device in devices: conf = telnet_show_command(command=commands, **device) if isinstance(conf, str): write_to_file( conf, BACKUP_PATH + parse_hostname(conf) + '-' + today + '.backup') else: logging.warning( f"The loaded config file of device {device['ip']} is empty, unable to write" )
def group_statistic(event_group_file, event_groupid_file, groupid_users_file): col_names = ["event", "group"] df = pd.read_csv(event_group_file, header=None, sep="\t", names=col_names, engine="python") group_list = [] for index, row in df.iterrows(): group = set(str(row["group"]).split(" ")) if group not in group_list: group_list.append(group) event_groupid_str = "" groupid_users_str = "" for index, row in df.iterrows(): id = group_list.index(set(str(row["group"]).split(" "))) event_groupid_str += str(row["event"]) + "\t" + str(id) + "\n" groupid_users_str += str(id) + "\t" + str(row["group"]) + "\n" write_to_file(event_groupid_file, event_groupid_str) write_to_file(groupid_users_file, groupid_users_str)