Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick script checking if a given file may be a valid appimage file
#!/usr/bin/env python3
import argparse
import struct
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
'appimage', metavar='APPIMAGE', help="Appimage file to query",
type=argparse.FileType(mode="rb"))
ns = parser.parse_args()
with ns.appimage as f:
f.seek(8)
tag = f.read(3)
if tag == b'\x41\x49\x02':
print("{} looks like a valid appimage file".format(f.name))
else:
print("{} doesn't look like a valid appimage file".format(f.name))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment