Anonymous committed 4eaba9b

Added proxy support (currently doesn't work)

Comments (0)

Files changed (1)


 # $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/", 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", "", options.proxy_user, options.proxy_password )
+		pwMgr.add_password( "NTLM_PWS", "", 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 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.