Possibly unicode related, try print(repr(filePath)) and print(type(filePath)). Strings coming out of Qt is often unicode.
Second possible cause is that there are “ included in the path, notice the triple ‘ on the invalid argument warning.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4eae1d5e-791d-4afc-bea0-489ec135b057n%40googlegroups.com.
Also copy/pasted the question into ChatGPT out of curiosity and got a similar response.
The issue you are encountering seems to be related to the formatting of the file path string. It appears that the filePath parameter you are passing to the saveTreeDataToFile function includes double quotes (“) around the path, resulting in the error you’re experiencing.
The error message you provided, OSError: [Errno 22] Invalid argument: ‘“D:/CHIMERA STUDIO/CHIMERA CGI/workspace/cfg_data.json”‘, indicates that the path is being treated as an invalid argument due to the presence of the double quotes.
To resolve this issue, you should pass the file path without the double quotes. If you are calling the saveTreeDataToFile function with the filePath parameter in quotes like this:
saveTreeDataToFile('"D:/CHIMERA STUDIO/CHIMERA CGI/workspace/cfg_data.json"', treeWidget)
You can modify the function call to remove the quotes:
saveTreeDataToFile("D:/CHIMERA STUDIO/CHIMERA CGI/workspace/cfg_data.json", treeWidget)
By removing the double quotes, the file path should be passed correctly, and the function should work as expected.