

def copy_xul_runtime(dir1, dir2):
    ' Copy the firefox/xulrunner runtime to a new folder, in which\n    we rename the firefox exe to xulrunner. This thus creates a xul\n    runtime in a location where we have write access. Used to be able\n    to set the process name on Windows, and maybe used to distribute\n    apps *with* the runtime.\n    '
    t0 = time.time()
    ext = ('.exe' if sys.platform.startswith('win') else '')
    if op.isdir(op.join(dir1, 'xulrunner')):
        dir1 = op.join(dir1, 'xulrunner')
    if op.isdir(dir2):
        shutil.rmtree(dir2)
    os.mkdir(dir2)
    try:
        for fname in os.listdir(dir1):
            filename1 = op.join(dir1, fname)
            filename2 = op.join(dir2, fname)
            if op.isfile(filename1):
                shutil.copy2(filename1, filename2)
        for exe_name in ('firefox', 'iceweasel', 'xulrunner', 'firefox'):
            exe = op.join(dir1, (exe_name + ext))
            if op.isfile(exe):
                break
        shutil.copy2(exe, op.join(dir2, ('xulrunner' + ext)))
        logging.info(('Copied firefox (in %1.2f s)' % (time.time() - t0)))
    except Exception:
        shutil.rmtree(dir2)
        raise

dataset/ETHPy150Open zoofIO/flexx/flexx/webruntime/xul.py copy_xul_runtime/original