Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla BitBar - Monitor Charging and Control HVAC from your OSX menubar

This site may earn commission on affiliate links.
I added this to my main method so I can have proxy settings setup at work, and non proxy setups when not on work.

Location Name == System Preferences -> Network -> Location
Proxy URL = proxy url and port
Proxy username = proxy username
Proxy password = proxy password.

Code:
p1 = subprocess.Popen(['networksetup', '-getcurrentlocation'], stdout=subprocess.PIPE).communicate()[0]
    networklocation = p1.decode('utf-8')

    if "Location Name" in networklocation:
    #     #We need to use proxy settings
    #      # create connection to tesla account
        c = Connection(access_token = tesla_access_token, proxy_url = '<PROXY URL>', proxy_user = '<PROXYUSER>', proxy_password = 'PROXYPASSWORD'
    else:
         #No proxy needed
         # create connection to tesla account
        c = Connection(access_token = tesla_access_token)

Hope this helps someone else.