

def _get_xul_runtime(self):
    ' Get path to executable of a xul runtime. The returned path\n        is in a writable directory. On Unix/OSX it may be a symlink,\n        on Windows it is a real file. Returns None if no XUL runtime\n        could be found.\n        '
    exe_name = 'xulrunner'
    exe_name += ('.exe' if sys.platform.startswith('win') else '')
    ff_exe = get_firefox_exe()
    ff_version = ''
    if ff_exe:
        if ('Contents/MacOS/' in ff_exe):
            inifile = op.join(op.dirname(ff_exe), '../Resources/application.ini')
        else:
            inifile = op.join(op.dirname(ff_exe), 'application.ini')
        for line in open(inifile, 'rb').read().decode().splitlines():
            if line.lower().startswith('version'):
                ff_version = ('xul_' + line.split('=')[1].strip())
                break
    xuldir = op.join(appdata_dir('flexx'), 'webruntimes')
    if (not op.isdir(xuldir)):
        os.mkdir(xuldir)
    dnames = [d for d in sorted(os.listdir(xuldir)) if d.startswith('xul')]
    obsolete = [d for d in dnames if (not op.isfile(op.realpath(op.join(xuldir, d, exe_name))))]
    dnames = [d for d in dnames if (ff_exe not in obsolete)]
    for dname in (obsolete + dnames[:(- 1)]):
        logging.info(('Clearing XUL runtime at %s' % dname))
        try:
            shutil.rmtree(op.join(xuldir, dname))
        except (OSError, IOError):
            pass
    if ff_version:
        if ((not dnames) or (dnames[(- 1)] < ff_version)):
            self._install_ff_locally(op.join(xuldir, ff_version), ff_exe)
            dnames.append(ff_version)
    if dnames:
        return op.join(xuldir, dnames[(- 1)], exe_name)

dataset/ETHPy150Open zoofIO/flexx/flexx/webruntime/xul.py XulRuntime._get_xul_runtime/VarMisuse@262/453 `d`->`ff_exe`