justinfx / MayaSublime

Send selected Python and MEL code snippets from SublimeText to Maya via commandPort
MIT License
149 stars 38 forks source link

Send to maya error Maya 2023 #43

Open PyrokinesisLtd opened 1 year ago

PyrokinesisLtd commented 1 year ago

Hi, I'm getting an error when sending code in Maya 2023

 # ----------------------------------------
# Exception occurred during processing of request from('127.0.0.1', 56180)
# Traceback (most recent call last):
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 747, in __init__
    self.handle()
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\site-packages\maya\app\general\CommandPort.py", line 134, in handle
    self.wfile.write(self.server.commandMessageQueue.get() + self.resp_term)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 826, in write
    self._sock.sendall(b)
# TypeError: a bytes-like object is required, not 'str'
# ----------------------------------------
justinfx commented 1 year ago

Hey. I haven't tested this plugin in a while so I can't yet confirm behavior in Maya 2023. But from your traceback it all looks like it's all happening within Maya's own socket server and commandport code. I see that it's trying to reply back to the remote client with a response and seems to be sending a string value instead of bytes.

Is there any other related exception that references the MayaSublime plugin code? The error kind of seems related to Maya's python3 env. Is that the case? I may not have ever tested things since Maya started using py3.

justinfx commented 1 year ago

Ok I have just tested Maya 2023.1 on linux and it seems to be working, with SublimeText 3.2.2. Could you confirm your SublimeText version and also provide a sample of code that could produce the crash?

PyrokinesisLtd commented 1 year ago

Hey Justin, Seems to happen for me with all versions of sublime on Windows. I am now using Build 4126.

Like I said, still errors with all versions though :(

New Error

# Exception occurred during processing of request from # Traceback (most recent call last):
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\socketserver.py", line 747, in __init__
    self.handle()
# #   File "C:\Program Files\Autodesk\Maya2023\Python\lib\site-packages\maya\app\general\CommandPort.py", line 134, in handle
    self.wfile.write(self.server.commandMessageQueue.get() + self.resp_term)
justinfx commented 1 year ago

I've just tested this again on Linux using Sublime Build 4126 and Maya 2023.1, but I was not able to reproduce the error. This makes me wonder if its even related to Sublime at all and maybe just an issue with the configuration of your commandPort. If you have a telnet client on windows (PuTTY? or WSL?) I would suggest testing something like this:

# start a connection to your local Maya python commandPort
telnet localhost 7002

# run a python command
cmds.ls()

You could also try closing and opening the commandPort again, from a script editor

cmds.commandPort(name=":7002", close=True)
cmds.commandPort(name=":7002", sourceType="python")

The thing that is standing out to me about your errors is that they are not coming from MayaSublime code at all. They are in Maya's own command port socket handler, where it seems to be trying to send back a string type instead of a bytes type. That is a kind of error that happens during a port from python2 to python3. So I am not sure if maybe you had a command port configured differently than mine.