faust icon indicating copy to clipboard operation
faust copied to clipboard

faust2sc.py: Path not properly escaped on macos

Open madskjeldgaard opened this issue 3 years ago • 0 comments

Hi

This line seems to cause that the path of the plugin file becomes incorrect on macOS if the path includes a space, which it usually does: https://github.com/grame-cncm/faust/blob/4645a5b42455676a4dcdc71e2508ffe1fd984203/tools/faust2appls/faust2sc.py#L175

on macos this works:

os.getcwd().replace(" ", "\\")

But is this cross platform compatible?

Also the command should be split in convert_files:

 cmd = ["faust", "-i", "-a", arch_file, "-json", dsp_file, "-o", cpp_file]

and then remove the .split() from the cmd

def convert_files(dsp_file, out_dir, arch, faustflags):
    cpp_file = path.splitext(path.basename(dsp_file))[0] + ".cpp"
    arch_file = arch or "supercollider.cpp"

    cmd = ["faust", "-i", "-a", arch_file, "-json", dsp_file, "-o", cpp_file]

    result = {
        "arch_file": arch_file,
        "dsp_file": dsp_file,
        "out_dir": out_dir,
        "cpp_file": cpp_file,
        "json_file": dsp_file + ".json"
    }

    print("Converting faust file to .json and .cpp.\nCommand:\n%s.\nc++ file:%s\njson file:%s" % (cmd, cpp_file, result["json_file"]))
    try:
        subprocess.run(cmd, check = True, capture_output=False)
        # shutil.move(result["cpp_file"], path.join(out_dir, result["cpp_file"]))
        # shutil.move(result["json_file"], path.join(out_dir, result["json_file"]))
    except subprocess.CalledProcessError:
        # print(cmd)
        sys.exit('faust failed to compile json file')

    return result

Posting this here as a reminder to myself mostly to test this on other platforms.

madskjeldgaard avatar Jun 28 '22 20:06 madskjeldgaard