Commits

jaraco  committed 4eaba9b

Added proxy support (currently doesn't work)

  • Participants
  • Parent commits 4a4b827

Comments (0)

Files changed (1)

File eodsfetch/eodsfetch.py

 # $Id$
 
 import urllib2, sys
+from getpass import getpass
 from ClientForm import ParseResponse
 from optparse import OptionParser
 from urlparse import urljoin
 	parser.add_option( "-c", "--retrieve-command", default="newhires/ReviewQueuedExport.do", help="Web site path to retrieval command (relative to url)" )
 	parser.add_option( "-r", "--proxy-server", help="Optional proxy server and port (server:port)" )
 	parser.add_option( "-s", "--save-file", help="filename to save data" )
+	parser.add_option( "-w", "--proxy-password", help="Password for the proxy server '-' for prompt" )
+	parser.add_option( "-i", "--proxy-user", help="User name for the proxy server" )
 	return parser.parse_args()
 
 def setupLogging():
 
 def installOpener():
 	handlers = [ urllib2.HTTPCookieProcessor ]
+	if options.proxy_user and options.proxy_password:
+		pwMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
+		if options.proxy_password == '-':
+			options.proxy_password = getpass( )
+		pwMgr.add_password( "NTLM_PWS", "http://dev01.hrworx.com:8180", options.proxy_user, options.proxy_password )
+		pwMgr.add_password( "NTLM_PWS", "http://occ.hrservices.accenture.com", options.proxy_user, options.proxy_password )
+		handler = urllib2.ProxyBasicAuthHandler( pwMgr )
+		handlers.append( handler )
 	if options.proxy_server:
 		handlers.append( urllib2.ProxyHandler( { 'http': options.proxy_server } ) )
 	opener = urllib2.build_opener( handlers )