DCU Proxy And Scripts

From Redbrick Wiki
Jump to navigation Jump to search

Have you ever tried to run a script on Redbrick that communicates with external websites and found that it doesn't work?

This might be due to the proxy being set wrong. For example on Installing Wordpress the proxy must be set manually in one of the files.

The proxy on Redbrick is 'http://proxy.dcu.ie:8080'. This is normally set via enviromental variables that your script can pick up. This variables are case-sensitive.

HTTP_PROXY=proxy.dcu.ie:8080
FTP_PROXY=proxy.dcu.ie:8080
http_proxy=http://proxy.dcu.ie:8080
ftp_proxy=http://proxy.dcu.ie:8080

These variables break Python's 'urllib' module because it wants the 'HTTP_PROXY' setting but finds the 'http_proxy'. You can quickly fix this in your script by having:

os.environ['HTTP_PROXY'] = "http://proxy.dcu.ie:8080"

or

HTTP_PROXY = "http://proxy.dcu.ie:8080"

(or both) near the top of the Python script (at least after 'import os').