]> git.ipfire.org Git - people/shoehn/ipfire.org.git/commitdiff
Fix enconding of json data.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Jan 2010 19:35:19 +0000 (20:35 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Jan 2010 19:35:19 +0000 (20:35 +0100)
www/webapp/banners.py
www/webapp/helpers.py
www/webapp/info.py
www/webapp/mirrors.py
www/webapp/news.py
www/webapp/releases.py

index 0ad56e5af3923dbc7b3483f2d8f69397af4c21c7..ba21ab99de59bbcb9587b78887fc6cfaa786ba27 100644 (file)
@@ -1,9 +1,8 @@
 #!/usr/bin/python
 
 import random
-import simplejson
 
-from helpers import Item, _stringify
+from helpers import Item, _stringify, json_loads
 
 class Banners(object):
        def __init__(self, filename=None):
@@ -17,7 +16,7 @@ class Banners(object):
                data = f.read()
                f.close()
                
-               for item in simplejson.loads(data):
+               for item in json_loads(data):
                        self.items.append(Item(**_stringify(item)))
 
        def get(self):
index 62717cc4261f6cafd98bf54a9f6754cff12624d9..d634fcb99c66b45d71686d5c99af8e9abad904fa 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+import simplejson
 import subprocess
 
 class Item(object):
@@ -15,7 +16,6 @@ class Item(object):
        def __setitem__(self, key, val):
                self.args[key] = val
 
-
 def size(s):
        suffixes = ["B", "K", "M", "G", "T",]
        
@@ -25,7 +25,10 @@ def size(s):
                idx += 1
 
        return "%.0f%s" % (s, suffixes[idx])
-       
+
+def json_loads(s):
+       return simplejson.loads(s.decode("utf-8"))
+
 def _stringify(d):
        ret = {}
        for key in d.keys():
index 18754fa8448659b992656295244526aaf8fe8d93..3ea75b0cbcc2d065e86b45304fa35e4876289c2d 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import simplejson
+from helpers import json_loads
 
 class Info(dict):
        def __init__(self, filename):
@@ -8,7 +8,7 @@ class Info(dict):
                
        def load(self, filename):
                f = open(filename)
-               for key, val in simplejson.loads(f.read()).items():
+               for key, val in json_loads(f.read()).items():
                        self[key] = val
                f.close()
 
index 58ba28c891d0ccd946d9c5d2396c748ddced00c0..df19627bc484d754b6f27f1721a968b0275bfa43 100644 (file)
@@ -3,11 +3,10 @@
 import tornado.httpclient
 
 import random
-import simplejson
 import threading
 import time
 
-from helpers import Item, _stringify, ping
+from helpers import Item, _stringify, ping, json_loads
 
 class Mirrors(threading.Thread):
        def __init__(self, filename):
@@ -25,7 +24,7 @@ class Mirrors(threading.Thread):
                data = f.read()
                f.close()
                
-               for item in simplejson.loads(data):
+               for item in json_loads(data):
                        self.items.append(MirrorItem(**_stringify(item)))
 
        @property
index d99d2ed88a8663438b99258c584b4587e3434042..9d170db6835a7b29d06e80f2e4aa75442ca81f28 100644 (file)
@@ -1,8 +1,6 @@
 #!/usr/bin/python
 
-import simplejson
-
-from .helpers import Item, _stringify
+from helpers import Item, _stringify, json_loads
 
 class News(object):
        def __init__(self, filename=None):
@@ -18,7 +16,7 @@ class News(object):
 
                data = data.replace("\n", "").replace("\t", " ")
 
-               json = simplejson.loads(data)
+               json = json_loads(data)
                for key in sorted(json.keys()):
                        self.items.append(NewsItem(**_stringify(json[key])))
 
index 5365ccffff47631aa4237a3dcf35f7cebb63d875..12a4ecfb209d285918715172928af1a4bf30638b 100644 (file)
@@ -1,8 +1,6 @@
 #!/usr/bin/python
 
-import simplejson
-
-from helpers import Item, _stringify
+from helpers import Item, _stringify, json_loads
 
 class ReleaseItem(Item):
        options = {
@@ -111,7 +109,7 @@ class Releases(object):
                data = f.read()
                f.close()
                
-               for item in simplejson.loads(data):
+               for item in json_loads(data):
                        self.items.append(ReleaseItem(**_stringify(item)))
 
        @property