Compare commits
No commits in common. "fbf4fc96436c54fbf102e2bf1caca32fd6cd2133" and "24ea05b64a389361ecae91074d882f363660ba1b" have entirely different histories.
fbf4fc9643
...
24ea05b64a
|
@ -4,7 +4,7 @@
|
|||
from sys import exit, argv
|
||||
from json import dumps
|
||||
from traceback import print_exc
|
||||
from cucchiaiata import Parser, config, Configuration, JsonError
|
||||
from cucchiaiata import Parser, config, Configuration
|
||||
from cucchiaiata.i18n import _
|
||||
|
||||
|
||||
|
@ -15,15 +15,9 @@ def main():
|
|||
else:
|
||||
parser = Parser()
|
||||
print(dumps(parser.get(),
|
||||
indent=config.indent),
|
||||
)
|
||||
indent=config.indent))
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except JsonError as err:
|
||||
print(dumps(err.message,
|
||||
indent=config.indent),
|
||||
)
|
||||
exit(1)
|
||||
except Exception as err:
|
||||
if config.debug:
|
||||
print_exc()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from .parser import Parser
|
||||
from .configuration import Configuration
|
||||
from .config import config
|
||||
from .common import JsonError
|
||||
|
||||
__all__ = ('Parser', 'config', 'Configuration', 'JsonError')
|
||||
__all__ = ('Parser', 'config')
|
||||
__version__ = "0.0.1"
|
||||
|
|
|
@ -13,10 +13,6 @@ if config.allow_insecure_https:
|
|||
warnings.simplefilter('ignore', InsecureRequestWarning)
|
||||
|
||||
|
||||
class JsonError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Common:
|
||||
def __init__(self):
|
||||
self.cucchiaiata_config = config
|
||||
|
@ -101,12 +97,11 @@ def send_data(uri: str,
|
|||
ret = post(final_url,
|
||||
data=dumps(payload),
|
||||
verify=config.allow_insecure_https)
|
||||
try:
|
||||
response = ret.json()
|
||||
except:
|
||||
if ret.status_code != 200:
|
||||
raise Exception(ret.text)
|
||||
if response['type'] == 'error':
|
||||
err = JsonError()
|
||||
err.message = response['response']
|
||||
raise err
|
||||
response = ret.json()
|
||||
if 'error' in response:
|
||||
if 'reason' in response['error']['kwargs']:
|
||||
raise Exception("{}".format(response['error']['kwargs']['reason']))
|
||||
raise Exception('erreur inconnue')
|
||||
return response['response']
|
||||
|
|
Loading…
Reference in New Issue