# HG changeset patch # User Dennis Fink # Date 2013-11-17 00:15:22 # Node ID de6292f200dc90faaff2b16ff33b0053c52491ca # Parent dc9fa1a9e86436caec311a38c402f60d884ace13 updated script diff --git a/Scripts/update_server.py b/Scripts/update_server.py --- a/Scripts/update_server.py +++ b/Scripts/update_server.py @@ -28,7 +28,7 @@ def get_tor_status(name='tor'): pids = subprocess.check_output(['pidof', 'tor']).decode('utf-8') pids = pids.split(' ') pid_file = '.'.join([name, 'pid']) - pid = open('/'.join(['var', 'run', name, pid_file])).readline() + pid = open('/'.join(['/var', 'run', name, pid_file])).readline() if pid in pids: return "Online" @@ -40,7 +40,7 @@ def get_tor_status(name='tor'): def get_tor_fingerprint(name='tor'): - fingerprint_file = '/'.join(['var', 'lib', name, 'fingerprint']) + fingerprint_file = '/'.join(['/var', 'lib', name, 'fingerprint']) with open(fingerprint_file) as fb: line = fb.readline()[:-1] @@ -101,13 +101,14 @@ def create_server_json(tor_configfile='/ if server_type != 'Bridge': dictionary['fingerprint'] = fingerprint - return json.dumps(dictionary) + return dictionary def update_server(server_json, url): - response = requests.post(url + '/api/update', data=server_json) - + response = requests.post(url + '/api/update', data=json.dumps(server_json)) + print(response.text) + print(server_json) response.raise_for_status() return response.text @@ -127,11 +128,10 @@ def main(): else: server_json = create_server_json() response = update_server(server_json, ennstatus_url) + print(response) except Exception as e: print('Error: %s' % str(e)) - print(response) - if __name__ == '__main__': main()