Skip to content

Instantly share code, notes, and snippets.

@AndrewWCarson
Created May 20, 2019 17:27
Show Gist options
  • Save AndrewWCarson/9177b80632779d4250f67f02b1ad7379 to your computer and use it in GitHub Desktop.
Save AndrewWCarson/9177b80632779d4250f67f02b1ad7379 to your computer and use it in GitHub Desktop.
Prints all apps that are 32-bit only.
#!/usr/bin/python
import subprocess
import plistlib
def get32BitApps():
cmd = '/usr/sbin/system_profiler -xml SPApplicationsDataType'
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
exit('Error: ' + err)
plist = plistlib.readPlistFromString(out)
foundApps = []
apps = plist[0]['_items']
for app in apps:
if 'no' in app.get('has64BitIntelCode'):
foundApps.append(app.get('path'))
return foundApps
if __name__ == '__main__':
for app in get32BitApps():
print app
@AndrewWCarson
Copy link
Author

This is ~5s which is too slow for fact collection, imo. This could probably be refactored into using mdfind and mdls for much quicker results.

@smaddock
Copy link

smaddock commented Jun 5, 2019

/usr/bin/mdfind "kMDItemContentType == 'com.apple.application-bundle' && kMDItemExecutableArchitectures != '*x86_64*'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment