DCU Proxy And Scripts: Difference between revisions
Jump to navigation
Jump to search
twiki2mediawiki (talk) (Automagically converted by twiki2mediawiki) |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Have you ever tried to run a script on Redbrick that communicates with external websites and found that it doesn't work? | 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 [[ | This might be due to the proxy being set wrong. For example on [[Installing Wordpress on Redbrick|Installing Wordpress]] the proxy must be set manually in one of the files. | ||
The proxy on Redbrick is | 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 | |||
HTTP_PROXY=proxy.dcu.ie:8080 | FTP_PROXY=proxy.dcu.ie:8080 | ||
FTP_PROXY=proxy.dcu.ie:8080 | http_proxy=http://proxy.dcu.ie:8080 | ||
http_proxy=http://proxy.dcu.ie:8080 | ftp_proxy=http://proxy.dcu.ie:8080 | ||
ftp_proxy=http://proxy.dcu.ie:8080 | |||
These variables break Python's | 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" | |||
os.environ['HTTP_PROXY'] = "http://proxy.dcu.ie:8080" | |||
or | or | ||
HTTP_PROXY = "http://proxy.dcu.ie:8080" | |||
HTTP_PROXY = "http://proxy.dcu.ie:8080" | |||
(or both) near the top of the Python script (at least after | (or both) near the top of the Python script (at least after 'import os'). | ||
[[Category:HowTo]] |
Latest revision as of 23:54, 29 August 2009
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').