From 5892e7438073109b4bf624a0dca7e67677ab7fe5 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 11 May 2016 19:56:32 +0000 Subject: [PATCH] Send report just before reboot --- client/client.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/client/client.py b/client/client.py index 60cd2b9..eb53bfb 100755 --- a/client/client.py +++ b/client/client.py @@ -68,19 +68,22 @@ class Client(threadedclient.WebSocketClient): self.connect() self._OnNewManifest2() while True: - report = { - 'hostname': socket.gethostname(), - 'uptime_seconds': self._Uptime(), - 'next_timestamp': self._NextTimestamp(), - 'next_volume_id': lib.GetVolumeID('/isodevice/iconograph/current'), - } - report.update(self._config) - self.send(json.dumps({ - 'type': 'report', - 'data': report, - }), False) + self._SendReport() time.sleep(5.0) + def _SendReport(self): + report = { + 'hostname': socket.gethostname(), + 'uptime_seconds': self._Uptime(), + 'next_timestamp': self._NextTimestamp(), + 'next_volume_id': lib.GetVolumeID('/isodevice/iconograph/current'), + } + report.update(self._config) + self.send(json.dumps({ + 'type': 'report', + 'data': report, + })) + def _Uptime(self): with open('/proc/uptime', 'r') as fh: return int(float(fh.readline().split(' ', 1)[0])) @@ -128,6 +131,7 @@ class Client(threadedclient.WebSocketClient): fetch.Fetch(data['timestamp']) self._UpdateGrub() + self._SendReport() subprocess.check_call(['reboot']) def received_message(self, msg):