
This is my first post on stackoverflow, so if somethings wrong I'm eager to learn!
I'm programming a plugin for Cinema 4d with python. Everything works on Mac, but I'm having problems on Windows with what I'm about to explain.
The plugin needs a path to a server, in case of rendering on a renderserver. I want the user to enter the path once, and to then store it in a .txt file.
for c4d, plugins are being installed, by draging-and-droping the plugin into the plugin folder at for example:
C:/programm files/Maxon/Cinema4D/Plugins/NewPluginGoesHere
In Order to keep everything nice and clean, I want the pathToServer.txt (text file that only stores one line with the path) in the plugin folder as well. When Installing (droping) the plugin into said folder, the .txt file is already there -> Not created by the plugin.
Here comes the problem:
I open and write to the file with
pathFile = open(pathToPathFile, "w")
pathFile.write(pathToServerFolder)
Works fine on mac, but throws
IOError: [Errno 13] Permission denied: 'C:\Program Files\MAXON\CINEMA 4D R14\plugins\MultiLayerRender\Renderserverpath.txt'
on Windows.
I'm pretty inexperienced with using python for such tasks (like file management).
I then tried the following:
pathFile = subprocess.Popen(pathToPathFile, stdin = subprocess.PIPE, stdout = subprocess.PIPE, shell = True)
pathFile.communicate(input = pathToServerFolder)
pathFile.stdin.close()
Which doesn't give me an error, but it also doesn't seem to do anything :/
I read throung the python documentation of subprocess, but that realy didn't help me at all, if anything, it confused me.
I noticed, that I also need to run my code editor in Admin Mode, in order for it to have permission to save directly into the plugin folder in said directory. It seems like files in the 'program files' folder are somehow protected. Also, this plugin will be installed on several different computers either mac or windows, and therefor changing permission on for example the programm files folder is not an option. In the end draging and droping should be all one has to do in order to install it.
Does anyone know how to achieve that?
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)