Changeset - b491f9fa59bd
[Not reviewed]
default
0 3 0
Dennis Fink - 11 years ago 2014-01-23 11:07:03
dennis.fink@c3l.lu
added encoding parameter to open
3 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
ennstatus/api/functions.py
Show inline comments
 
@@ -84,12 +84,13 @@ def update_server(server, ip):
 
            del server['obfs']
 

	
 
        server['ip'] = ip
 

	
 
    try:
 
        filename = ''.join(['data/', server['server_name'].lower(), '.json'])
 
        with open(filename, 'w') as fb:
 

	
 
        with open(filename, 'w', encoding='utf-8') as fb:
 
            json.dump(server, fb)
 

	
 
        return server
 
    except Exception as e:
 
        return e
ennstatus/donate/functions.py
Show inline comments
 
@@ -5,13 +5,13 @@ import csv
 

	
 
def load_csv(date):
 

	
 
    filename = '.'.join([date, 'csv'])
 
    path = os.path.join('donations', filename)
 

	
 
    with open(path) as csvfile:
 
    with open(path, encoding='utf-8', newline='') as csvfile:
 
        csvreader = csv.reader(csvfile, delimiter=',')
 

	
 
        for row in csvreader:
 
            yield row
 

	
 

	
ennstatus/status/functions.py
Show inline comments
 
@@ -6,13 +6,13 @@ from collections import defaultdict
 
from datetime import datetime
 

	
 
def _load_single_server(name):
 

	
 
    filename = ''.join(['data/', name, '.json'])
 
    try:
 
        with open(filename) as f:
 
        with open(filename, encoding='utf-8') as f:
 
            return ''.join(f.readlines())
 
    except IOError:
 
        return False
 

	
 

	
 
def _check_server(data):
 
@@ -63,13 +63,13 @@ def _get_json_files(root, files):
 

	
 

	
 
def all_servers():
 

	
 
    for root, _, files in os.walk('data'):
 
        for f in _get_json_files(root, files):
 
            with open(f) as fb:
 
            with open(f, encoding='utf-8') as fb:
 
                try:
 
                    server = json.load(fb)
 
                except ValueError:
 
                    fb.close()
 
                    continue
 
            server = _check_server(server)
0 comments (0 inline, 0 general)