From 645a5ced14f24d529863814fee53f6f0394a3820 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sun, 6 May 2018 12:57:48 -0400 Subject: [PATCH] check response for a 200 --- service/esi.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/service/esi.py b/service/esi.py index add64537b..c2fe03b47 100644 --- a/service/esi.py +++ b/service/esi.py @@ -134,19 +134,19 @@ class Esi(object): def getSkills(self, id): char = self.getSsoCharacter(id) op = Esi.esi_v4.op['get_characters_character_id_skills'](character_id=char.characterID) - resp = char.esi_client.request(op) + resp = self.check_response(char.esi_client.request(op)) return resp.data def getSecStatus(self, id): char = self.getSsoCharacter(id) op = Esi.esi_v4.op['get_characters_character_id'](character_id=char.characterID) - resp = char.esi_client.request(op) + resp = self.check_response(char.esi_client.request(op)) return resp.data def getFittings(self, id): char = self.getSsoCharacter(id) op = Esi.esi_v1.op['get_characters_character_id_fittings'](character_id=char.characterID) - resp = char.esi_client.request(op) + resp = self.check_response(char.esi_client.request(op)) return resp.data def postFitting(self, id, json_str): @@ -156,7 +156,7 @@ class Esi(object): character_id=char.characterID, fitting=json.loads(json_str) ) - resp = char.esi_client.request(op) + resp = self.check_response(char.esi_client.request(op)) return resp.data def delFitting(self, id, fittingID): @@ -165,9 +165,14 @@ class Esi(object): character_id=char.characterID, fitting_id=fittingID ) - resp = char.esi_client.request(op) + resp = self.check_response(char.esi_client.request(op)) return resp.data + def check_response(self, resp): + if resp.status != 200: + raise Exception(resp.status) + return resp + @staticmethod def get_sso_data(char): """ Little "helper" function to get formated data for esipy security