Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created April 13, 2013 08:56
Show Gist options
  • Select an option

  • Save cdeil/5377660 to your computer and use it in GitHub Desktop.

Select an option

Save cdeil/5377660 to your computer and use it in GitHub Desktop.
$ python setup.py test --package vo
running test
running build
running build_py
running build_ext
skipping 'astropy/table/_np_utils.c' Cython extension (up-to-date)
skipping 'astropy/time/sofa_time.c' Cython extension (up-to-date)
skipping 'astropy/nddata/convolution/boundary_extend.c' Cython extension (up-to-date)
skipping 'astropy/nddata/convolution/boundary_fill.c' Cython extension (up-to-date)
skipping 'astropy/nddata/convolution/boundary_none.c' Cython extension (up-to-date)
skipping 'astropy/nddata/convolution/boundary_wrap.c' Cython extension (up-to-date)
regenerating default astropy.cfg file
copying astropy/astropy.cfg -> build/lib.macosx-10.8-x86_64-2.7/astropy
running build_scripts
WARNING: Module astropy was already imported from astropy/__init__.pyc, but /Users/deil/Library/Python/2.7/lib/python/site-packages/astropy-0.3.dev3731-py2.7-macosx-10.8-x86_64.egg is being added to sys.path [pkg_resources]
==================================================================== test session starts =====================================================================
platform darwin -- Python 2.7.3 -- pytest-2.3.3
Running tests with Astropy version 0.3.dev3731.
Running tests in astropy/vo.
Platform: Darwin-12.3.0-x86_64-i386-64bit
Executable: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Full Python Version:
2.7.3 (default, Nov 19 2012, 00:46:55)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))]
Numpy: 1.7.1
Scipy: 0.12.0
Matplotlib: 1.2.0
h5py: 2.1.2
collected 1 items
astropy/vo/samp/tests/test_core.py F
========================================================================== FAILURES ==========================================================================
_____________________________________________________________________ test_SAMPHubServer _____________________________________________________________________
def test_SAMPHubServer():
"""Test that samp classes can be instantiated"""
> samp.SAMPHubServer()
# TODO: Add tests for all classes and use cases
"""
samp.SAMPHubProxy()
samp.SAMPClient()
samp.SAMPHubError()
samp.SAMPClientError()
samp.SAMPProxyError()
samp.SAMPLog()
samp.SAMPIntegratedClient()
samp.SAMPMsgReplierWrapper()
astropy/vo/samp/tests/test_core.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.vo.samp.core.SAMPHubServer object at 0x110a12890>, secret = None, addr = None, port = 0, lockfile = None, timeout = 0, client_timeout = 0
log = None, mode = 'single', label = '', owner = '', owner_group = '', auth_file = None, access_restrict = None, admin = 'admin', https = False
keyfile = None, certfile = None, cert_reqs = 0, ca_certs = None, ssl_version = 2, web_profile = True, pool_size = 20
def __init__(self, secret = None, addr=None, port=0, lockfile=None, timeout = 0, \
client_timeout = 0, log = None,
mode = SAMP_HUB_SINGLE_INSTANCE, label = "",
owner = "", owner_group = "", auth_file = None,
access_restrict = None, admin = "admin", https = False,
keyfile = None, certfile = None,
cert_reqs = 0, ca_certs = None, ssl_version = 2, web_profile = True,
pool_size=20):
"""
SAMP Hub server constructor. The SSL parameters are usable only if Python has
been compiled with SSL support and/or U{ssl <http://docs.python.org/dev/library/ssl.html>}
module is installed (available by default since Python 2.6).
@param secret: Secret code.
@type secret: string
@param addr: Listening address (or IP)
@type addr: string
@param port: Listening port number.
@type port: int
@param lockfile: Custom lockfile name.
@type port: string
@param timeout: Hub inactivity timeout. If C{timeout} > 0 then the Hub automatically
stops after an inactivity period longer than C{timeout} seconds. By default C{timeout}
is set to 0 (Hub never expires).
@type timeout: int
@param client_timeout: Client inactivity timeout. If C{client_timeout} > 0 then the
Hub automatically unregisters the clients which result inactive for a period longer
than C{client_timeout} seconds. By default C{client_timeout} is set to 0 (clients never
expire).
@type client_timeout: int
@param log: a L{SAMPLog} instance for the Hub logging. If missing then
a standard L{SAMPLog} instance is used.
@type log: L{SAMPLog}
@param mode: Defines the Hub running mode. If C{mode} is 'single' then the Hub runs
using the standard {.samp} lock-file, having a single instance for user desktop
session. Otherwise, if C{mode} is 'multiple', then the Hub runs using a non-standard
lock-file, placed in C{.samp-1} directory, of the form C{samp-hub-<PID>-<ID>}, where
C{<PID>} is the process id and C{<ID>} is a general sub-id (integer number).
@type mode: string
@param label: A string used to label the Hub with a human readable name. This string
is written in the lock-file assigned to the C{hub.label} token.
@type label: string
@param owner: General purpose Hub owner name. This value is written in the lock-file
and assigned to the C{hub.owner.name} token.
@type owner: string
@param owner_group: General purpose Hub owner group name. This value is written in the
lock-file and assigned to the C{hub.owner.group} token.
@type owner_group: string
@param auth_file: Authentication file path used for Basic Authentication. The authentication file
must be a Berkeley DB file in Hash format containing a set of C{<user name>=md5(<password>)<group
1>,<group 2>,<group 3>,...)} key/value pairs.
@type auth_file: string
@param access_restrict: Define whether the Hub access must be restricted to the Hub owner, to a certain owner
group or not restricted at all. Values accepted: L{SAMP_RESTRICT_OWNER}, L{SAMP_RESTRICT_GROUP}, B{None}
@type access_restrict: string
@param admin: Define the name of the administrator user in case of restricted access. The administrator user
can always access the hub instance even if it is running with L{SAMP_RESTRICT_OWNER} policy. The administrator
must be declared in the authentication file.
@type admin: string
@param https: set the Hub running on a Secure Sockets Layer connection (HTTPS).
By default SSL is desabled.
@type https: boolean
@param keyfile: Set the file containing the private key for SSL connections. If the
certificate file (C{certfile}) contains the private key, then C{keyfile} can be omitted.
@type keyfile: string
@param certfile: Specify the file which contains a certificate to be used to identify the
local side of the secure connection.
@type certfile: string
@param cert_reqs: The parameter C{cert_reqs} specifies whether a certificate is required
from the client side of the connection, and whether it will be validated if provided. It
must be one of the three values L{ssl.CERT_NONE} (certificates ignored), L{ssl.CERT_OPTIONAL}
(not required, but validated if provided), or L{ssl.CERT_REQUIRED} (required and validated).
If the value of this parameter is not L{ssl.CERT_NONE}, then the C{ca_certs} parameter must
point to a file of CA certificates.
@type cert_reqs: int
@param ca_certs: The C{ca_certs} file contains a set of concatenated \"Certification Authority\"
certificates, which are used to validate certificates passed from the client end of the
connection.
@type ca_certs: string
@param ssl_version: The C{ssl_version} option specifies which version of the SSL protocol to use.
Typically, the server chooses a particular protocol version, and the client must adapt to the
server's choice. Most of the versions are not interoperable with the other versions. If not
specified the default SSL version is L{ssl.PROTOCOL_SSLv23}. This version provides the most
compatibility with other versions client side. Other SSL protocol versions are:
L{ssl.PROTOCOL_SSLv2}, L{ssl.PROTOCOL_SSLv3} and L{ssl.PROTOCOL_TLSv1}.
@type ssl_version: int
@param web_profile: The C{web_profile} option enables/disables the Web Profile support.
@type ssl_version: boolean
@param pool_size: The number of socket connections opened to communicate with the clients.
@type pool_size: int
"""
# General settings
self._lockfilename = lockfile
self._admin = admin
self._addr = addr
self._port = port
self._mode = mode
self._label = label
self._owner = owner
self._owner_group = owner_group
self._timeout = timeout
self._client_timeout = client_timeout
if log == None:
self._log = SAMPLog()
else:
self._log = log
self._pool_size = pool_size
# Web Profile variables
if not HAS_TKINTER:
if web_profile:
self._log.info("Tkinter python module is missing. Impossible to start the Web profile.")
web_profile = False
self._web_profile = web_profile
self._web_profile_server = None
self._web_profile_callbacks = {}
self._web_profile_popup_dialogue = None
self._web_profile_requests_queue = Queue.Queue(1)
self._web_profile_requests_result = Queue.Queue(1)
self._web_profile_requests_semaphore = Queue.Queue(1)
if web_profile:
try:
self._web_profile_server = WebProfileXMLRPCServer(('localhost', 21012), self._log, \
logRequests = False, allow_none = True)
self._web_profile_server.register_introspection_functions()
self._log.info("Hub set to run with Web Profile support enabled.")
except:
self._log.error("Port 21012 already in use. Impossible to run the Hub with Web Profile support.")
self._web_profile = web_profile = False
# SSL general settings
self._https = https
self._keyfile = keyfile
self._certfile = certfile
self._cert_reqs = cert_reqs
self._ca_certs = cert_reqs
self._ssl_version = ssl_version
# Basic Authentication settings
self._auth_file = auth_file
self._access_restrict = access_restrict
# Reformat access_restrict string to suitable dictionary
if access_restrict != None:
if access_restrict == SAMP_RESTRICT_GROUP:
access_restrict = {"group": owner_group, "admin": admin}
elif access_restrict == SAMP_RESTRICT_OWNER:
access_restrict = {"user": owner, "admin": admin}
else:
access_restrict = None
# Athentication file test
if auth_file != None:
if not os.path.isfile(auth_file):
self._log.error("Unable to load authentication file!")
raise SAMPHubError("Unable to load authentication file!")
self._host_name = "127.0.0.1"
> if internet_on():
astropy/vo/samp/core.py:1556:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def internet_on():
try:
> response = urllib2.urlopen('http://74.125.113.99',timeout=1)
astropy/vo/samp/core.py:334:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'http://74.125.113.99', data = None, timeout = 1
def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
global _opener
if _opener is None:
_opener = build_opener()
> return _opener.open(url, data, timeout)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:126:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib2.OpenerDirector instance at 0x110a22830>, fullurl = 'http://74.125.113.99', data = None, timeout = 1
def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
# accept a URL or a Request object
if isinstance(fullurl, basestring):
req = Request(fullurl, data)
else:
req = fullurl
if data is not None:
req.add_data(data)
req.timeout = timeout
protocol = req.get_type()
# pre-process request
meth_name = protocol+"_request"
for processor in self.process_request.get(protocol, []):
meth = getattr(processor, meth_name)
req = meth(req)
> response = self._open(req, data)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:400:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib2.OpenerDirector instance at 0x110a22830>, req = <urllib2.Request instance at 0x110a202d8>, data = None
def _open(self, req, data=None):
result = self._call_chain(self.handle_open, 'default',
'default_open', req)
if result:
return result
protocol = req.get_type()
result = self._call_chain(self.handle_open, protocol, protocol +
> '_open', req)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:418:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib2.OpenerDirector instance at 0x110a22830>
chain = {'file': [<urllib2.FileHandler instance at 0x110a20200>], 'ftp': [<urllib2.FTPHandler instance at 0x110a201b8>], 'http': [<urllib2.HTTPHandler instance at 0x110a200e0>], 'https': [<urllib2.HTTPSHandler instance at 0x110a20290>], ...}
kind = 'http', meth_name = 'http_open', args = (<urllib2.Request instance at 0x110a202d8>,), handlers = [<urllib2.HTTPHandler instance at 0x110a200e0>]
handler = <urllib2.HTTPHandler instance at 0x110a200e0>, func = <bound method HTTPHandler.http_open of <urllib2.HTTPHandler instance at 0x110a200e0>>
def _call_chain(self, chain, kind, meth_name, *args):
# Handlers raise an exception if no one else should try to handle
# the request, or return None if they can't but another handler
# could. Otherwise, they return the response.
handlers = chain.get(kind, ())
for handler in handlers:
func = getattr(handler, meth_name)
> result = func(*args)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:378:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib2.HTTPHandler instance at 0x110a200e0>, req = <urllib2.Request instance at 0x110a202d8>
def http_open(self, req):
> return self.do_open(httplib.HTTPConnection, req)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:1207:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib2.HTTPHandler instance at 0x110a200e0>, http_class = <class httplib.HTTPConnection at 0x110457bb0>
req = <urllib2.Request instance at 0x110a202d8>
def do_open(self, http_class, req):
"""Return an addinfourl object for the request, using http_class.
http_class must implement the HTTPConnection API from httplib.
The addinfourl return value is a file-like object. It also
has methods and attributes including:
- info(): return a mimetools.Message object for the headers
- geturl(): return the original request URL
- code: HTTP status code
"""
host = req.get_host()
if not host:
raise URLError('no host given')
h = http_class(host, timeout=req.timeout) # will parse host:port
h.set_debuglevel(self._debuglevel)
headers = dict(req.unredirected_hdrs)
headers.update(dict((k, v) for k, v in req.headers.items()
if k not in headers))
# We want to make an HTTP/1.1 request, but the addinfourl
# class isn't prepared to deal with a persistent connection.
# It will try to read all remaining data from the socket,
# which will block while the server waits for the next request.
# So make sure the connection gets closed after the (only)
# request.
headers["Connection"] = "close"
headers = dict(
(name.title(), val) for name, val in headers.items())
if req._tunnel_host:
tunnel_headers = {}
proxy_auth_hdr = "Proxy-Authorization"
if proxy_auth_hdr in headers:
tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
# Proxy-Authorization should not be sent to origin
# server.
del headers[proxy_auth_hdr]
h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
try:
h.request(req.get_method(), req.get_selector(), req.data, headers)
except socket.error, err: # XXX what error?
h.close()
raise URLError(err)
else:
try:
> r = h.getresponse(buffering=True)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:1180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httplib.HTTPConnection instance at 0x110a204d0>, buffering = True
def getresponse(self, buffering=False):
"Get the response from the server."
# if a prior response has been completed, then forget about it.
if self.__response and self.__response.isclosed():
self.__response = None
#
# if a prior response exists, then it must be completed (otherwise, we
# cannot read this response's header to determine the connection-close
# behavior)
#
# note: if a prior response existed, but was connection-close, then the
# socket and response were made independent of this HTTPConnection
# object since a new request requires that we open a whole new
# connection
#
# this means the prior response had one of two states:
# 1) will_close: this connection was reset and the prior socket and
# response operate independently
# 2) persistent: the response was retained and we await its
# isclosed() status to become true.
#
if self.__state != _CS_REQ_SENT or self.__response:
raise ResponseNotReady()
args = (self.sock,)
kwds = {"strict":self.strict, "method":self._method}
if self.debuglevel > 0:
args += (self.debuglevel,)
if buffering:
#only add this keyword if non-default, for compatibility with
#other response_classes.
kwds["buffering"] = True;
response = self.response_class(*args, **kwds)
> response.begin()
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:1030:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httplib.HTTPResponse instance at 0x110a20320>
def begin(self):
if self.msg is not None:
# we've already started reading the response
return
# read until we get a non-100 response
while True:
> version, status, reason = self._read_status()
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:407:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httplib.HTTPResponse instance at 0x110a20320>
def _read_status(self):
# Initialize with Simple-Response defaults
> line = self.fp.readline()
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:365:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <socket._fileobject object at 0x10fd15450>, size = -1
def readline(self, size=-1):
buf = self._rbuf
buf.seek(0, 2) # seek end
if buf.tell() > 0:
# check if we already have it in our buffer
buf.seek(0)
bline = buf.readline(size)
if bline.endswith('\n') or len(bline) == size:
self._rbuf = StringIO()
self._rbuf.write(buf.read())
return bline
del bline
if size < 0:
# Read until \n or EOF, whichever comes first
if self._rbufsize <= 1:
# Speed up unbuffered case
buf.seek(0)
buffers = [buf.read()]
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
data = None
recv = self._sock.recv
while True:
try:
while data != "\n":
data = recv(1)
if not data:
break
buffers.append(data)
except error, e:
# The try..except to catch EINTR was moved outside the
# recv loop to avoid the per byte overhead.
if e.args[0] == EINTR:
continue
raise
break
return "".join(buffers)
buf.seek(0, 2) # seek end
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
while True:
try:
> data = self._sock.recv(self._rbufsize)
E timeout: timed out
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py:447: timeout
---------------------------------------------------------------------- Captured stdout -----------------------------------------------------------------------
[SAMP] Info (2013-04-13T10:56:12.270896): Hub set to run with Web Profile support enabled.
================================================================== 1 failed in 1.29 seconds ==================================================================
Exception AttributeError: "'SAMPHubServer' object has no attribute '_is_running'" in <bound method SAMPHubServer.__del__ of <astropy.vo.samp.core.SAMPHubServer object at 0x110a12890>> ignored
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment