Apr-22-2020, 02:27 PM
Hi Buran,
I changed the code a little bit and now it works, I put the 'try' just below the 'for line'
Thank you very much, this helped a lot.
I changed the code a little bit and now it works, I put the 'try' just below the 'for line'
Thank you very much, this helped a lot.
def ssh_login_xxx(host_ip): do the login stuf def ssh_login_yyy(host_ip): do the login stuf def ssh_login_zzz(host_ip): do the login stuf login_functions = {'xxx':ssh_login_xxx, 'yyy':ssh_login_yyy, 'zzz':ssh_login_xxx} with open (input_file, 'r') as my_file: csv_reader = csv.DictReader(my_file) for line in csv_reader: try: dev_model = line['dev_model'] host_ip = line['host_ip'] login_function = login_functions[sub] function_name(host_ip) except KeyError: print(f'Unknown device model: {dev_model}')