# HG changeset patch # User Dennis Fink # Date 2014-07-15 23:16:16 # Node ID fd0f9336d6d8c2c48cefceac55c144c8fcf62941 # Parent 0203fb9c743131a869790372ca5f34823126fb71 Breaking API change. obfs and fteproxy need to be booleans not string diff --git a/Scripts/update_server.py b/Scripts/update_server.py --- a/Scripts/update_server.py +++ b/Scripts/update_server.py @@ -63,18 +63,12 @@ def get_server_type(tor_config): def get_obfs_proxy(tor_config): - if any(OBFS_REGEX.match(i) for i in tor_config): - return 'True' - else: - return 'False' + return any(OBFS_REGEX.match(i) for i in tor_config) def get_fte_proxy(tor_config): - if any(FTEPROXY_REGEX.match(i) for i in tor_config): - return 'True' - else: - return 'False' + return any(FTEPROXY_REGEX.match(i) for i in tor_config) def get_ip(tor_config): diff --git a/ennstatus/api/functions.py b/ennstatus/api/functions.py --- a/ennstatus/api/functions.py +++ b/ennstatus/api/functions.py @@ -3,7 +3,6 @@ import re import json from datetime import datetime -from ast import literal_eval import pygeoip @@ -28,10 +27,10 @@ def check_bridge(key, server): if key not in server: raise ValueError('%s key not present!\n' % key) else: - if server[key] not in ('True', 'False'): - error_message = ('%s has not the right content!' - ' is: %s must be one of: True or False\n') \ - % (key, server[key]) + if not isinstance(server[key], bool): + error_message = ('%s has not the right type!' + ' Needs to be a boolean!\n') \ + % key raise ValueError(error_message) @@ -75,15 +74,15 @@ def update_server(server, ip): server['country'] = gi4.country_name_by_addr(ip) if server['server_type'] == 'Bridge': - server['obfs'] = literal_eval(server['obfs']) - server['fteproxy'] = literal_eval(server['fteproxy']) - if 'ip' in server: del server['ip'] else: if 'obfs' in server: del server['obfs'] + if 'fteproxy' in server: + del server['fteproxy'] + server['ip'] = ip try: