JulianEberius / SublimePythonIDE

ST3 only: A rewrite of SublimeRope for ST3, uses the Rope library to add python completions and refactoring to ST3
GNU General Public License v2.0
267 stars 36 forks source link

[WinXP] No server respose for unsaved buffers. #34

Closed OscarL closed 10 years ago

OscarL commented 11 years ago

Using the latest version, on Windows XP.

When trying to test the autocomplete functionality, I get (using SERVER_DEBUGGING = True):

started server on port 2161 with C:\Python27\python.exe IN DEBUG MODE
SublimePythonIDE: No server respose
'NoneType' object has no attribute 'data'
started server on port 2163 with C:\Python27\python.exe IN DEBUG MODE

Server on port 2163 - STDERR: b'SublimePythonIDE Server is starting in Debug mode\r\n'
Server on port 2163 - STDERR: b'SublimePythonIDE Server is called: completions\r\n'
Server on port 2163 - STDERR: b'Traceback (most recent call last):\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\server.py", line 134, in completions\r\n'
Server on port 2163 - STDERR: b'    project, source, loc, resource=resource, maxfixes=3)\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 33, in code_assist\r\n'
Server on port 2163 - STDERR: b'    return assist()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 335, in __call__\r\n'
Server on port 2163 - STDERR: b'    completions = list(self._code_completions().values())\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 403, in _code_completions\r\n'
Server on port 2163 - STDERR: b'    pymodule = fixer.get_pymodule()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\utils.py", line 10, in _wrapper\r\n'
Server on port 2163 - STDERR: b'    setattr(self, name, func(self, *args, **kwds))\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\fixsyntax.py", line 24, in get_pymodule\r\n'
Server on port 2163 - STDERR: b'    self.resource.read() == code:\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 81, in read\r\n'
Server on port 2163 - STDERR: b'    data = self.read_bytes()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 88, in read_bytes\r\n'
Server on port 2163 - STDERR: b"    return open(self.real_path, 'rb').read()\r\n"
Server on port 2163 - STDERR: b"IOError: [Errno 13] Permission denied: 'c:\\\\docume~1\\\\oscarl\\\\config~1\\\\temp\\\\tmpmt7hm7'\r\n"

Server on port 2163 - STDERR: b'SublimePythonIDE Server is called: completions\r\n'
Server on port 2163 - STDERR: b'Traceback (most recent call last):\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\server.py", line 134, in completions\r\n'
Server on port 2163 - STDERR: b'    project, source, loc, resource=resource, maxfixes=3)\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 33, in code_assist\r\n'
Server on port 2163 - STDERR: b'    return assist()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 335, in __call__\r\n'
Server on port 2163 - STDERR: b'    completions = list(self._code_completions().values())\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 403, in _code_completions\r\n'
Server on port 2163 - STDERR: b'    pymodule = fixer.get_pymodule()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\utils.py", line 10, in _wrapper\r\n'
Server on port 2163 - STDERR: b'    setattr(self, name, func(self, *args, **kwds))\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\fixsyntax.py", line 24, in get_pymodule\r\n'
Server on port 2163 - STDERR: b'    self.resource.read() == code:\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 81, in read\r\n'
Server on port 2163 - STDERR: b'    data = self.read_bytes()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 88, in read_bytes\r\n'
Server on port 2163 - STDERR: b"    return open(self.real_path, 'rb').read()\r\n"
Server on port 2163 - STDERR: b"IOError: [Errno 13] Permission denied: 'c:\\\\docume~1\\\\oscarl\\\\config~1\\\\temp\\\\tmpl3lr50'\r\n"

