Skip to content

Instantly share code, notes, and snippets.

@MagerValp
Forked from erikng/32bitapps.py
Last active January 26, 2018 04:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MagerValp/f926e84ac2e43d1f698343f1d6848de0 to your computer and use it in GitHub Desktop.
Save MagerValp/f926e84ac2e43d1f698343f1d6848de0 to your computer and use it in GitHub Desktop.
32bitapps.py
#!/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