Add --download-only mode to fetch firmware without a printer - #56
Conversation
The vendor's fileUpdate endpoint resolves the firmware image from the
model name and SPEC alone, so the update image can be downloaded without
a printer being reachable on the network.
* make the IP argument optional
* add --spec so the model's SPEC code can be provided directly
* add --download-only to skip the upload phase
* validate that --model and --spec are present when no IP is given
* surface VERSIONCHECK=2 (invalid model/SPEC) as a clear error and
print LATESTVERSION from the server response
|
I fixed these issues: Blocking No IP without --download-only is accepted and tries to upload to localhost. The validation only checks args.ip is None → require model+spec. It never requires --download-only. So ./oh-brother.py -m X -S Y -c MAIN -f 1.77 downloads the firmware, then falls into the upload path with args.ip = None. I checked: socket.getaddrinfo(None, 9100, proto=SOL_TCP) resolves to 127.0.0.1. Normally you get connection refused (caught, prints "aborted"), but if anything is listening on local 9100 — a raw JetDirect queue, CUPS socket backend — it gets a firmware blob. The -p path is worse: FTP(None) skips connect, then storbinary raises something not caught by the ConnectionRefusedError handler. Fix is one line: require --download-only when no IP, or imply it. --category is silently required too but not validated. With no IP, firmInfo stays [] unless -c is given, so the download loop runs zero times and the script prints Success having done nothing. The README example passes -c MAIN -f 1.77, so the author knows — the check just doesn't cover it. |
Summary
The vendor's
fileUpdateendpoint resolves the firmware image from the modelname and SPEC alone, so the update image can be downloaded without a printer
being reachable on the network. Today the script requires a printer IP,
always performs the SNMP walk, and aborts on any SNMP failure — even though
only the download half needs the printer at all.
Changes
IPargument optional (nargs='?').--spec/-Sto provide the model's SPEC code directly (previouslySPEC could only be read from the printer, and had no override even though
--modeland--categoryalready had them).--download-onlyto skip the upload phase;--testis unchanged.--modeland--spec(clearparser.errorotherwise).VERSIONCHECK=2(invalid model name / wrong SPEC) as an expliciterror with a hint, instead of exiting silently with
"No firmware update info path found".
LATESTVERSIONfrom the server response (was in the payload,previously ignored).
Usage
--model/--specvalues can be read from a reachable printer via SNMP:Notes / findings from testing against the vendor server
VERSIONCHECKsemantics as observed:0= update available (PATH holds aplain-HTTP Akamai CDN URL, no auth),
1= already up to date,2=invalid model name / wrong SPEC / missing device context.
<VERSION>value in the request should be a real, lower installedversion (e.g.
1.77); placeholder values like0or1.0getVERSIONCHECK=2.network card and expects community
public; unknown communities aresilently dropped, which looks like a timeout. (The
--communityoptionalready exists upstream — this PR only documents the failure mode.)
Compatibility
Backwards compatible: existing invocations with an IP behave exactly as
before. No dependency changes. Related open PRs (#44, #47) only touch the
README and do not conflict.