Added debug parameter. More sanity checks. Return empty result set if no
actual results were returned.
This commit is contained in:
parent
7959ac4776
commit
bd62226a6e
@ -23,6 +23,7 @@ optp.add_option("--code", action="append", dest="unlock_codes", metavar="UNLOCK_
|
|||||||
optp.add_option("--devicexml", dest="devicexml", metavar="FILE", help="Use specified GarminDevice.xml (also implies -E)")
|
optp.add_option("--devicexml", dest="devicexml", metavar="FILE", help="Use specified GarminDevice.xml (also implies -E)")
|
||||||
optp.add_option("--json", action="store_true", dest="json", default=False, help="Output JSON")
|
optp.add_option("--json", action="store_true", dest="json", default=False, help="Output JSON")
|
||||||
optp.add_option("--list-devices", action="store_true", dest="list_devices", default=False, help="Show a list of SKUs and product names")
|
optp.add_option("--list-devices", action="store_true", dest="list_devices", default=False, help="Show a list of SKUs and product names")
|
||||||
|
optp.add_option("--debug", action="store_true", dest="debug", default=False, help="Dump raw server requests and replies to files")
|
||||||
|
|
||||||
optp.usage = """
|
optp.usage = """
|
||||||
%prog [options] SKU1 [SKU2..SKUn]
|
%prog [options] SKU1 [SKU2..SKUn]
|
||||||
@ -50,6 +51,9 @@ elif len(device_skus) < 1 and not opts.devicexml:
|
|||||||
|
|
||||||
us = updateserver.UpdateServer()
|
us = updateserver.UpdateServer()
|
||||||
|
|
||||||
|
if opts.debug:
|
||||||
|
us.debug = True
|
||||||
|
|
||||||
if opts.devicexml:
|
if opts.devicexml:
|
||||||
# Filename given, load GarminDevice.xml from there; also disable WebUpdater
|
# Filename given, load GarminDevice.xml from there; also disable WebUpdater
|
||||||
print("Using GarminDevice.xml from {}.".format(opts.devicexml))
|
print("Using GarminDevice.xml from {}.".format(opts.devicexml))
|
||||||
|
@ -63,7 +63,8 @@ class UpdateInfo:
|
|||||||
self.device_name = self.dom_get_text(dom.getElementsByTagName("Description"))
|
self.device_name = self.dom_get_text(dom.getElementsByTagName("Description"))
|
||||||
version_major = self.dom_get_text(dom.getElementsByTagName("VersionMajor"))
|
version_major = self.dom_get_text(dom.getElementsByTagName("VersionMajor"))
|
||||||
version_minor = self.dom_get_text(dom.getElementsByTagName("VersionMinor"))
|
version_minor = self.dom_get_text(dom.getElementsByTagName("VersionMinor"))
|
||||||
self.fw_version = "{}.{:0>2s}".format(version_major, version_minor)
|
if len(version_minor) > 0:
|
||||||
|
self.fw_version = "{}.{:0>2s}".format(version_major, version_minor)
|
||||||
self.license_url = self.dom_get_text(dom.getElementsByTagName("LicenseLocation"))
|
self.license_url = self.dom_get_text(dom.getElementsByTagName("LicenseLocation"))
|
||||||
self.changelog = self.dom_get_text(dom.getElementsByTagName("ChangeDescription"))
|
self.changelog = self.dom_get_text(dom.getElementsByTagName("ChangeDescription"))
|
||||||
self.notes = self.dom_get_text(dom.getElementsByTagName("Notes"))
|
self.notes = self.dom_get_text(dom.getElementsByTagName("Notes"))
|
||||||
@ -107,11 +108,12 @@ class UpdateServer:
|
|||||||
device_xml = self.get_device_xml(sku_numbers)
|
device_xml = self.get_device_xml(sku_numbers)
|
||||||
reply = self.get_unit_updates(device_xml)
|
reply = self.get_unit_updates(device_xml)
|
||||||
results = []
|
results = []
|
||||||
for i in range(0, len(reply.update_info)):
|
if reply:
|
||||||
ui = reply.update_info[i]
|
for i in range(0, len(reply.update_info)):
|
||||||
r = UpdateInfo()
|
ui = reply.update_info[i]
|
||||||
r.fill_from_protobuf(ui)
|
r = UpdateInfo()
|
||||||
results.append(r)
|
r.fill_from_protobuf(ui)
|
||||||
|
results.append(r)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def query_webupdater(self, sku_numbers):
|
def query_webupdater(self, sku_numbers):
|
||||||
@ -125,6 +127,10 @@ class UpdateServer:
|
|||||||
|
|
||||||
results = []
|
results = []
|
||||||
for resp in dom.getElementsByTagName("Response"):
|
for resp in dom.getElementsByTagName("Response"):
|
||||||
|
uf = resp.getElementsByTagName("UpdateFile")
|
||||||
|
if len(uf) == 0:
|
||||||
|
# Empty result
|
||||||
|
continue
|
||||||
r = UpdateInfo()
|
r = UpdateInfo()
|
||||||
r.fill_from_response_dom(resp)
|
r.fill_from_response_dom(resp)
|
||||||
results.append(r)
|
results.append(r)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user