DCU Proxy And Scripts

From Redbrick Wiki
Revision as of 10:53, 23 August 2005 by twiki2mediawiki (talk) (Automagically converted by twiki2mediawiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 InstallingWordpress 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=).