Oct-16-2020, 08:08 PM
I have these two files
Main.py
it works if I put all the code in a single code
Main.py
# Script displays my organizations I have access to. import os os.chdir('/Users/virgi/Dropbox/Dropbox-Work/Wing Files/Development/Utils') from menu_option import api_key from menu_option import organization_id my_org = dashboard.organizations.getOrganizations() print(my_org)choice.py
# script sets the correct environment variables import meraki # Create the menu to be displayed print('Please make a chose') print("1 - For SandBox Virgil press") print('2 - For SandBox Meraki') print('3 - For LafageProduction') user_input = int(input('Please select an enviroment: ')) # Determine the users input was and set variables if user_input == 1:# Sandbox A api_key = 'ijkl' organization_id = '996719' print(api_key) elif user_input == 2: # Sandbox B api_key = 'efgh' organization_id = '566327653141842188' print(api_key) elif user_input == 3: api_key = 'abcd' # Sandbox C organization_id = '647392446434509389' print(api_key) else: print('Sorry there was not match') # Creates the dashboard variable dashboard = meraki.DashboardAPI(api_key,output_log=False, print_console=False)When I run the 2 scripts I get the
api_key & organization_id
but when I try to use the dashboard varialbe it says it isn't defined.it works if I put all the code in a single code
# script sets the correct environment variables import meraki # Create the menu to be displayed print('Please make a chose') print("1 - For SandBox Virgil press") print('2 - For SandBox Meraki') print('3 - For LafageProduction') user_input = int(input('Please select an enviroment: ')) # Determine the users input was and set variables if user_input == 1:# Sandbox A api_key = 'ijkl' organization_id = '996719' print(api_key) elif user_input == 2: # Sandbox B api_key = 'efgh' organization_id = '566327653141842188' print(api_key) elif user_input == 3: api_key = 'abcd' # Sandbox C organization_id = '647392446434509389' print(api_key) else: print('Sorry there was not match') # Creates the dashboard variable dashboard = meraki.DashboardAPI(api_key,output_log=False, print_console=False) my_org = dashboard.organizations.getOrganizations() print(my_org)