Add additional information to machine parsable outputs
This commit is contained in:
parent
3cb44f5630
commit
5a9f82a20a
17
speedtest.py
17
speedtest.py
|
@ -827,8 +827,8 @@ class SpeedtestResults(object):
|
||||||
to get a share results image link.
|
to get a share results image link.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, download=0, upload=0, ping=0, server=None, opener=None,
|
def __init__(self, download=0, upload=0, ping=0, server=None, client=None,
|
||||||
secure=False):
|
opener=None, secure=False):
|
||||||
self.download = download
|
self.download = download
|
||||||
self.upload = upload
|
self.upload = upload
|
||||||
self.ping = ping
|
self.ping = ping
|
||||||
|
@ -836,6 +836,8 @@ class SpeedtestResults(object):
|
||||||
self.server = {}
|
self.server = {}
|
||||||
else:
|
else:
|
||||||
self.server = server
|
self.server = server
|
||||||
|
self.client = client or {}
|
||||||
|
|
||||||
self._share = None
|
self._share = None
|
||||||
self.timestamp = '%sZ' % datetime.datetime.utcnow().isoformat()
|
self.timestamp = '%sZ' % datetime.datetime.utcnow().isoformat()
|
||||||
self.bytes_received = 0
|
self.bytes_received = 0
|
||||||
|
@ -924,6 +926,7 @@ class SpeedtestResults(object):
|
||||||
'bytes_sent': self.bytes_sent,
|
'bytes_sent': self.bytes_sent,
|
||||||
'bytes_received': self.bytes_received,
|
'bytes_received': self.bytes_received,
|
||||||
'share': self._share,
|
'share': self._share,
|
||||||
|
'client': self.client,
|
||||||
}
|
}
|
||||||
|
|
||||||
def csv(self, delimiter=','):
|
def csv(self, delimiter=','):
|
||||||
|
@ -935,7 +938,7 @@ class SpeedtestResults(object):
|
||||||
row = [data['server']['id'], data['server']['sponsor'],
|
row = [data['server']['id'], data['server']['sponsor'],
|
||||||
data['server']['name'], data['timestamp'],
|
data['server']['name'], data['timestamp'],
|
||||||
data['server']['d'], data['ping'], data['download'],
|
data['server']['d'], data['ping'], data['download'],
|
||||||
data['upload']]
|
data['upload'], self._share or '', self.client['ip']]
|
||||||
writer.writerow([to_utf8(v) for v in row])
|
writer.writerow([to_utf8(v) for v in row])
|
||||||
return out.getvalue()
|
return out.getvalue()
|
||||||
|
|
||||||
|
@ -972,7 +975,11 @@ class Speedtest(object):
|
||||||
self.closest = []
|
self.closest = []
|
||||||
self._best = {}
|
self._best = {}
|
||||||
|
|
||||||
self.results = SpeedtestResults(opener=self._opener, secure=secure)
|
self.results = SpeedtestResults(
|
||||||
|
client=self.config['client'],
|
||||||
|
opener=self._opener,
|
||||||
|
secure=secure,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def best(self):
|
def best(self):
|
||||||
|
@ -1480,7 +1487,7 @@ def csv_header(delimiter=','):
|
||||||
"""Print the CSV Headers"""
|
"""Print the CSV Headers"""
|
||||||
|
|
||||||
row = ['Server ID', 'Sponsor', 'Server Name', 'Timestamp', 'Distance',
|
row = ['Server ID', 'Sponsor', 'Server Name', 'Timestamp', 'Distance',
|
||||||
'Ping', 'Download', 'Upload']
|
'Ping', 'Download', 'Upload', 'Share', 'IP Address']
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
writer = csv.writer(out, delimiter=delimiter, lineterminator='')
|
writer = csv.writer(out, delimiter=delimiter, lineterminator='')
|
||||||
writer.writerow([to_utf8(v) for v in row])
|
writer.writerow([to_utf8(v) for v in row])
|
||||||
|
|
Loading…
Reference in New Issue