Created
December 14, 2018 05:38
-
-
Save slivingston/feb5d4682d4af02ecf3e5a1f673ce430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""check Misty version numbers against reference | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
https://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
Copyright (C) 2018 rerobots, Inc. | |
by SCL <scott@rerobots.net> | |
""" | |
import sys | |
import requests | |
EXPECTED = { | |
'robotVersion': '1.1.11.0', | |
'hardwareInfo': { | |
'mcBoard': { | |
'firmware': '1.1.11.3', | |
}, | |
'rtcBoard': { | |
'firmware': '1.1.11.3', | |
}, | |
}, | |
'sensoryServiceAppVersion': '1.1.11.3', | |
} | |
def check_deviceinfo(di, parent=None, expected_versions=None): | |
if expected_versions is None: | |
expected_versions = EXPECTED | |
if parent is None: | |
p = '' | |
else: | |
p = parent + '.' | |
for k, v in expected_versions.items(): | |
full_path = p + k | |
if k not in di: | |
raise ValueError('missing item: {}'.format(k)) | |
if isinstance(v, dict): | |
check_deviceinfo(di[k], parent=full_path, expected_versions=v) | |
else: | |
if di[k] != v: | |
raise ValueError('expected {} to be {}, but found {}'.format(full_path, v, di[k])) | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
print('Usage: checkmistyversion.py ADDRESS') | |
sys.exit(1) | |
ipv4_addr = sys.argv[1] | |
try: | |
res = requests.get('http://{}/api/info/device'.format(ipv4_addr)) | |
assert res.ok | |
di = res.json()[0] | |
assert di['status'] == 'Success' | |
assert 'result' in di | |
except: | |
print('Failed to get Misty device information.') | |
print('Is {} the correct address of the robot?'.format(ipv4_addr)) | |
sys.exit(1) | |
try: | |
check_deviceinfo(di['result']) | |
except ValueError as msg: | |
print(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
patch recommendation at https://community.mistyrobotics.com/t/12-10-18-release-notes/1101/7