Skip to content

Instantly share code, notes, and snippets.

@cynthia
Created July 31, 2017 06:52
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 cynthia/753d4bf56ea3d3f466e8624ee6a35acd to your computer and use it in GitHub Desktop.
Save cynthia/753d4bf56ea3d3f466e8624ee6a35acd to your computer and use it in GitHub Desktop.
Quick and dirty script to find all CEF and Electron installations in macOS. (Not the prettiest code, to be addressed later)
#!/usr/local/bin/python3
import os
MRD = 10
def recursive_suffix_find(p, s='.app', cs=False, do=True, d=0):
a = []
try:
l = os.listdir(p)
except PermissionError as pe:
return []
for f in l:
fp = os.path.join(p, f)
fl = f[-len(s):].lower if cs else f[-len(s):]
if os.path.isdir(fp):
if fl == s:
a.append(fp)
else:
if d - 1 < MRD:
a.extend(recursive_suffix_find(p=fp, s=s, cs=cs, do=do, d=(d + 1)))
else:
break
else:
if not do and fl == s:
a.append(fullpath)
return a
def find_frameworks(app):
frameworks = []
search_path = app + '/Contents/Frameworks'
if os.path.exists(search_path):
contents = os.listdir(search_path)
for content in contents:
current_path = os.path.join(search_path, content)
if content[-10:].lower() == '.framework':
frameworks.append(current_path)
if content[-4:].lower() == '.app':
frameworks.extend(find_frameworks(current_path))
return frameworks
main = lambda: [print(x, y) for x, y in {e: [f for f in find_frameworks(e) if 'electron' in f.lower() or 'chromium' in f.lower()] for e in recursive_suffix_find('/Applications')}.items() if len(y) > 0]
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment