Skip to content

Instantly share code, notes, and snippets.

@zyga
Created August 6, 2017 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zyga/45d2c3b8d948749a375467e3576a43cf to your computer and use it in GitHub Desktop.
Save zyga/45d2c3b8d948749a375467e3576a43cf to your computer and use it in GitHub Desktop.
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