Skip to content

Commit 50093ac

Browse files
committed
tools: cloud: apps: info: support cross-app diffs
Add support for displaying cross-application diffs. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 7f50f6b commit 50093ac

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

src/infuse_iot/tools/cloud.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,23 +538,42 @@ def _info_one(self, client: Client):
538538
tablefmt="simple",
539539
)
540540
)
541+
542+
other_apps = get_applications_by_organisation_id.sync(client=client, id=UUID(self.args.org))
543+
assert isinstance(other_apps, list)
544+
541545
diff_info = []
542546
for diff in diffs:
547+
source_app_id = self.args.app
543548
from_release = get_release_by_organisation_id_and_application_id_and_release_id.sync(
544-
client=client, id=UUID(self.args.org), application_id=self.args.app, release_id=diff.from_release_id
549+
client=client, id=UUID(self.args.org), application_id=source_app_id, release_id=diff.from_release_id
545550
)
551+
if not isinstance(from_release, models.ApplicationRelease):
552+
# Try the other applications in the organisation
553+
for other_app in other_apps:
554+
from_release = get_release_by_organisation_id_and_application_id_and_release_id.sync(
555+
client=client,
556+
id=UUID(self.args.org),
557+
application_id=other_app.id,
558+
release_id=diff.from_release_id,
559+
)
560+
if isinstance(from_release, models.ApplicationRelease):
561+
source_app_id = other_app.id
562+
break
546563
if not isinstance(from_release, models.ApplicationRelease):
547564
print(f"Failed to query information about source release {diff.from_release_id}")
548565
continue
549566
from_version = from_release.version
550567
from_version_str = (
551568
f"{from_version.major}.{from_version.minor}.{from_version.revision}+{from_version.build_num:08x}"
552569
)
553-
diff_info.append([from_version_str, diff.file.coap_path, diff.file.len_, diff.file.crc])
570+
diff_info.append(
571+
[f"0x{source_app_id:08x}", from_version_str, diff.file.coap_path, diff.file.len_, diff.file.crc]
572+
)
554573

555574
if len(diff_info) > 0:
556575
print("~~~ Diffs ~~~")
557-
print(tabulate(diff_info, headers=["From Version", "Path", "Length", "CRC"]))
576+
print(tabulate(diff_info, headers=["From App", "From Version", "Path", "Length", "CRC"]))
558577

559578
def _info_all(self, client: Client):
560579
releases = get_releases_by_organisation_id_and_application_id.sync(

0 commit comments

Comments
 (0)