(self)
return binary
Finds the binary for self.names if one was not provided.
Finds the binary for self.names if one was not provided.
Finds the binary for self . names if one was not provided .
def find_binary(self):
        """Finds the binary for self.names if one was not provided."""
        binary = None
        if sys.platform in ('linux2', 'sunos5', 'solaris'):
            for name in reversed(self.names):
                binary = findInPath(name)
        elif os.name == 'nt' or sys.platform == 'cygwin':

            # find the default executable from the windows registry
            try:
                # assumes self.app_name is defined, as it should be for
                # implementors
                import _winreg
                app_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"Software\Mozilla\Mozilla %s" % self.app_name)
                version, _type = _winreg.QueryValueEx(app_key, "CurrentVersion")
                version_key = _winreg.OpenKey(app_key, version + r"\Main")
                path, _ = _winreg.QueryValueEx(version_key, "PathToExe")
                return path
            except: # XXX not sure what type of exception this should be
                pass

            # search for the binary in the path            
            for name in reversed(self.names):
                binary = findInPath(name)
                if sys.platform == 'cygwin':
                    program_files = os.environ['PROGRAMFILES']
                else:
                    program_files = os.environ['ProgramFiles']

                if binary is None:
                    for bin in [(program_files, 'Mozilla Firefox', 'firefox.exe'),
                                (os.environ.get("ProgramFiles(x86)"),'Mozilla Firefox', 'firefox.exe'),
                                (program_files,'Nightly', 'firefox.exe'),
                                (os.environ.get("ProgramFiles(x86)"),'Nightly', 'firefox.exe')
                                ]:
                        path = os.path.join(*bin)
                        if os.path.isfile(path):
                            binary = path
                            break
        elif sys.platform == 'darwin':
            for name in reversed(self.names):
                appdir = os.path.join('Applications', name.capitalize()+'.app')
                if os.path.isdir(os.path.join(os.path.expanduser('~/'), appdir)):
                    binary = os.path.join(os.path.expanduser('~/'), appdir,
                                          'Contents/MacOS/'+name+'-bin')
                elif os.path.isdir('/'+appdir):
                    binary = os.path.join("/"+appdir, 'Contents/MacOS/'+name+'-bin')

                if binary is not None:
                    if not os.path.isfile(binary):
                        binary = binary.replace(name+'-bin', 'firefox-bin')
                    if not os.path.isfile(binary):
                        binary = None
        if binary is None:
            raise Exception('Mozrunner could not locate your binary, you will need to set it.')
        return binary
def find_binary ( self ) : binary = None if sys . platform in ( 'linux2' , 'sunos5' , 'solaris' ) : for name in reversed ( self . names ) : binary = findInPath ( name ) elif os . name == 'nt' or sys . platform == 'cygwin' : # find the default executable from the windows registry try : # assumes self.app_name is defined, as it should be for # implementors import _winreg app_key = _winreg . OpenKey ( _winreg . HKEY_LOCAL_MACHINE , r"Software\Mozilla\Mozilla %s" % self . app_name ) version , _type = _winreg . QueryValueEx ( app_key , "CurrentVersion" ) version_key = _winreg . OpenKey ( app_key , version + r"\Main" ) path , _ = _winreg . QueryValueEx ( version_key , "PathToExe" ) return path except : # XXX not sure what type of exception this should be pass # search for the binary in the path             for name in reversed ( self . names ) : binary = findInPath ( name ) if sys . platform == 'cygwin' : program_files = os . environ [ 'PROGRAMFILES' ] else : program_files = os . environ [ 'ProgramFiles' ] if binary is None : for bin in [ ( program_files , 'Mozilla Firefox' , 'firefox.exe' ) , ( os . environ . get ( "ProgramFiles(x86)" ) , 'Mozilla Firefox' , 'firefox.exe' ) , ( program_files , 'Nightly' , 'firefox.exe' ) , ( os . environ . get ( "ProgramFiles(x86)" ) , 'Nightly' , 'firefox.exe' ) ] : path = os . path . join ( * bin ) if os . path . isfile ( path ) : binary = path break elif sys . platform == 'darwin' : for name in reversed ( self . names ) : appdir = os . path . join ( 'Applications' , name . capitalize ( ) + '.app' ) if os . path . isdir ( os . path . join ( os . path . expanduser ( '~/' ) , appdir ) ) : binary = os . path . join ( os . path . expanduser ( '~/' ) , appdir , 'Contents/MacOS/' + name + '-bin' ) elif os . path . isdir ( '/' + appdir ) : binary = os . path . join ( "/" + appdir , 'Contents/MacOS/' + name + '-bin' ) if binary is not None : if not os . path . isfile ( binary ) : binary = binary . replace ( name + '-bin' , 'firefox-bin' ) if not os . path . isfile ( binary ) : binary = None if binary is None : raise Exception ( 'Mozrunner could not locate your binary, you will need to set it.' ) return binary