Created
August 6, 2017 21:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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