buggy stringlengths 35 5.03k | fixed stringlengths 46 62.5k |
|---|---|
def test_offset_label_color():
assert ax.yaxis.get_offset_text().get_color() == 'red'
def test_large_offset():
fig, ax = plt.subplots()
ax.plot((1 + np.array([0, 1.e-12])) * 1.e27) | def test_offset_label_color():
assert ax.yaxis.get_offset_text().get_color() == 'red'
def test_offset_text_visible():
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot([1.01e9, 1.02e9, 1.03e9])
ax.yaxis.set_tick_params(label1On=False, label2On=True)
assert ax.yaxis.get_offset_text().get... |
from pandas.core.dtypes.common import (
ensure_object,
is_bool_dtype,
is_complex_dtype,
is_datetime64_dtype,
is_datetime64tz_dtype,
is_datetimelike_v_numeric,
is_dtype_equal,
is_extension_array_dtype,
is_float_dtype,
is_integer_dtype,
is_object_dtype,
is_period_dtype,
... | from pandas.core.dtypes.common import (
ensure_object,
is_bool_dtype,
is_complex_dtype,
is_datetimelike_v_numeric,
is_dtype_equal,
is_extension_array_dtype,
is_float_dtype,
is_integer_dtype,
is_object_dtype,
is_scalar,
is_string_dtype,
is_string_like_dtype,
needs_i8_c... |
def _isna_new(obj):
raise NotImplementedError("isna is not defined for MultiIndex")
elif isinstance(obj, type):
return False
elif isinstance(
obj,
(
ABCSeries,
np.ndarray,
ABCIndexClass,
ABCExtensionArray,
ABCDatetimeArr... | def _isna_new(obj):
raise NotImplementedError("isna is not defined for MultiIndex")
elif isinstance(obj, type):
return False
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass, ABCExtensionArray)):
return _isna_ndarraylike(obj)
elif isinstance(obj, ABCDataFrame):
retu... |
def _isna_new(obj):
elif hasattr(obj, "__array__"):
return _isna_ndarraylike(np.asarray(obj))
else:
return obj is None
def _isna_old(obj): | def _isna_new(obj):
elif hasattr(obj, "__array__"):
return _isna_ndarraylike(np.asarray(obj))
else:
return False
def _isna_old(obj): |
def _isna_old(obj):
elif hasattr(obj, "__array__"):
return _isna_ndarraylike_old(np.asarray(obj))
else:
return obj is None
_isna = _isna_new | def _isna_old(obj):
elif hasattr(obj, "__array__"):
return _isna_ndarraylike_old(np.asarray(obj))
else:
return False
_isna = _isna_new |
def _use_inf_as_na(key):
def _isna_ndarraylike(obj):
is_extension = is_extension_array_dtype(obj)
if not is_extension:
# Avoid accessing `.values` on things like
# PeriodIndex, which may be expensive.
values = getattr(obj, "_values", obj)
else:
values = obj
dtype = va... | def _use_inf_as_na(key):
def _isna_ndarraylike(obj):
is_extension = is_extension_array_dtype(obj.dtype)
values = getattr(obj, "_values", obj)
dtype = values.dtype
if is_extension:
result = values.isna()
elif is_string_dtype(dtype):
result = _isna_string_dtype(values, dtype, old=Fa... |
def _isna_ndarraylike_old(obj):
dtype = values.dtype
if is_string_dtype(dtype):
# Working around NumPy ticket 1542
shape = values.shape
if is_string_like_dtype(dtype):
result = np.zeros(values.shape, dtype=bool)
else:
result = np.empty(shape, dtype=bool)... | def _isna_ndarraylike_old(obj):
dtype = values.dtype
if is_string_dtype(dtype):
result = _isna_string_dtype(values, dtype, old=True)
elif needs_i8_conversion(dtype):
# this is the NaT pattern
result = values.view("i8") == iNaT
else: |
def _isna_ndarraylike_old(obj):
return result
def notna(obj):
"""
Detect non-missing values for an array-like object. | def _isna_ndarraylike_old(obj):
return result
def _isna_string_dtype(values: np.ndarray, dtype: np.dtype, old: bool) -> np.ndarray:
# Working around NumPy ticket 1542
shape = values.shape
if is_string_like_dtype(dtype):
result = np.zeros(values.shape, dtype=bool)
else:
result = np... |
def na_value_for_dtype(dtype, compat: bool = True):
if is_extension_array_dtype(dtype):
return dtype.na_value
if (
is_datetime64_dtype(dtype)
or is_datetime64tz_dtype(dtype)
or is_timedelta64_dtype(dtype)
or is_period_dtype(dtype)
):
return NaT
elif is_fl... | def na_value_for_dtype(dtype, compat: bool = True):
if is_extension_array_dtype(dtype):
return dtype.na_value
if needs_i8_conversion(dtype):
return NaT
elif is_float_dtype(dtype):
return np.nan |
class TestIsNA:
exp = np.zeros(len(mask), dtype=bool)
tm.assert_numpy_array_equal(mask, exp)
@pytest.mark.parametrize(
"value, expected",
[ | class TestIsNA:
exp = np.zeros(len(mask), dtype=bool)
tm.assert_numpy_array_equal(mask, exp)
def test_isna_old_datetimelike(self):
# isna_old should work for dt64tz, td64, and period, not just tznaive
dti = pd.date_range("2016-01-01", periods=3)
dta = dti._data
dta[-... |
class HttpRequest(object):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# There is no hostname validation when DEBUG=True
if settings.DEBUG:
return host
domain, port = split_domain_port(host)
if domain and ... | class HttpRequest(object):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
... |
class CsrfViewMiddlewareTest(SimpleTestCase):
self.assertEqual(len(csrf_cookie.value), CSRF_TOKEN_LENGTH)
self._check_token_present(resp, csrf_id=csrf_cookie.value)
@override_settings(DEBUG=True)
def test_https_bad_referer(self):
"""
Test that a POST HTTPS request with a bad ref... | class CsrfViewMiddlewareTest(SimpleTestCase):
self.assertEqual(len(csrf_cookie.value), CSRF_TOKEN_LENGTH)
self._check_token_present(resp, csrf_id=csrf_cookie.value)
@override_settings(DEBUG=True, ALLOWED_HOSTS=['www.example.com'])
def test_https_bad_referer(self):
"""
Test that ... |
class HostValidationTests(SimpleTestCase):
self.assertEqual(request.get_port(), '8080')
@override_settings(DEBUG=True, ALLOWED_HOSTS=[])
def test_host_validation_disabled_in_debug_mode(self):
"""If ALLOWED_HOSTS is empty and DEBUG is True, all hosts pass."""
request = HttpRequest()
... | class HostValidationTests(SimpleTestCase):
self.assertEqual(request.get_port(), '8080')
@override_settings(DEBUG=True, ALLOWED_HOSTS=[])
def test_host_validation_in_debug_mode(self):
"""
If ALLOWED_HOSTS is empty and DEBUG is True, variants of localhost are
allowed.
"""
... |
from django.contrib.postgres.fields import ArrayField, JSONField
from django.db.models.aggregates import Aggregate
from .mixins import OrderableAggMixin | from django.contrib.postgres.fields import ArrayField, JSONField
from django.db.models import Value
from django.db.models.aggregates import Aggregate
from .mixins import OrderableAggMixin |
class JSONBAgg(Aggregate):
class StringAgg(OrderableAggMixin, Aggregate):
function = 'STRING_AGG'
template = "%(function)s(%(distinct)s%(expressions)s, '%(delimiter)s'%(ordering)s)"
allow_distinct = True
def __init__(self, expression, delimiter, **extra):
super().__init__(expression, delimiter... | class JSONBAgg(Aggregate):
class StringAgg(OrderableAggMixin, Aggregate):
function = 'STRING_AGG'
template = '%(function)s(%(distinct)s%(expressions)s %(ordering)s)'
allow_distinct = True
def __init__(self, expression, delimiter, **extra):
delimiter_expr = Value(str(delimiter))
super()... |
from django.db.models.expressions import F, OrderBy
class OrderableAggMixin:
def __init__(self, expression, ordering=(), **extra):
if not isinstance(ordering, (list, tuple)):
ordering = [ordering]
ordering = ordering or [] | from django.db.models.expressions import F, OrderBy
class OrderableAggMixin:
def __init__(self, *expressions, ordering=(), **extra):
if not isinstance(ordering, (list, tuple)):
ordering = [ordering]
ordering = ordering or [] |
class OrderableAggMixin:
(OrderBy(F(o[1:]), descending=True) if isinstance(o, str) and o[0] == '-' else o)
for o in ordering
)
super().__init__(expression, **extra)
self.ordering = self._parse_expressions(*ordering)
def resolve_expression(self, *args, **kwargs): | class OrderableAggMixin:
(OrderBy(F(o[1:]), descending=True) if isinstance(o, str) and o[0] == '-' else o)
for o in ordering
)
super().__init__(*expressions, **extra)
self.ordering = self._parse_expressions(*ordering)
def resolve_expression(self, *args, **kwargs): |
class TestGeneralAggregate(PostgreSQLTestCase):
with self.assertRaises(TypeError):
AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field'))
def test_string_agg_charfield(self):
values = AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field', delimiter=';'))... | class TestGeneralAggregate(PostgreSQLTestCase):
with self.assertRaises(TypeError):
AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field'))
def test_string_agg_delimiter_escaping(self):
values = AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field', delimi... |
"""
from os import path, listdir
import os
import sys
import errno
import marshal | """
from os import path, listdir
import os
import stat
import sys
import errno
import marshal |
class FileSystemBytecodeCache(BytecodeCache):
# On windows the temporary directory is used specific unless
# explicitly forced otherwise. We can just use that.
if os.name == 'n':
return tmpdir
if not hasattr(os, 'getuid'):
raise RuntimeError('Cannot determine sa... | class FileSystemBytecodeCache(BytecodeCache):
# On windows the temporary directory is used specific unless
# explicitly forced otherwise. We can just use that.
if os.name == 'nt':
return tmpdir
if not hasattr(os, 'getuid'):
raise RuntimeError('Cannot determine s... |
class FileSystemBytecodeCache(BytecodeCache):
dirname = '_jinja2-cache-%d' % os.getuid()
actual_dir = os.path.join(tmpdir, dirname)
try:
# 448 == 0700
os.mkdir(actual_dir, 448)
except OSError as e:
if e.errno != errno.EEXIST:
raise
... | class FileSystemBytecodeCache(BytecodeCache):
dirname = '_jinja2-cache-%d' % os.getuid()
actual_dir = os.path.join(tmpdir, dirname)
try:
os.mkdir(actual_dir, stat.S_IRWXU) # 0o700
except OSError as e:
if e.errno != errno.EEXIST:
raise
actu... |
def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None:
check_lpar = False
for index, child in enumerate(list(node.children)):
if check_lpar:
if child.type == syms.atom:
if maybe_make_parens_invisible_in_atom(child, parent=node): | def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None:
check_lpar = False
for index, child in enumerate(list(node.children)):
# Add parentheses around long tuple unpacking in assignments.
if (
index == 0
and isinstance(child, Node)
and ch... |
def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None:
lpar = Leaf(token.LPAR, "")
rpar = Leaf(token.RPAR, "")
index = child.remove() or 0
node.insert_child(index, Node(syms.atom, [lpar, child, rpar]))
check_lpar = isinstance(... | def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None:
lpar = Leaf(token.LPAR, "")
rpar = Leaf(token.RPAR, "")
index = child.remove() or 0
prefix = child.prefix
child.prefix = ""
new_child = Node(syms.at... |
class BlackTestCase(unittest.TestCase):
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, black.FileMode())
def test_tab_comment_indentation(self) -> None:
contents_tab = "if 1:\n\tif 2:\n\t\tpass\n\t# comment\n\tpass\n"
contents_spc = "if 1:\n if 2:\n ... | class BlackTestCase(unittest.TestCase):
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, black.FileMode())
@patch("black.dump_to_file", dump_to_stderr)
def test_tuple_assign(self) -> None:
source, expected = read_data("tupleassign")
actual = fs(source)... |
import socks
except (ImportError, AttributeError):
socks = None
# Build the appropriate socket wrapper for ssl
ssl = None | import socks
except (ImportError, AttributeError):
socks = None
from httplib2 import auth
from httplib2.error import *
# Build the appropriate socket wrapper for ssl
ssl = None |
ssl_CertificateError = getattr(ssl, "CertificateError", None)
def _ssl_wrap_socket(
sock, key_file, cert_file, disable_validation, ca_certs, ssl_version, hostname, key_password
):
if disable_validation:
cert_reqs = ssl.CERT_NONE
else: | ssl_CertificateError = getattr(ssl, "CertificateError", None)
def _ssl_wrap_socket(sock, key_file, cert_file, disable_validation, ca_certs, ssl_version, hostname, key_password):
if disable_validation:
cert_reqs = ssl.CERT_NONE
else: |
def _ssl_wrap_socket(
if key_password:
raise NotSupportedOnThisPlatform("Certificate with password is not supported.")
return ssl.wrap_socket(
sock,
keyfile=key_file,
certfile=cert_file,
cert_reqs=cert_reqs,
ca_certs=ca_certs,
... | def _ssl_wrap_socket(
if key_password:
raise NotSupportedOnThisPlatform("Certificate with password is not supported.")
return ssl.wrap_socket(
sock, keyfile=key_file, certfile=cert_file, cert_reqs=cert_reqs, ca_certs=ca_certs, ssl_version=ssl_version,
)
|
class NotRunningAppEngineEnvironment(HttpLib2Error):
DEFAULT_MAX_REDIRECTS = 5
from httplib2 import certs
CA_CERTS = certs.where()
# Which headers are hop-by-hop headers by default | class NotRunningAppEngineEnvironment(HttpLib2Error):
DEFAULT_MAX_REDIRECTS = 5
from httplib2 import certs
CA_CERTS = certs.where()
# Which headers are hop-by-hop headers by default |
def safename(filename):
def _normalize_headers(headers):
return dict(
[
(key.lower(), NORMALIZE_SPACE.sub(value, " ").strip())
for (key, value) in headers.iteritems()
]
)
def _parse_cache_control(headers): | def safename(filename):
def _normalize_headers(headers):
return dict([(key.lower(), NORMALIZE_SPACE.sub(value, " ").strip()) for (key, value) in headers.iteritems()])
def _parse_cache_control(headers): |
def _parse_cache_control(headers):
if "cache-control" in headers:
parts = headers["cache-control"].split(",")
parts_with_args = [
tuple([x.strip().lower() for x in part.split("=", 1)])
for part in parts
if -1 != part.find("=")
]
parts_wo_args = [
... | def _parse_cache_control(headers):
if "cache-control" in headers:
parts = headers["cache-control"].split(",")
parts_with_args = [
tuple([x.strip().lower() for x in part.split("=", 1)]) for part in parts if -1 != part.find("=")
]
parts_wo_args = [(name.strip().lower(), 1) ... |
def _parse_cache_control(headers):
# Set to true to turn on, usefull for testing servers.
USE_WWW_AUTH_STRICT_PARSING = 0
# In regex below:
# [^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+ matches a "token" as defined by HTTP
# "(?:[^\0-\x08\x0A-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?" matches a "quoted-st... | def _parse_cache_control(headers):
# Set to true to turn on, usefull for testing servers.
USE_WWW_AUTH_STRICT_PARSING = 0
# TODO: add current time as _entry_disposition argument to avoid sleep in tests
def _entry_disposition(response_headers, request_headers): |
def _entry_disposition(response_headers, request_headers):
cc = _parse_cache_control(request_headers)
cc_response = _parse_cache_control(response_headers)
if (
"pragma" in request_headers
and request_headers["pragma"].lower().find("no-cache") != -1
):
retval = "TRANSPARENT"
... | def _entry_disposition(response_headers, request_headers):
cc = _parse_cache_control(request_headers)
cc_response = _parse_cache_control(response_headers)
if "pragma" in request_headers and request_headers["pragma"].lower().find("no-cache") != -1:
retval = "TRANSPARENT"
if "cache-control" n... |
def _decompressContent(response, new_content):
except (IOError, zlib.error):
content = ""
raise FailedToDecompressContent(
_("Content purported to be compressed with %s but failed to decompress.")
% response.get("content-encoding"),
response,
content,
... | def _decompressContent(response, new_content):
except (IOError, zlib.error):
content = ""
raise FailedToDecompressContent(
_("Content purported to be compressed with %s but failed to decompress.") % response.get("content-encoding"),
response,
content,
) |
def _updateCache(request_headers, response_headers, content, cache, cachekey):
def _cnonce():
dig = _md5(
"%s:%s"
% (time.ctime(), ["0123456789"[random.randrange(0, 9)] for i in range(20)])
).hexdigest()
return dig[:16]
def _wsse_username_token(cnonce, iso_now, password):
return base... | def _updateCache(request_headers, response_headers, content, cache, cachekey):
def _cnonce():
dig = _md5("%s:%s" % (time.ctime(), ["0123456789"[random.randrange(0, 9)] for i in range(20)])).hexdigest()
return dig[:16]
def _wsse_username_token(cnonce, iso_now, password):
return base64.b64encode(_sha("%s%... |
def _wsse_username_token(cnonce, iso_now, password):
class Authentication(object):
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
self.path = path
self.host = host | def _wsse_username_token(cnonce, iso_now, password):
class Authentication(object):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
self.path = path
self.host = host |
def response(self, response, content):
class BasicAuthentication(Authentication):
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(
self, credentials, host, request_uri, headers, response, content, http
)
d... | def response(self, response, content):
class BasicAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
def request(self, method, request_uri... |
def request(self, method, request_uri, headers, content, cnonce=None):
def response(self, response, content):
if "authentication-info" not in response:
challenge = _parse_www_authenticate(response, "www-authenticate").get(
"digest", {}
)
if "true" == chal... | def request(self, method, request_uri, headers, content, cnonce=None):
def response(self, response, content):
if "authentication-info" not in response:
challenge = auth._parse_www_authenticate(response, "www-authenticate").get("digest", {})
if "true" == challenge.get("stale"):
... |
class HmacDigestAuthentication(Authentication):
__author__ = "Thomas Broyer (t.broyer@ltgt.net)"
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(
self, credentials, host, request_uri, headers, response, content, ht... | class HmacDigestAuthentication(Authentication):
__author__ = "Thomas Broyer (t.broyer@ltgt.net)"
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
challenge = aut... |
def __init__(
self.challenge["pw-algorithm"] = self.challenge.get("pw-algorithm", "SHA-1")
if self.challenge["pw-algorithm"] not in ["SHA-1", "MD5"]:
raise UnimplementedHmacDigestAuthOptionError(
_(
"Unsupported value for pw-algorithm: %s."
... | def __init__(
self.challenge["pw-algorithm"] = self.challenge.get("pw-algorithm", "SHA-1")
if self.challenge["pw-algorithm"] not in ["SHA-1", "MD5"]:
raise UnimplementedHmacDigestAuthOptionError(
_("Unsupported value for pw-algorithm: %s." % self.challenge["pw-algorithm"])
... |
def __init__(
[
self.credentials[0],
":",
self.pwhashmod.new(
"".join([self.credentials[1], self.challenge["salt"]])
)
.hexdigest()
.lower(),
":",
self.challeng... | def __init__(
[
self.credentials[0],
":",
self.pwhashmod.new("".join([self.credentials[1], self.challenge["salt"]])).hexdigest().lower(),
":",
self.challenge["realm"],
] |
def request(self, method, request_uri, headers, content):
headers_val = "".join([headers[k] for k in keys])
created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
request_digest = "%s:%s:%s:%s:%s" % (
method,
request_uri,
cnonc... | def request(self, method, request_uri, headers, content):
headers_val = "".join([headers[k] for k in keys])
created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
request_digest = "%s:%s:%s:%s:%s" % (method, request_uri, cnonce, self.challenge["snonce"], headers_... |
def request(self, method, request_uri, headers, content):
)
def response(self, response, content):
challenge = _parse_www_authenticate(response, "www-authenticate").get(
"hmacdigest", {}
)
if challenge.get("reason") in ["integrity", "stale"]:
return True
... | def request(self, method, request_uri, headers, content):
)
def response(self, response, content):
challenge = auth._parse_www_authenticate(response, "www-authenticate").get("hmacdigest", {})
if challenge.get("reason") in ["integrity", "stale"]:
return True
return False |
class WsseAuthentication(Authentication):
challenge but instead requiring your client to telepathically know that
their endpoint is expecting WSSE profile="UsernameToken"."""
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(... | class WsseAuthentication(Authentication):
challenge but instead requiring your client to telepathically know that
their endpoint is expecting WSSE profile="UsernameToken"."""
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credenti... |
def request(self, method, request_uri, headers, content):
iso_now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
password_digest = _wsse_username_token(cnonce, iso_now, self.credentials[1])
headers["X-WSSE"] = (
'UsernameToken Username="%s", PasswordD... | def request(self, method, request_uri, headers, content):
iso_now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
password_digest = _wsse_username_token(cnonce, iso_now, self.credentials[1])
headers["X-WSSE"] = ('UsernameToken Username="%s", PasswordDigest="%s", '... |
def __init__(
# elif request_uri.find("spreadsheets") > 0:
# service = "wise"
auth = dict(
Email=credentials[0],
Passwd=credentials[1],
service=service,
source=headers["user-agent"],
)
resp, content = self.http.request(
... | def __init__(
# elif request_uri.find("spreadsheets") > 0:
# service = "wise"
auth = dict(Email=credentials[0], Passwd=credentials[1], service=service, source=headers["user-agent"],)
resp, content = self.http.request(
"https://www.google.com/accounts/ClientLogin",
... |
class FileCache(object):
be running on the same cache.
"""
def __init__(
self, cache, safe=safename
): # use safe=lambda x: md5.new(x).hexdigest() for the old behavior
self.cache = cache
self.safe = safe
if not os.path.exists(cache): | class FileCache(object):
be running on the same cache.
"""
def __init__(self, cache, safe=safename): # use safe=lambda x: md5.new(x).hexdigest() for the old behavior
self.cache = cache
self.safe = safe
if not os.path.exists(cache): |
def iter(self, domain):
class KeyCerts(Credentials):
"""Identical to Credentials except that
name/password are mapped to key/cert."""
def add(self, key, cert, domain, password):
self.credentials.append((domain.lower(), key, cert, password))
| def iter(self, domain):
class KeyCerts(Credentials):
"""Identical to Credentials except that
name/password are mapped to key/cert."""
def add(self, key, cert, domain, password):
self.credentials.append((domain.lower(), key, cert, password))
|
class ProxyInfo(object):
bypass_hosts = ()
def __init__(
self,
proxy_type,
proxy_host,
proxy_port,
proxy_rdns=True,
proxy_user=None,
proxy_pass=None,
proxy_headers=None,
):
"""Args:
| class ProxyInfo(object):
bypass_hosts = ()
def __init__(
self, proxy_type, proxy_host, proxy_port, proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None,
):
"""Args:
|
def connect(self):
"""Connect to the host and port specified in __init__."""
# Mostly verbatim from httplib.py.
if self.proxy_info and socks is None:
raise ProxiesUnavailableError(
"Proxy support missing but proxy use was requested!"
)
if self.prox... | def connect(self):
"""Connect to the host and port specified in __init__."""
# Mostly verbatim from httplib.py.
if self.proxy_info and socks is None:
raise ProxiesUnavailableError("Proxy support missing but proxy use was requested!")
if self.proxy_info and self.proxy_info.isg... |
def connect(self):
if use_proxy:
self.sock = socks.socksocket(af, socktype, proto)
self.sock.setproxy(
proxy_type,
proxy_host,
proxy_port,
proxy_rdns,
... | def connect(self):
if use_proxy:
self.sock = socks.socksocket(af, socktype, proto)
self.sock.setproxy(
proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers,
)
else:
... |
def connect(self):
if use_proxy:
print(
"proxy: %s ************"
% str(
(
proxy_host,
proxy_port,
... | def connect(self):
if use_proxy:
print(
"proxy: %s ************"
% str((proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers,))
)
if use_proxy:
... |
def connect(self):
if use_proxy:
print(
"proxy: %s"
% str(
(
proxy_host,
proxy_port,
... | def connect(self):
if use_proxy:
print(
"proxy: %s"
% str((proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers,))
)
if self.sock:
self.soc... |
def connect(self):
if self.proxy_info and self.proxy_info.isgood():
use_proxy = True
proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers = (
self.proxy_info.astuple()
)
host = proxy_host
port = proxy_... | def connect(self):
if self.proxy_info and self.proxy_info.isgood():
use_proxy = True
(
proxy_type,
proxy_host,
proxy_port,
proxy_rdns,
proxy_user,
proxy_pass,
proxy_headers,
... |
def connect(self):
sock = socks.socksocket(family, socktype, proto)
sock.setproxy(
proxy_type,
proxy_host,
proxy_port,
proxy_rdns,
proxy_user,
... | def connect(self):
sock = socks.socksocket(family, socktype, proto)
sock.setproxy(
proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers,
)
else:
sock = socket.socket(... |
def connect(self):
if use_proxy:
print(
"proxy: %s"
% str(
(
proxy_host,
proxy_port,
... | def connect(self):
if use_proxy:
print(
"proxy: %s"
% str((proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers,))
)
if not self.disable_ssl_certificate_valida... |
def connect(self):
if use_proxy:
print(
"proxy: %s"
% str(
(
proxy_host,
proxy_port,
... | def connect(self):
if use_proxy:
print(
"proxy: %s"
% str((proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers,))
)
if self.sock:
self.soc... |
def connect(self):
def _new_fixed_fetch(validate_certificate):
def fixed_fetch(
url,
payload=None,
method="GET",
headers={},
allow_truncated=False,
follow_redirects=True,
deadline=None,
):
return fetch(
url, | def connect(self):
def _new_fixed_fetch(validate_certificate):
def fixed_fetch(
url, payload=None, method="GET", headers={}, allow_truncated=False, follow_redirects=True, deadline=None,
):
return fetch(
url, |
def __init__(
disable_ssl_certificate_validation=False,
ssl_version=None,
):
httplib.HTTPConnection.__init__(
self, host, port=port, strict=strict, timeout=timeout
)
class AppEngineHttpsConnection(httplib.HTTPSConnection): | def __init__(
disable_ssl_certificate_validation=False,
ssl_version=None,
):
httplib.HTTPConnection.__init__(self, host, port=port, strict=strict, timeout=timeout)
class AppEngineHttpsConnection(httplib.HTTPSConnection): |
def __init__(
if key_password:
raise NotSupportedOnThisPlatform("Certificate with password is not supported.")
httplib.HTTPSConnection.__init__(
self,
host,
port=port,
key_file=key_file,
cert_file=cert_file,
strict=stric... | def __init__(
if key_password:
raise NotSupportedOnThisPlatform("Certificate with password is not supported.")
httplib.HTTPSConnection.__init__(
self, host, port=port, key_file=key_file, cert_file=cert_file, strict=strict, timeout=timeout,
)
self._fetch = _new_fix... |
def is_gae_instance():
raise NotRunningAppEngineEnvironment()
from google.appengine.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub("urlfetch") is None:
raise ImportError
| def is_gae_instance():
raise NotRunningAppEngineEnvironment()
from google.appengine.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub("urlfetch") is None:
raise ImportError
|
def _auth_from_challenge(self, host, request_uri, headers, response, content):
"""A generator that creates Authorization objects
that can be applied to requests.
"""
challenges = _parse_www_authenticate(response, "www-authenticate")
for cred in self.credentials.iter(host):
... | def _auth_from_challenge(self, host, request_uri, headers, response, content):
"""A generator that creates Authorization objects
that can be applied to requests.
"""
challenges = auth._parse_www_authenticate(response, "www-authenticate")
for cred in self.credentials.iter(host)... |
def _conn_request(self, conn, request_uri, method, body, headers):
return (response, content)
def _request(
self,
conn,
host,
absolute_uri,
request_uri,
method,
body,
headers,
redirections,
cachekey,
):
"""Do the ac... | def _conn_request(self, conn, request_uri, method, body, headers):
return (response, content)
def _request(
self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey,
):
"""Do the actual request using the connection object
and also follow one lev... |
def _request(
del headers["if-none-match"]
if "if-modified-since" in headers:
del headers["if-modified-since"]
if (
"authorization" in headers
and not self.forward_authorization_header... | def _request(
del headers["if-none-match"]
if "if-modified-since" in headers:
del headers["if-modified-since"]
if "authorization" in headers and not self.forward_authorization_headers:
del headers["authorizat... |
def _request(
redirect_method = "GET"
body = None
(response, content) = self.request(
location,
method=redirect_method,
body=body,
... | def _request(
redirect_method = "GET"
body = None
(response, content) = self.request(
location, method=redirect_method, body=body, headers=headers, redirections=redirections - 1,
)
... |
def _normalize_headers(self, headers):
# including all socket.* and httplib.* exceptions.
def request(
self,
uri,
method="GET",
body=None,
headers=None,
redirections=DEFAULT_MAX_REDIRECTS,
connection_type=None,
):
""" Performs a single HTTP re... | def _normalize_headers(self, headers):
# including all socket.* and httplib.* exceptions.
def request(
self, uri, method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None,
):
""" Performs a single HTTP request.
|
def request(
being and instance of the 'Response' class, the second being
a string that contains the response entity body.
"""
conn_key = ''
try:
if headers is None: | def request(
being and instance of the 'Response' class, the second being
a string that contains the response entity body.
"""
conn_key = ""
try:
if headers is None: |
def request(
# Should cached permanent redirects be counted in our redirection count? For now, yes.
if redirections <= 0:
raise RedirectLimit(
"Redirected more times than rediection_limit allows.",
{}... | def request(
# Should cached permanent redirects be counted in our redirection count? For now, yes.
if redirections <= 0:
raise RedirectLimit(
"Redirected more times than rediection_limit allows.", {}, "",
... |
def request(
return (response, content)
if entry_disposition == "STALE":
if (
"etag" in info
and not self.ignore_etag
and not "if-none-match" in headers
... | def request(
return (response, content)
if entry_disposition == "STALE":
if "etag" in info and not self.ignore_etag and not "if-none-match" in headers:
headers["if-none-match"] = info["etag"]
if "las... |
def request(
pass
(response, new_content) = self._request(
conn,
authority,
uri,
request_uri,
method,
body,
... | def request(
pass
(response, new_content) = self._request(
conn, authority, uri, request_uri, method, body, headers, redirections, cachekey,
)
if response.status == 304 and method == "GET": |
def request(
merged_response = Response(info)
if hasattr(response, "_stale_digest"):
merged_response._stale_digest = response._stale_digest
_updateCache(
headers, merged_response, content, self.cache, cachekey
... | def request(
merged_response = Response(info)
if hasattr(response, "_stale_digest"):
merged_response._stale_digest = response._stale_digest
_updateCache(headers, merged_response, content, self.cache, cachekey)
respon... |
def request(
content = ""
else:
(response, content) = self._request(
conn,
authority,
uri,
request_uri,
method,
body,
... | def request(
content = ""
else:
(response, content) = self._request(
conn, authority, uri, request_uri, method, body, headers, redirections, cachekey,
)
except Exception as e:
is_timeout = isinstance(... |
def request(
response.reason = str(e)
elif is_timeout:
content = "Request Timeout"
response = Response(
{
"content-type": "text/plain",
"status": "408",
... | def request(
response.reason = str(e)
elif is_timeout:
content = "Request Timeout"
response = Response({"content-type": "text/plain", "status": "408", "content-length": len(content),})
response.reason = "Request Timeout"
... |
# TODO: remove this fallback and copypasted socksipy module upon py2/3 merge,
# idea is to have soft-dependency on any compatible module called socks
from . import socks
from .iri2uri import iri2uri
| # TODO: remove this fallback and copypasted socksipy module upon py2/3 merge,
# idea is to have soft-dependency on any compatible module called socks
from . import socks
from . import auth
from .error import *
from .iri2uri import iri2uri
|
def has_timeout(timeout):
RETRIES = 2
# All exceptions raised here derive from HttpLib2Error
class HttpLib2Error(Exception):
pass
# Some exceptions can be caught and optionally
# be turned back into responses.
class HttpLib2ErrorWithResponse(HttpLib2Error):
def __init__(self, desc, response, content):
... | def has_timeout(timeout):
RETRIES = 2
# Open Items:
# -----------
|
class ProxiesUnavailableError(HttpLib2Error):
from httplib2 import certs
CA_CERTS = certs.where()
# PROTOCOL_TLS is python 3.5.3+. PROTOCOL_SSLv23 is deprecated. | class ProxiesUnavailableError(HttpLib2Error):
from httplib2 import certs
CA_CERTS = certs.where()
# PROTOCOL_TLS is python 3.5.3+. PROTOCOL_SSLv23 is deprecated. |
class ProxiesUnavailableError(HttpLib2Error):
# > Selects the highest protocol version that both the client and server support.
# > Despite the name, this option can select “TLS” protocols as well as “SSL”.
# source: https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLS
DEFAULT_TLS_VERSION = getattr(ssl, "PROTO... | class ProxiesUnavailableError(HttpLib2Error):
# > Selects the highest protocol version that both the client and server support.
# > Despite the name, this option can select “TLS” protocols as well as “SSL”.
# source: https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLS
DEFAULT_TLS_VERSION = getattr(ssl, "PROTO... |
def safename(filename):
def _normalize_headers(headers):
return dict(
[
(
_convert_byte_str(key).lower(),
NORMALIZE_SPACE.sub(_convert_byte_str(value), " ").strip(),
)
for (key, value) in headers.items()
]
) | def safename(filename):
def _normalize_headers(headers):
return dict(
[
(_convert_byte_str(key).lower(), NORMALIZE_SPACE.sub(_convert_byte_str(value), " ").strip(),)
for (key, value) in headers.items()
]
) |
def _parse_cache_control(headers):
if "cache-control" in headers:
parts = headers["cache-control"].split(",")
parts_with_args = [
tuple([x.strip().lower() for x in part.split("=", 1)])
for part in parts
if -1 != part.find("=")
]
parts_wo_args = [
... | def _parse_cache_control(headers):
if "cache-control" in headers:
parts = headers["cache-control"].split(",")
parts_with_args = [
tuple([x.strip().lower() for x in part.split("=", 1)]) for part in parts if -1 != part.find("=")
]
parts_wo_args = [(name.strip().lower(), 1) ... |
def _parse_cache_control(headers):
# Set to true to turn on, useful for testing servers.
USE_WWW_AUTH_STRICT_PARSING = 0
# In regex below:
# [^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+ matches a "token" as defined by HTTP
# "(?:[^\0-\x08\x0A-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?" matches a "quoted-str... | def _parse_cache_control(headers):
# Set to true to turn on, useful for testing servers.
USE_WWW_AUTH_STRICT_PARSING = 0
def _entry_disposition(response_headers, request_headers):
"""Determine freshness from the Date, Expires and Cache-Control headers. |
def _entry_disposition(response_headers, request_headers):
cc = _parse_cache_control(request_headers)
cc_response = _parse_cache_control(response_headers)
if (
"pragma" in request_headers
and request_headers["pragma"].lower().find("no-cache") != -1
):
retval = "TRANSPARENT"
... | def _entry_disposition(response_headers, request_headers):
cc = _parse_cache_control(request_headers)
cc_response = _parse_cache_control(response_headers)
if "pragma" in request_headers and request_headers["pragma"].lower().find("no-cache") != -1:
retval = "TRANSPARENT"
if "cache-control" n... |
def _decompressContent(response, new_content):
except (IOError, zlib.error):
content = ""
raise FailedToDecompressContent(
_("Content purported to be compressed with %s but failed to decompress.")
% response.get("content-encoding"),
response,
content,
... | def _decompressContent(response, new_content):
except (IOError, zlib.error):
content = ""
raise FailedToDecompressContent(
_("Content purported to be compressed with %s but failed to decompress.") % response.get("content-encoding"),
response,
content,
) |
def _write_headers(self):
print(v.encode(maxlinelen=self._maxheaderlen), file=self._fp)
else:
# email.Header got lots of smarts, so use it.
headers = header.Header(
v, maxlinelen=self._maxheaderlen, charset="utf-8", header_name=h
... | def _write_headers(self):
print(v.encode(maxlinelen=self._maxheaderlen), file=self._fp)
else:
# email.Header got lots of smarts, so use it.
headers = header.Header(v, maxlinelen=self._maxheaderlen, charset="utf-8", header_name=h)
print(headers.... |
def _updateCache(request_headers, response_headers, content, cache, cachekey):
header_str = info.as_string()
header_str = re.sub("\r(?!\n)|(?<!\r)\n", "\r\n", header_str)
text = b"".join(
[status_header.encode("utf-8"), header_str.encode("utf-8"), content]
... | def _updateCache(request_headers, response_headers, content, cache, cachekey):
header_str = info.as_string()
header_str = re.sub("\r(?!\n)|(?<!\r)\n", "\r\n", header_str)
text = b"".join([status_header.encode("utf-8"), header_str.encode("utf-8"), content])
cache.set... |
def _wsse_username_token(cnonce, iso_now, password):
class Authentication(object):
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
self.path = path
self.host = host | def _wsse_username_token(cnonce, iso_now, password):
class Authentication(object):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
(scheme, authority, path, query, fragment) = parse_uri(request_uri)
self.path = path
self.host = host |
def __bool__(self):
class BasicAuthentication(Authentication):
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(
self, credentials, host, request_uri, headers, response, content, http
)
def request(self, me... | def __bool__(self):
class BasicAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
def request(self, method, request_uri, headers, content)... |
class DigestAuthentication(Authentication):
"""Only do qop='auth' and MD5, since that
is all Apache currently implements"""
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(
self, credentials, host, request_uri, ... | class DigestAuthentication(Authentication):
"""Only do qop='auth' and MD5, since that
is all Apache currently implements"""
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content,... |
def request(self, method, request_uri, headers, content, cnonce=None):
def response(self, response, content):
if "authentication-info" not in response:
challenge = _parse_www_authenticate(response, "www-authenticate").get(
"digest", {}
)
if "true" == chal... | def request(self, method, request_uri, headers, content, cnonce=None):
def response(self, response, content):
if "authentication-info" not in response:
challenge = auth._parse_www_authenticate(response, "www-authenticate").get("digest", {})
if "true" == challenge.get("stale"):
... |
class HmacDigestAuthentication(Authentication):
__author__ = "Thomas Broyer (t.broyer@ltgt.net)"
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(
self, credentials, host, request_uri, headers, response, content, ht... | class HmacDigestAuthentication(Authentication):
__author__ = "Thomas Broyer (t.broyer@ltgt.net)"
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
challenge = aut... |
def __init__(
self.challenge["pw-algorithm"] = self.challenge.get("pw-algorithm", "SHA-1")
if self.challenge["pw-algorithm"] not in ["SHA-1", "MD5"]:
raise UnimplementedHmacDigestAuthOptionError(
_(
"Unsupported value for pw-algorithm: %s."
... | def __init__(
self.challenge["pw-algorithm"] = self.challenge.get("pw-algorithm", "SHA-1")
if self.challenge["pw-algorithm"] not in ["SHA-1", "MD5"]:
raise UnimplementedHmacDigestAuthOptionError(
_("Unsupported value for pw-algorithm: %s." % self.challenge["pw-algorithm"])
... |
def __init__(
[
self.credentials[0],
":",
self.pwhashmod.new(
"".join([self.credentials[1], self.challenge["salt"]])
)
.hexdigest()
.lower(),
":",
self.challeng... | def __init__(
[
self.credentials[0],
":",
self.pwhashmod.new("".join([self.credentials[1], self.challenge["salt"]])).hexdigest().lower(),
":",
self.challenge["realm"],
] |
def request(self, method, request_uri, headers, content):
headers_val = "".join([headers[k] for k in keys])
created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
request_digest = "%s:%s:%s:%s:%s" % (
method,
request_uri,
cnonc... | def request(self, method, request_uri, headers, content):
headers_val = "".join([headers[k] for k in keys])
created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
request_digest = "%s:%s:%s:%s:%s" % (method, request_uri, cnonce, self.challenge["snonce"], headers_... |
def request(self, method, request_uri, headers, content):
)
def response(self, response, content):
challenge = _parse_www_authenticate(response, "www-authenticate").get(
"hmacdigest", {}
)
if challenge.get("reason") in ["integrity", "stale"]:
return True
... | def request(self, method, request_uri, headers, content):
)
def response(self, response, content):
challenge = auth._parse_www_authenticate(response, "www-authenticate").get("hmacdigest", {})
if challenge.get("reason") in ["integrity", "stale"]:
return True
return False |
class WsseAuthentication(Authentication):
challenge but instead requiring your client to telepathically know that
their endpoint is expecting WSSE profile="UsernameToken"."""
def __init__(
self, credentials, host, request_uri, headers, response, content, http
):
Authentication.__init__(... | class WsseAuthentication(Authentication):
challenge but instead requiring your client to telepathically know that
their endpoint is expecting WSSE profile="UsernameToken"."""
def __init__(self, credentials, host, request_uri, headers, response, content, http):
Authentication.__init__(self, credenti... |
def request(self, method, request_uri, headers, content):
iso_now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
password_digest = _wsse_username_token(cnonce, iso_now, self.credentials[1])
headers["X-WSSE"] = (
'UsernameToken Username="%s", PasswordD... | def request(self, method, request_uri, headers, content):
iso_now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
password_digest = _wsse_username_token(cnonce, iso_now, self.credentials[1])
headers["X-WSSE"] = ('UsernameToken Username="%s", PasswordDigest="%s", '... |
def __init__(
# elif request_uri.find("spreadsheets") > 0:
# service = "wise"
auth = dict(
Email=credentials[0],
Passwd=credentials[1],
service=service,
source=headers["user-agent"],
)
resp, content = self.http.request(
... | def __init__(
# elif request_uri.find("spreadsheets") > 0:
# service = "wise"
auth = dict(Email=credentials[0], Passwd=credentials[1], service=service, source=headers["user-agent"],)
resp, content = self.http.request(
"https://www.google.com/accounts/ClientLogin",
... |
class FileCache(object):
be running on the same cache.
"""
def __init__(
self, cache, safe=safename
): # use safe=lambda x: md5.new(x).hexdigest() for the old behavior
self.cache = cache
self.safe = safe
if not os.path.exists(cache): | class FileCache(object):
be running on the same cache.
"""
def __init__(self, cache, safe=safename): # use safe=lambda x: md5.new(x).hexdigest() for the old behavior
self.cache = cache
self.safe = safe
if not os.path.exists(cache): |
def iter(self, domain):
class KeyCerts(Credentials):
"""Identical to Credentials except that
name/password are mapped to key/cert."""
def add(self, key, cert, domain, password):
self.credentials.append((domain.lower(), key, cert, password))
| def iter(self, domain):
class KeyCerts(Credentials):
"""Identical to Credentials except that
name/password are mapped to key/cert."""
def add(self, key, cert, domain, password):
self.credentials.append((domain.lower(), key, cert, password))
|
class ProxyInfo(object):
bypass_hosts = ()
def __init__(
self,
proxy_type,
proxy_host,
proxy_port,
proxy_rdns=True,
proxy_user=None,
proxy_pass=None,
proxy_headers=None,
):
"""Args:
| class ProxyInfo(object):
bypass_hosts = ()
def __init__(
self, proxy_type, proxy_host, proxy_port, proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None,
):
"""Args:
|
def __init__(
proxy_user = proxy_user.decode()
if isinstance(proxy_pass, bytes):
proxy_pass = proxy_pass.decode()
self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass, self.proxy_headers = (
proxy_type,
proxy... | def __init__(
proxy_user = proxy_user.decode()
if isinstance(proxy_pass, bytes):
proxy_pass = proxy_pass.decode()
(
self.proxy_type,
self.proxy_host,
self.proxy_port,
self.proxy_rdns,
self.proxy_user,
self.pr... |
def __init__(self, host, port=None, timeout=None, proxy_info=None):
def connect(self):
"""Connect to the host and port specified in __init__."""
if self.proxy_info and socks is None:
raise ProxiesUnavailableError(
"Proxy support missing but proxy use was requested!"
... | def __init__(self, host, port=None, timeout=None, proxy_info=None):
def connect(self):
"""Connect to the host and port specified in __init__."""
if self.proxy_info and socks is None:
raise ProxiesUnavailableError("Proxy support missing but proxy use was requested!")
if self.proxy... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.