From 7f63d94616f6a9026ca94fbe5f88e1cb40a28a43 Mon Sep 17 00:00:00 2001 From: joecryptotoo <80373433+joecryptotoo@users.noreply.github.com> Date: Wed, 30 Mar 2022 12:26:48 -0700 Subject: [PATCH] output get-time, get-battery, get-time, get-status in JSON format --- Software/Source/Utilities/pijuice_util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Software/Source/Utilities/pijuice_util.py b/Software/Source/Utilities/pijuice_util.py index 420658c1..70aa73c8 100755 --- a/Software/Source/Utilities/pijuice_util.py +++ b/Software/Source/Utilities/pijuice_util.py @@ -164,11 +164,11 @@ def getDataOrError(d): # primitives if args.get_status: - print(pj.status.GetStatus()) + print(json.dumps(pj.status.GetStatus())) if args.get_time: rtc = pj.rtcAlarm - print(getDataOrError(rtc.GetTime())) + print(json.dumps(getDataOrError(rtc.GetTime()))) # composites @@ -199,7 +199,7 @@ def getDataOrError(d): v['chargeLevel'] = getDataOrError(status.GetChargeLevel()) s = status.GetStatus().get('data',{ 'error': 'NO-STATUS-AVAILABLE'}) v['batteryStatus'] = s.get('battery', 'BATTERY_STATUS-NOT-IN-STATUS') - print(v) + print(json.dumps(v)) if args.get_input: v = {} @@ -212,5 +212,5 @@ def getDataOrError(d): # TODO is 'gpioPowerStatus' name good, or should it be powerInput5vIo? v['gpioPowerStatus'] = s.get('powerInput5vIo', 'GPIO_POWER_STATUS-NOT-IN-STATUS') v['usbPowerInput'] = s.get('powerInput', 'POWERINPUT-NOT-IN-STATUS') - print(v) + print(json.dumps(v))