Package ndg :: Package xacml :: Package utils :: Module urlfetcher
[hide private]

Module urlfetcher

source code

NDG XACML data fetch by URL utility

NERC DataGrid


Date: 03/11/11

Author: R B Wilkinson

Contact: Philip.Kershaw@stfc.ac.uk

Copyright: (C) 2011 Science and Technology Facilities Council

License: BSD - see LICENSE file in top-level directory

Functions [hide private]
file derived type
fetch_stream_from_url(url, debug=False)
Returns data retrieved from a URL.
source code
str
fetch_data_from_url(url, debug=False)
Returns data retrieved from a URL.
source code
 
open_url(url, debug=False)
Attempts to open a connection to a specified URL.
source code
bool
_should_use_proxy(url)
Determines whether a proxy should be used to open a connection to the specified URL, based on the value of the no_proxy environment variable.
source code
Variables [hide private]
  __revision__ = '$Id$'
  log = logging.getLogger(__name__)
  __package__ = 'ndg.xacml.utils'
Function Details [hide private]

fetch_stream_from_url(url, debug=False)

source code 

Returns data retrieved from a URL.

Parameters:
  • url - URL to attempt to open
  • debug - debug flag for urllib2
Returns: file derived type
data retrieved from URL or None

fetch_data_from_url(url, debug=False)

source code 

Returns data retrieved from a URL.

Parameters:
  • url - URL to attempt to open
  • debug - debug flag for urllib2
Returns: str
data retrieved from URL or None

open_url(url, debug=False)

source code 
Attempts to open a connection to a specified URL.
@param url: URL to attempt to open
@type: str
@param debug: debug flag for urllib2
@type: bool
@return: tuple (
@rtype: tuple (
    int: returned HTTP status code or 0 if an error occurred
    str: returned message or error description
    file-like: response object
)

_should_use_proxy(url)

source code 

Determines whether a proxy should be used to open a connection to the specified URL, based on the value of the no_proxy environment variable.

Parameters:
  • url - URL
Returns: bool
flag indicating whether proxy should be used