Changeset - 6632069b797d
[Not reviewed]
default
0 1 0
Dennis Fink - 11 years ago 2014-01-21 19:00:40
dennis.fink@c3l.lu
updated check_server.py
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
Scripts/check_servers.py
Show inline comments
 
@@ -26,28 +26,29 @@ def check_all_servers():
 
                data = json.load(file_object)
 

	
 
            with open(f, mode='w', encoding='utf-8') as file_object:
 

	
 
                date = datetime.strptime(data['last_updated'],
 
                                         DATE_FORMAT)
 
                now = datetime.utcnow()
 

	
 
                delta = now - date
 

	
 
                if delta.seconds >= 3600:
 
                    status = 'Offline'
 
                elif delta.second >= 1200:
 
                elif delta.seconds >= 1200:
 
                    status = 'Unkown'
 
                else:
 
                    status = None
 

	
 
                if status:
 
                    for key in ('server_status', 'tor_status'):
 
                        data[key] = status
 

	
 
                json.dump(data, file_object)
 
        except:
 
        except Exception as e:
 
            print(e)
 
            continue
 

	
 

	
 
if __name__ == '__main__':
 
    check_all_servers()
0 comments (0 inline, 0 general)