Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Henjuro committed Nov 12, 2017
2 parents 850f3ce + f267ec3 commit 4b01c5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 81 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#Changelog
* 1.1.1
* Fixes
* Removed some unneeded code
* Removed fix for wrong / in ESI underscore routes
* 1.1.0
* Changes
* Taking over a fleet now detects the fleet you are in (using new ESI route)
Expand Down
2 changes: 1 addition & 1 deletion waitlist/data/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.1.0-$Format:%h$"
version = "1.1.1-$Format:%h$"
81 changes: 1 addition & 80 deletions waitlist/utility/swagger/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,82 +15,6 @@

logger = logging.getLogger(__name__)

'''
Most of this code is the code from pyswagger.contrib.client.requests
only **kwargs was added
This client is to patch the pyswagger client
'''


class PatchClient(BaseClient):
""" Client implementation based on requests
"""

__schemes__ = {'http', 'https'}

def __init__(self, auth=None, send_opt=None, **kwargs):
""" constructor
:param auth pyswagger.SwaggerAuth: auth info used when requesting
:param send_opt dict: options used in requests.send, ex verify=False
"""
super(PatchClient, self).__init__(auth)
if send_opt is None:
send_opt = {}

self.timeout = kwargs.pop('timeout', 10)

self.__s = Session()
self.__send_opt = send_opt

def request(self, req_and_resp, opt=None, headers=None):
"""
"""
if opt is None:
opt = {}

req, resp = super(PatchClient, self).request(req_and_resp, opt)

# apply request-related options before preparation.
req.prepare(scheme=self.prepare_schemes(req), handle_files=False)
req._patch(opt)

# prepare for uploaded files
file_obj = []

def append(name, obj):
f = obj.data or open(obj.filename, 'rb')
if 'Content-Type' in obj.header:
file_obj.append((name, (obj.filename, f, obj.header['Content-Type'])))
else:
file_obj.append((name, (obj.filename, f)))

for k, v in six.iteritems(req.files):
if isinstance(v, list):
for vv in v:
append(k, vv)
else:
append(k, v)

rq = Request(
method=req.method.upper(),
url=req.url,
params=req.query,
data=req.data,
headers=req.header,
files=file_obj
)
rq = self.__s.prepare_request(rq)
rs = self.__s.send(rq, stream=True, timeout=self.timeout, **self.__send_opt)

resp.apply_with(
status=rs.status_code,
header=rs.headers,
raw=six.BytesIO(rs.content).getvalue()
)

return resp


class EsiClient(BaseClient):

Expand Down Expand Up @@ -188,8 +112,7 @@ def request(self, req_and_resp, raw_body_only=None, opt=None):
prepared_request = self._session.prepare_request(
Request(
method=request.method.upper(),
# lets patch the double / after ccp.is out since apparently esi servers hang up on that
url=request.url.replace("//esi.tech.ccp.is//", "//esi.tech.ccp.is/"),
url=request,
params=request.query,
data=request.data,
headers=request.header
Expand Down Expand Up @@ -275,7 +198,5 @@ def __make_cache_key(cls, request):


def monkey_patch_pyswagger_requests_client():
import pyswagger.contrib.client.requests
pyswagger.contrib.client.requests.Client = PatchClient
import esipy
esipy.EsiClient = EsiClient

0 comments on commit 4b01c5f

Please sign in to comment.