mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-10 22:41:51 +02:00
fix uptime for "user" instead of "users"
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20240906 v1.25.4
|
20240907 v1.25.4
|
||||||
- Fix `mount` parser for cases where there are spaces in the filesystem name
|
- Fix `mount` parser for cases where there are spaces in the filesystem name
|
||||||
- Fix `ip-address` parser for Python 3.13 changes to IPv4 mapped IPv6 addresses
|
- Fix `ip-address` parser for Python 3.13 changes to IPv4 mapped IPv6 addresses
|
||||||
|
- Fix `uptime` parser for data that contains `user` instead of `users`
|
||||||
|
|
||||||
20240609 v1.25.3
|
20240609 v1.25.3
|
||||||
- Enhance `bluetoothctl` parser with added `battery_percentage` field
|
- Enhance `bluetoothctl` parser with added `battery_percentage` field
|
||||||
|
@@ -65,7 +65,7 @@ import jc.utils
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.9'
|
version = '1.10'
|
||||||
description = '`uptime` command parser'
|
description = '`uptime` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@@ -162,7 +162,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
if 'users' in data:
|
if 'user' in data:
|
||||||
# standard uptime output
|
# standard uptime output
|
||||||
time, _, *uptime, users, _, _, _, load_1m, load_5m, load_15m = data.split()
|
time, _, *uptime, users, _, _, _, load_1m, load_5m, load_15m = data.split()
|
||||||
|
|
||||||
|
@@ -73,6 +73,14 @@ class MyTests(unittest.TestCase):
|
|||||||
expected = {"time":"00:03:32","uptime":"3 min","load_1m":0.0,"load_5m":0.0,"load_15m":0.0,"time_hour":0,"time_minute":3,"time_second":32,"uptime_days":0,"uptime_hours":0,"uptime_minutes":3,"uptime_total_seconds":180}
|
expected = {"time":"00:03:32","uptime":"3 min","load_1m":0.0,"load_5m":0.0,"load_15m":0.0,"time_hour":0,"time_minute":3,"time_second":32,"uptime_days":0,"uptime_hours":0,"uptime_minutes":3,"uptime_total_seconds":180}
|
||||||
self.assertEqual(jc.parsers.uptime.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.uptime.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
def test_uptime_user(self):
|
||||||
|
"""
|
||||||
|
Test 'uptime' with 'user' instead of 'users' in the data
|
||||||
|
"""
|
||||||
|
data = ' 12:44:19 up 1 day, 23:12, 0 user, load average: 3.94, 4.43, 2.75'
|
||||||
|
expected = {"time":"12:44:19","uptime":"1 day, 23:12","users":0,"load_1m":3.94,"load_5m":4.43,"load_15m":2.75,"time_hour":12,"time_minute":44,"time_second":19,"uptime_days":1,"uptime_hours":23,"uptime_minutes":12,"uptime_total_seconds":169920}
|
||||||
|
self.assertEqual(jc.parsers.uptime.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user