#NEWLINE# def _get_profiles( self ) : #NEWLINE# #INDENT# log . info ( 'Getting firefox profiles' ) #NEWLINE# if ( self . os == 'linux' ) : #NEWLINE# #INDENT# profiles_folder = self . _expand ( '~/.mozilla/firefox/' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . os == 'windows' ) : #NEWLINE# #INDENT# if ( platform . release ( ) == 'XP' ) : #NEWLINE# #INDENT# log . error ( 'Unsupported OS (Windows XP). Returning None' ) #NEWLINE# return None #NEWLINE# #UNINDENT# profiles_folder = self . _expand ( '%APPDATA%\\Mozilla\\Firefox\\' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . os == 'darwin' ) : #NEWLINE# #INDENT# profiles_folder = self . _expand ( '~/Library/Mozilla/Firefox/' ) #NEWLINE# if ( not os . path . exists ( profiles_folder ) ) : #NEWLINE# #INDENT# profiles_folder = self . _expand ( '~/Library/Application Support/Firefox/' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# log . error ( 'Unsupported OS. Returning None' ) #NEWLINE# return None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# log . debug ( 'Firefox profiles root folder set to {}' . format ( profiles_folder ) ) #NEWLINE# if ( not os . path . exists ( profiles_folder ) ) : #NEWLINE# #INDENT# log . error ( 'profiles_folder does not exists, returning {}' ) #NEWLINE# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# profiles_path = os . path . join ( profiles_folder , 'profiles.ini' ) #NEWLINE# log . debug ( 'profiles.ini path: {}' . format ( profiles_path ) ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# log . error ( 'Joining folder and profiles.ini failed. Returning None' ) #NEWLINE# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# log . exception ( e ) #NEWLINE# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( not os . path . exists ( profiles_path ) ) : #NEWLINE# #INDENT# log . error ( 'Profiles path not found. New FF installation?. Returning None' ) #NEWLINE# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# profiles = ConfigParser . RawConfigParser ( ) #NEWLINE# profiles . read ( profiles_path ) #NEWLINE# profiles . remove_section ( 'General' ) #NEWLINE# available_profiles = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( index , profile ) in enumerate ( profiles . sections ( ) ) : #NEWLINE# #INDENT# name = profiles . get ( profiles . sections ( ) [ index ] , 'Name' ) #NEWLINE# path = profiles . get ( profiles . sections ( ) [ index ] , 'Path' ) #NEWLINE# available_profiles [ name ] = path #NEWLINE# #UNINDENT# log . debug ( 'Profiles:{}' . format ( available_profiles ) ) #NEWLINE# return available_profiles