Changeset - 2d83b2f6b3fb
[Not reviewed]
default
0 1 0
Dennis Fink - 11 years ago 2013-11-17 00:04:07
dennis.fink@c3l.lu
updated script
1 file changed with 13 insertions and 8 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.py
Show inline comments
 
@@ -7,7 +7,7 @@ import requests
 

	
 
from ast import literal_eval
 

	
 
OBFS_REGEX = re.compule(r'^ServerTransportPlugin obfs2,obfs3')
 
OBFS_REGEX = re.compile(r'^ServerTransportPlugin obfs2,obfs3')
 

	
 
IP_REGEX = re.compile((r'^(OutboundBindAddress)'
 
                       r' (\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3})'))
 
@@ -108,6 +108,8 @@ def update_server(server_json, url):
 

	
 
    response = requests.post(url + '/api/update', data=server_json)
 

	
 
    response.raise_for_status()
 

	
 
    return response.text
 

	
 

	
 
@@ -116,13 +118,16 @@ def main():
 
    config = get_config()
 
    ennstatus_url = config['main']['ennstatus_url']
 

	
 
    if 'servers' in config['main']:
 
        for server in literal_eval(config['main']['servers']):
 
            server_json = create_server_json(config[server]['configfile'],
 
                                             server)
 
    try:
 
        if 'servers' in config['main']:
 
            for server in literal_eval(config['main']['servers']):
 
                server_json = create_server_json(config[server]['configfile'],
 
                                                 server)
 
                response = update_server(server_json, ennstatus_url)
 
        else:
 
            server_json = create_server_json()
 
            response = update_server(server_json, ennstatus_url)
 
    else:
 
        server_json = create_server_json()
 
        response = update_server(server_json, ennstatus_url)
 
    except Exception as e:
 
        print('Error: %s' % str(e))
 

	
 
    print(response)
0 comments (0 inline, 0 general)