Created
January 12, 2018 14:37
-
-
Save aniline/166be773cbabb5ad33510c00a49e338f to your computer and use it in GitHub Desktop.
List ESR or quantum
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 python | |
# | |
# List Quantum migrated and non-migrated (ESR) firefox profiles. | |
# Assumes the preference 'extensions.lastAppVersion' kinda tells firefox version last used with a profile. | |
# Use at your own risk. | |
# | |
import os, sys, re | |
ff_path=os.environ['HOME']+'/.mozilla/firefox/' | |
ff_profiles = {} | |
try: | |
c_prof_n = '' | |
ff_prof_ini=map(lambda x: x[:-1], open(ff_path+'profiles.ini').readlines()) | |
for n in ff_prof_ini: | |
pl=n.split('=') | |
if (pl[0]).lower() == 'name': | |
c_prof = pl[1] | |
elif (pl[0]).lower() == 'path': | |
ff_profiles[c_prof] = '='.join(pl[1:]) | |
else: | |
None | |
except IOError, e: | |
print e | |
def is_quantum(d): | |
m = re.compile('(user_pref)\((.+)\);') | |
try: | |
prefsfile = open(d + '/prefs.js') | |
prefsl = dict(map(lambda ar: (ar[0][1:-1], ','.join(ar[1:]).strip()), map(lambda (x,y): y.split(','), map(lambda x: x.groups(), filter(None, map(m.search, prefsfile.readlines())))))) | |
prefsfile.close() | |
return int(prefsl['extensions.lastAppVersion'][1:-1].split('.')[0]) >= 57 | |
except IOError, e: | |
return None | |
for (n, d) in map(lambda (x,y): (x, ff_path+y), ff_profiles.items()): | |
if is_quantum(d): | |
print "\033[1;32m"+n+' '*(32-len(n))+"Quantum"+"\033[0m" | |
else: | |
print n+' '*(32-len(n))+"ESR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment