ArrantSquid
03-01-2011, 05:48 AM
So I'm using sockets to send some output to maya. Unfortunately what I'm getting back from Maya doesn't make sense at all. I'm trying to quote a variable, while escaping the quote, but once it gets to Maya it fails. Here's the code:
currentDir = os.getcwd()
maya.send('python("import os; import sys; os.chdir(\''+currentDir+'\'); sys.path.append(\''+currentDir+'\'); import pythonExec; pythonExec.main()")')
Here's the output I get:
python("import os; import sys; os.chdir('C:\Users\pneumonic\Documents\My Dropbox\pythonTesting'); sys.path.append('C:\Users\pneumonic\Documents\My Dropbox\pythonTesting'); import pythonExec; pythonExec.main()");
import os; import sys; os.chdir('C:UserspneumonicDocumentsMy DropboxpythonTesting'); sys.path.append('C:UserspneumonicDocumentsMy DropboxpythonTesting'); import pythonExec; pythonExec.main()
# Error: line 1: [Error 2] The system cannot find the file specified: 'C:UserspneumonicDocumentsMy DropboxpythonTesting'
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# WindowsError: [Error 2] The system cannot find the file specified: 'C:UserspneumonicDocumentsMy DropboxpythonTesting' #
It's dropping every backslash \ character in the path name. I've tried using a double quote instead of a single quote and the output I get from that is this:
python("import os; import sys; os.chdir("C:\Users\pneumonic\Documents\My Dropbox\pythonTesting"); sys.path.append("C:\Users\pneumonic\Documents\My Dropbox\pythonTesting"); import pythonExec; pythonExec.main()");
// Error: python("import os; import sys; os.chdir("C:\Users\pneumonic\Documents\My Dropbox\pythonTesting"); sys.path.append("C:\Users\pneu€ //
// Error: Line 1.42: Syntax error //
I'm not sure what it is I'm doing wrong, and I originally thought it was something I was doing - which it may be - but this works perfectly on OSX and I'm not using any non-standard libraries to do any of this. It seems idiotic that Python/Maya doesn't understand the same command from OS to OS to escape a character.
currentDir = os.getcwd()
maya.send('python("import os; import sys; os.chdir(\''+currentDir+'\'); sys.path.append(\''+currentDir+'\'); import pythonExec; pythonExec.main()")')
Here's the output I get:
python("import os; import sys; os.chdir('C:\Users\pneumonic\Documents\My Dropbox\pythonTesting'); sys.path.append('C:\Users\pneumonic\Documents\My Dropbox\pythonTesting'); import pythonExec; pythonExec.main()");
import os; import sys; os.chdir('C:UserspneumonicDocumentsMy DropboxpythonTesting'); sys.path.append('C:UserspneumonicDocumentsMy DropboxpythonTesting'); import pythonExec; pythonExec.main()
# Error: line 1: [Error 2] The system cannot find the file specified: 'C:UserspneumonicDocumentsMy DropboxpythonTesting'
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# WindowsError: [Error 2] The system cannot find the file specified: 'C:UserspneumonicDocumentsMy DropboxpythonTesting' #
It's dropping every backslash \ character in the path name. I've tried using a double quote instead of a single quote and the output I get from that is this:
python("import os; import sys; os.chdir("C:\Users\pneumonic\Documents\My Dropbox\pythonTesting"); sys.path.append("C:\Users\pneumonic\Documents\My Dropbox\pythonTesting"); import pythonExec; pythonExec.main()");
// Error: python("import os; import sys; os.chdir("C:\Users\pneumonic\Documents\My Dropbox\pythonTesting"); sys.path.append("C:\Users\pneu€ //
// Error: Line 1.42: Syntax error //
I'm not sure what it is I'm doing wrong, and I originally thought it was something I was doing - which it may be - but this works perfectly on OSX and I'm not using any non-standard libraries to do any of this. It seems idiotic that Python/Maya doesn't understand the same command from OS to OS to escape a character.