Server on port 2163 - STDERR: b'SublimePythonIDE Server is called: completions\r\n'
Server on port 2163 - STDERR: b'Traceback (most recent call last):\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\server.py", line 134, in completions\r\n'
Server on port 2163 - STDERR: b'    project, source, loc, resource=resource, maxfixes=3)\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 33, in code_assist\r\n'
Server on port 2163 - STDERR: b'    return assist()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 335, in __call__\r\n'
Server on port 2163 - STDERR: b'    completions = list(self._code_completions().values())\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 403, in _code_completions\r\n'
Server on port 2163 - STDERR: b'    pymodule = fixer.get_pymodule()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\utils.py", line 10, in _wrapper\r\n'
Server on port 2163 - STDERR: b'    setattr(self, name, func(self, *args, **kwds))\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\fixsyntax.py", line 24, in get_pymodule\r\n'
Server on port 2163 - STDERR: b'    self.resource.read() == code:\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 81, in read\r\n'
Server on port 2163 - STDERR: b'    data = self.read_bytes()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 88, in read_bytes\r\n'
Server on port 2163 - STDERR: b"    return open(self.real_path, 'rb').read()\r\n"
Server on port 2163 - STDERR: b"IOError: [Errno 13] Permission denied: 'c:\\\\docume~1\\\\oscarl\\\\config~1\\\\temp\\\\tmptin9y5'\r\n"

Server on port 2163 - STDERR: b'SublimePythonIDE Server is called: completions\r\n'
Server on port 2163 - STDERR: b'Traceback (most recent call last):\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\server.py", line 134, in completions\r\n'
Server on port 2163 - STDERR: b'    project, source, loc, resource=resource, maxfixes=3)\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 33, in code_assist\r\n'
Server on port 2163 - STDERR: b'    return assist()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 335, in __call__\r\n'
Server on port 2163 - STDERR: b'    completions = list(self._code_completions().values())\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 403, in _code_completions\r\n'
Server on port 2163 - STDERR: b'    pymodule = fixer.get_pymodule()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\utils.py", line 10, in _wrapper\r\n'
Server on port 2163 - STDERR: b'    setattr(self, name, func(self, *args, **kwds))\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\fixsyntax.py", line 24, in get_pymodule\r\n'
Server on port 2163 - STDERR: b'    self.resource.read() == code:\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 81, in read\r\n'
Server on port 2163 - STDERR: b'    data = self.read_bytes()\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\base\\resources.py", line 88, in read_bytes\r\n'
Server on port 2163 - STDERR: b"    return open(self.real_path, 'rb').read()\r\n"
Server on port 2163 - STDERR: b"IOError: [Errno 13] Permission denied: 'c:\\\\docume~1\\\\oscarl\\\\config~1\\\\temp\\\\tmpqzas3p'\r\n"

Server on port 2163 - STDERR: b'SublimePythonIDE Server is called: completions\r\n'
Server on port 2163 - STDERR: b'Traceback (most recent call last):\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\server.py", line 134, in completions\r\n'
Server on port 2163 - STDERR: b'    project, source, loc, resource=resource, maxfixes=3)\r\n'
Server on port 2163 - STDERR: b'  File "C:\\Sublime Text Build 3047\\Data\\Packages\\SublimePythonIDE\\server\\..\\lib\\python2\\rope\\contrib\\codeassist.py", line 33, in code_assist\r\n'
Server on port 2163 - STDERR: b'    return assist()\r\n'

I have managed to make it work by changing line number 90 of server.py, from this:

    tmpfile = tempfile.NamedTemporaryFile()

to this:

    tmpfile = tempfile.NamedTemporaryFile(delete=False)

(this was the default behavior in SublimeRope)

That means that the server won't automatically remove the temp files when shutting down (they keep pilling up on the user's %temp% folder), but at least works ok.

Maybe we should use delete=False if os.name == 'nt'?

JulianEberius commented 11 years ago

Hi,

I've created a new branch "tempfile_and_scratch_buffers" that reworks the scratch buffer handling and creation+deletion of tempfiles. If you find some time, please test it with WinXP, with scratch buffers (->temp files), single files on disk, and projects (dirs on disk).

Julian

OscarL commented 11 years ago

I've just tested the "tempfile_and_scratch_buffers" branch. Both with scratch buffers and with files on disk (from projects and independent files). It works OK, although the temp files are not being deleted from %temp% after closing ST and waiting for the servers to die.

That was kinda expected, as __del__ in Python cannot be trusted.

So. Yes, your code works on WinXP :-D Thanks for the fix!

JulianEberius commented 10 years ago

Is now in master branch, closing.