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()
|
self.reset_cache()
|
||||||
|
|
||||||
def reset_cache(self):
|
def reset_cache(self):
|
||||||
|
'''Reset cached password'''
|
||||||
self.cache = {
|
self.cache = {
|
||||||
"last_update": -1,
|
"last_update": -1,
|
||||||
"cached_passwords": []
|
"cached_passwords": []
|
||||||
}
|
}
|
||||||
|
|
||||||
def _write_cache(self):
|
def _write_cache(self):
|
||||||
self.debug(
|
self.debug(
|
||||||
{
|
{
|
||||||
|
@ -353,9 +355,27 @@ class NextcloudHandler:
|
||||||
else:
|
else:
|
||||||
out_obj = self._safer_obj(obj)
|
out_obj = self._safer_obj(obj)
|
||||||
if self.output_format == 'json':
|
if self.output_format == 'json':
|
||||||
|
try:
|
||||||
return json.dumps(out_obj, indent=2)
|
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':
|
if self.output_format == 'yaml':
|
||||||
|
try:
|
||||||
return dump(out_obj, Dumper=Dumper)
|
return dump(out_obj, Dumper=Dumper)
|
||||||
|
except Exception as error:
|
||||||
|
self.error(
|
||||||
|
{
|
||||||
|
'action': '_outpout',
|
||||||
|
'message': 'Error decoding YAML',
|
||||||
|
'error': error,
|
||||||
|
}
|
||||||
|
)
|
||||||
output = ''
|
output = ''
|
||||||
if isinstance(out_obj, list):
|
if isinstance(out_obj, list):
|
||||||
output += '-' * os.get_terminal_size(0)[0]
|
output += '-' * os.get_terminal_size(0)[0]
|
||||||
|
@ -916,8 +936,7 @@ class NextcloudHandler:
|
||||||
else:
|
else:
|
||||||
self.cache['cached_passwords'] = [ new_obj ]
|
self.cache['cached_passwords'] = [ new_obj ]
|
||||||
return r.json()
|
return r.json()
|
||||||
self.error(r.content)
|
self.error(r.json())
|
||||||
self.error(r.headers)
|
|
||||||
self.error(
|
self.error(
|
||||||
{
|
{
|
||||||
"action": "create_password",
|
"action": "create_password",
|
||||||
|
|
Loading…
Reference in a new issue