Browse Source

read ALFRED+BATMAN data as Unicode

Helge Jung 9 years ago
parent
commit
a9819ef438
2 changed files with 8 additions and 1 deletions
  1. 6 0
      ffstatus/alfred.py
  2. 2 1
      ffstatus/batman.py

+ 6 - 0
ffstatus/alfred.py

@@ -51,8 +51,14 @@ class AlfredParser:
 
         alfreddata = {}
         for datatype in self.alfred_datatypes:
+            # call 'alfred-json' and fetch the output
             cmd = [self.alfred_json, '-z', '-r', str(int(datatype[1]))]
             rawdata = subprocess.check_output(cmd)
+
+            # convert raw input into unicode
+            rawdata = unicode(rawdata, encoding='latin1', errors='replace')
+
+            # parse it as JSON
             newdata = json.loads(rawdata)
 
             for item in newdata:

+ 2 - 1
ffstatus/batman.py

@@ -44,8 +44,9 @@ class BatmanParser:
         data = {}
         timestamp = int(time.time())
 
-        # call batadv-vis and parse output as JSON
+        # call batadv-vis and parse output as unicode JSON
         rawdata = subprocess.check_output([self.batadv_vis, '-f', 'jsondoc'])
+        rawdata = unicode(rawdata, encoding='latin1', errors='replace')
         batmandata = json.loads(rawdata)
 
         # dump raw data into file if requested