travis: fix style

This commit is contained in:
Oleksii Shevchuk 2019-05-25 07:59:45 +03:00
parent a35bd8f2ec
commit 211892aebf
4 changed files with 34 additions and 24 deletions

View File

@ -98,16 +98,15 @@ class http(PupyModule):
self.log(result)
except Exception, e:
raise
if hasattr(e, 'reason'):
message = '{} {} ({})'.format(e.code, e.reason, e.filename)
if e.code / 100 < 4:
self.warning(message)
else:
self.error(message)
return
elif hasattr(e, 'msg'):
message = e.msg
else:

View File

@ -3,6 +3,8 @@
from pupylib.PupyModule import config, PupyModule, PupyArgumentParser
from pupylib.PupyOutput import Table
@config(cat='creds')
class NetCreds(PupyModule):
''' Manage saved authentication information '''

View File

@ -112,32 +112,41 @@ class ProxyError(IOError):
def __str__(self):
return self.msg
class GeneralProxyError(ProxyError):
pass
class ProxyConnectionError(ProxyError):
pass
class SOCKS5AuthError(ProxyError):
pass
class SOCKS5Error(ProxyError):
pass
class SOCKS4Error(ProxyError):
pass
class HTTPError(ProxyError):
pass
class AuthenticationRequired(ProxyError):
__slots__ = ('methods',)
def __init__(self, methods):
super(AuthenticationRequired, self).__init__(
'Authentication required, supported methods: {}'.format(
';'.join(methods)))
self.methods = methods
class AuthenticationImpossible(EOFError):
pass
@ -1131,7 +1140,7 @@ class socksocket(_BaseSocket):
try:
self._connect(self, dest_pair)
break
except AuthenticationRequired as e:
except AuthenticationRequired:
_orig_socket.__init__(
self, *self._orig_args, **self._orig_kwargs)

View File

@ -95,7 +95,7 @@ class ProxyPasswordManager(object):
class HTTPContext(urllib2.BaseHandler):
default = None
__slots__ = ('cookies', 'headers')
handler_order = 999
@ -106,11 +106,11 @@ class HTTPContext(urllib2.BaseHandler):
HTTPContext.default = HTTPContext()
return HTTPContext.default
def __init__(self):
self.cookies = cookielib.CookieJar()
self.headers = {}
def http_request(self, request):
self.cookies.add_cookie_header(request)
host = request.get_host()
@ -123,7 +123,7 @@ class HTTPContext(urllib2.BaseHandler):
def http_response(self, request, response):
self.cookies.extract_cookies(response, request)
host = request.get_host()
headers = request.headers
code = response.headers
@ -150,12 +150,12 @@ class HTTPContext(urllib2.BaseHandler):
if host not in self.headers:
self.headers[host] = {}
self.headers[host][header] = request.get_headers(header)
self.headers[host][header] = headers.get(header)
https_request = http_request
https_response = http_response
https_response = http_response
class NoRedirects(urllib2.HTTPErrorProcessor):
__slots__ = ()
@ -532,7 +532,7 @@ class HTTP(object):
password_managers.append(http_password_manager)
context = HTTPContext.get_default()
handlers.append(context)
handlers.append(urllib2.HTTPDefaultErrorHandler)
@ -561,10 +561,10 @@ class HTTP(object):
opener, scheme, host, password_managers, context = self.make_opener(url)
result = []
try:
response = opener.open(url, timeout=self.timeout)
except ProxyConnectionError as e:
if self.proxy == 'wpad':
set_proxy_unavailable(scheme, host)
@ -573,21 +573,21 @@ class HTTP(object):
except urllib2.HTTPError as e:
context.update_from_error(e)
if not return_headers:
raise
result = [e.fp.read() if e.fp.read else '']
if return_url:
result.append(e.url)
if code:
result.append(e.code)
if return_headers:
result.append(e.hdrs.dict)
if len(result) == 1:
return result[0]
else:
@ -668,16 +668,16 @@ class HTTP(object):
raise
result = [e.fp.read() if e.fp.read else '']
if return_url:
result.append(e.url)
if code:
result.append(e.code)
if return_headers:
result.append(e.hdrs.dict)
if len(result) == 1:
return result[0]
else: