Check decoding output

This commit is contained in:
Antonio J. Delgado 2024-12-19 17:03:25 +02:00
parent 3cbe9b0530
commit c0cd9feebf

View file

@ -314,10 +314,12 @@ class NextcloudHandler:
self.reset_cache()
def reset_cache(self):
'''Reset cached password'''
self.cache = {
"last_update": -1,
"cached_passwords": []
}
def _write_cache(self):
self.debug(
{
@ -353,9 +355,27 @@ class NextcloudHandler:
else:
out_obj = self._safer_obj(obj)
if self.output_format == 'json':
try:
return json.dumps(out_obj, indent=2)
except json.decoder.JSONDecodeError as error:
self.error(
{
'action': '_outpout',
'message': 'Error decoding JSON',
'error': error,
}
)
if self.output_format == 'yaml':
try:
return dump(out_obj, Dumper=Dumper)
except Exception as error:
self.error(
{
'action': '_outpout',
'message': 'Error decoding YAML',
'error': error,
}
)
output = ''
if isinstance(out_obj, list):
output += '-' * os.get_terminal_size(0)[0]
@ -916,8 +936,7 @@ class NextcloudHandler:
else:
self.cache['cached_passwords'] = [ new_obj ]
return r.json()
self.error(r.content)
self.error(r.headers)
self.error(r.json())
self.error(
{
"action": "create_password",