Skip to content

Instantly share code, notes, and snippets.

@dmukhg
Created April 10, 2013 04:04
Show Gist options
  • Save dmukhg/5351707 to your computer and use it in GitHub Desktop.
Save dmukhg/5351707 to your computer and use it in GitHub Desktop.
Set proxy environment variables and execute google-chrome based on a dict of proxy servers.
#!/usr/bin/python
import sys
import os
import subprocess
proxies = {
'150': 'http://10.3.100.150:8080/',
'211': 'http://10.3.100.211:8080/',
'212': 'http://10.3.100.212:8080/',
'218': 'http://144.16.192.218:8080/',
'245': 'http://144.16.192.245:8080/',
'247': 'http://144.16.192.247:8080/'
}
if __name__ == "__main__":
try:
if sys.argv[1] in proxies:
print "Setting proxy %s" %proxies[sys.argv[1]]
os.environ['http_proxy'] = proxies[sys.argv[1]]
os.environ['https_proxy'] = proxies[sys.argv[1]]
subprocess.call(['google-chrome'])
else:
sys.exit("Invalid Proxy specified choose 150, 211, 212, 218, 245 or 247")
except IndexError:
sys.exit("No Proxy specified choose: %s (150 | 211 | 212 | 218 | 245 | 247) " % sys.argv[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment