Merge pull request #195 from cgallemore/master

Resolves issue #194
This commit is contained in:
David Cramer 2012-10-19 12:24:19 -07:00
commit f9153f1b70
3 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ pip-log.txt
bin/
include/
lib/
.idea

View File

@ -25,7 +25,10 @@ TIMEOUT = 5
# TODO: this is specific to Django
CLIENT = 'raven.contrib.django.DjangoClient'
NAME = socket.gethostname()
# Not all environments have access to socket module, for example Google App Engine
# Need to check to see if the socket module has ``gethostname``, if it doesn't we
# will set it to None and require it passed in to ``Client`` on initializtion.
NAME = socket.gethostname() if hasattr(socket, 'gethostname') else None
# Superuser key -- will be used if set, otherwise defers to
# SECRET_KEY and PUBLIC_KEY

View File

@ -9,7 +9,14 @@ raven.transport.builtins
import logging
import sys
import urllib2
from socket import socket, AF_INET, SOCK_DGRAM, error as socket_error
try:
# Google App Engine blacklists parts of the socket module, this will prevent
# it from blowing up.
from socket import socket, AF_INET, SOCK_DGRAM, error as socket_error
has_socket = True
except:
has_socket = False
try:
import gevent
@ -80,6 +87,8 @@ class UDPTransport(Transport):
scheme = ['udp']
def __init__(self, parsed_url):
if not has_socket:
raise ImportError('UDPTransport requires the socket module')
self.check_scheme(parsed_url)
self._parsed_url = parsed_url