-
-
Save MagerValp/f926e84ac2e43d1f698343f1d6848de0 to your computer and use it in GitHub Desktop.
32bitapps.py
This file contains hidden or 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/python | |
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from __future__ import print_function | |
from __future__ import division | |
import io | |
import sys | |
import codecs | |
if sys.stdout.encoding != "UTF-8": | |
sys.stdout = codecs.getwriter("utf-8")(sys.stdout, "strict") | |
if sys.stderr.encoding != "UTF-8": | |
sys.stderr = codecs.getwriter("utf-8")(sys.stderr, "strict") | |
import subprocess | |
import plistlib | |
def main(argv): | |
cmd = ["/usr/sbin/system_profiler", "-xml", "SPApplicationsDataType"] | |
proc = subprocess.Popen(cmd, | |
shell=False, | |
bufsize=-1, | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE) | |
output, err = proc.communicate() | |
plist = plistlib.readPlistFromString(output) | |
items = plist[0]["_items"] | |
print("Path\tName\tVersion") | |
for item in sorted(items, key=lambda x: x.get("path")): | |
if "no" in item.get("has64BitIntelCode"): | |
print("\t".join([item.get("path"), item.get("_name"), item.get("version")])) | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment