# HG changeset patch # User Dennis Fink # Date 2016-03-02 20:01:22 # Node ID 47d07b5cb8db51357db4b3560b2746252e2b3068 # Parent 9e4fba8ebb3bb34b16e08fc33e3eb03ea57e8d77 Added flags diff --git a/ennstatus/api/model.py b/ennstatus/api/model.py --- a/ennstatus/api/model.py +++ b/ennstatus/api/model.py @@ -120,6 +120,7 @@ class Server: self.last_updated = kwargs['last_updated'] self.country = kwargs['country'] self.bandwidth = kwargs.get('bandwidth') + self.flags = kwargs.get('flags') if self.type == 'bridge': self.obfs = kwargs.get('obfs') @@ -247,6 +248,15 @@ class Server: data.consensus_weight_fraction ) + def update_flags(self): + + try: + data = manager.query('details', lookup=self.fingerprint) + except: + raise NotImplementedError + + self.flags = data.relays[0].flags + def check_status(self): now = datetime.utcnow() diff --git a/ennstatus/api/schema/server.json b/ennstatus/api/schema/server.json --- a/ennstatus/api/schema/server.json +++ b/ennstatus/api/schema/server.json @@ -100,6 +100,11 @@ }, "type": { "type": "string" + }, + "flags": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true } }, "required": [ diff --git a/ennstatus/api/views.py b/ennstatus/api/views.py --- a/ennstatus/api/views.py +++ b/ennstatus/api/views.py @@ -121,6 +121,11 @@ def update(): pass try: + server.update_flags() + except NotImplementedError: + pass + + try: server.save() except Exception as e: current_app.logger.error(str(e))