Ver código fonte

Adding handling of empty data in extractJSON

Andrej 1 mês atrás
pai
commit
76eab91cb9
2 arquivos alterados com 4 adições e 0 exclusões
  1. 2 0
      orthancDatabaseBrowser.py
  2. 2 0
      orthancQR.py

+ 2 - 0
orthancDatabaseBrowser.py

@@ -5,6 +5,8 @@ import io
 import sys
 
 def extractJSON(data):
+   if len(data)==0:
+      return {}
    encoding=chardet.detect(data)["encoding"]
    #try with a set of encodings to maximize probability of success
    encodings=[encoding,'utf_8']

+ 2 - 0
orthancQR.py

@@ -25,6 +25,8 @@ class orthancQR:
       v={}
       response=self.net.get(apiURL)
       #OK if empty,JSON if fail
+      if len(response.data)==0:
+         return {}
       return orthancDatabaseBrowser.extractJSON(response.data)
 
    def sendCFind(self,name,query):