Browse Source

handle errors when trying to get instance jsonld schema

Signed-off-by: R4SAS <r4sas@i2pmail.org>
master
R4SAS 1 year ago
parent
commit
3f30828e1a
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 19
      pbincli/api.py

19
pbincli/api.py

@ -81,14 +81,19 @@ class PrivateBin: @@ -81,14 +81,19 @@ class PrivateBin:
def getVersion(self):
jsonldSchema = self.session.get(
result = self.session.get(
url = self.server + '?jsonld=paste',
headers = self.headers).json()
return jsonldSchema['@context']['v']['@value'] \
if ('@context' in jsonldSchema and
'v' in jsonldSchema['@context'] and
'@value' in jsonldSchema['@context']['v']) \
else 1
headers = self.headers)
try:
jsonldSchema = result.json()
return jsonldSchema['@context']['v']['@value'] \
if ('@context' in jsonldSchema and
'v' in jsonldSchema['@context'] and
'@value' in jsonldSchema['@context']['v']) \
else 1
except ValueError:
PBinCLIError("Unable parse response as json. Received (size = {}):\n{}".format(len(result.text), result.text))
def getServer(self):
return self.server

Loading…
Cancel
Save