Changeset - fd0f9336d6d8
[Not reviewed]
default
0 2 0
Dennis Fink - 11 years ago 2014-07-15 23:16:16
dennis.fink@c3l.lu
Breaking API change. obfs and fteproxy need to be booleans not string
2 files changed with 9 insertions and 16 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.py
Show inline comments
 
@@ -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):
ennstatus/api/functions.py
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)