Check decoding output
This commit is contained in:
parent
3cbe9b0530
commit
c0cd9feebf
1 changed files with 23 additions and 4 deletions
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue