pyblish / pyblish-nuke

Pyblish for Nuke
GNU Lesser General Public License v3.0
9 stars 12 forks source link

nuke_integration on OSX #25

Open linez69 opened 8 years ago

linez69 commented 8 years ago

When I try pyblish_nuke.setup() on OSX, I get this.

# Result: pyblish_nuke.setup()
# Result: Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_nuke/lib.py", line 40, in setup
    pyblish_integration.setup(console=console, port=port)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_integration/lib.py", line 99, in setup
    self.port = self.proxy.find_available_port(*args)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
    return u.close()
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.IOError'>:[Errno 32] Broken pipe">
Exception in thread server:
Traceback (most recent call last):
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_integration/lib.py", line 136, in server
    self.server = pyblish_rpc.server.start_production_server(port)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 122, in start_production_server
    return _serve(port, service)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 108, in _serve
    server = _server(port, service)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 93, in _server
    logRequests=False)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 65, in __init__
    **kwargs)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SimpleXMLRPCServer.py", line 593, in __init__
    SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 408, in __init__
    self.server_bind()
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 419, in server_bind
    self.socket.bind(self.server_address)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
TypeError: an integer is required
linez69 commented 8 years ago

On my new mac-box the nuke_integration is working: pyblish: Integration loaded.. Listening on 127.0.0.1:9001.

mottosso commented 8 years ago

Did you modify your distribution somehow?

linez69 commented 8 years ago

No, but now I discovered, it's only, when pyblish isn't running. when it's running, pyblish_nuke.setup() gives me this:

 Result: Exception in thread server:
Traceback (most recent call last):
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_integration/lib.py", line 136, in server
    self.server = pyblish_rpc.server.start_production_server(port)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 122, in start_production_server
    return _serve(port, service)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 108, in _serve
    server = _server(port, service)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 93, in _server
    logRequests=False)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_rpc/server.py", line 65, in __init__
    **kwargs)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SimpleXMLRPCServer.py", line 593, in __init__
    SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 408, in __init__
    self.server_bind()
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 419, in server_bind
    self.socket.bind(self.server_address)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 48] Address already in use

ERROR    | Time:  04:48:13.0634 | nhbPipeline.src.nuke.connect.menu - NhbMenuConnect | Line: 137 name: handleException  |Unhandled exception occurred!
Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_nuke/lib.py", line 40, in setup
    pyblish_integration.setup(console=console, port=port)

  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_integration/lib.py", line 99, in setup
    self.port = self.proxy.find_available_port(*args)

  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)

  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose

  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)

  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)

  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
    return u.close()

  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])

Fault: <Fault 1: "<class 'psutil.AccessDenied'>:psutil.AccessDenied (pid=349)">
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_nuke/lib.py", line 40, in setup
    pyblish_integration.setup(console=console, port=port)
  File "/Volumes/Repository/python_globals/sitepackages_pyblish_1.3.2_osx/pyblish/pythonpath/pyblish_integration/lib.py", line 99, in setup
    self.port = self.proxy.find_available_port(*args)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
    return u.close()
  File "/Applications/Nuke9.0v8/Nuke9.0v8.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
Fault: <Fault 1: "<class 'psutil.AccessDenied'>:psutil.AccessDenied (pid=349)">
mottosso commented 8 years ago

Could you wrap code and console output in a ```-fence, please?

mottosso commented 8 years ago

This can happen if you launch two Nuke sessions, but there is no Pyblish QML running.

Pyblish QML normally distributes available ports, and if there is none around, each Nuke session will attempt to step on each others toes.

linez69 commented 8 years ago

ah, wait, I think, it's working.

linez69 commented 8 years ago

ok, so if I first do pyblish_nuke.setup() then start the server from a shell then pyblish_nuke.show(), I can work with it. Do you think it's possible to catch that error, when the server is already running? Then I could start the server when launching nuke and pyblish_nuke.show(), when I want to publish something.

But so cool, that it's finally working at all. Many, many thanks!

mottosso commented 8 years ago

Yes, you can try and connect to it, and handle what happens if it isn't there.

Sorry, can't test this at the moment, but something along these lines. If you have corrections, let me know so I can update the snippet.

import os
import socket
from pyblish_qml import settings, client

port = os.getenv("PYBLISH_CLIENT_PORT")
proxy = client.proxy()
settings = settings.to_dict()

try:
    proxy.show(port, settings)
except (socket.error, socket.timeout):
    print("No answer, what to do?")

But the recommended workflow is for Pyblish QML to launch at startup of your machine. It normally takes a few seconds to launch.

linez69 commented 8 years ago

No, I think, the problem is, that pyblish_nuke.setup() is trying to start a pyblish-server on it's own. But since the pyblish_shell-server is already running, it can't, and when I try pyblish_nuke.show(), it says Integration not initialised correctly. So it would be good, if it just wouldn't try to start another server.

Don't know, if what you wrote is the same, but I don't know, where to put your snippet

mottosso commented 8 years ago

Ah, interesting.

It should already be checking if there is one. Smells like a bug. I'll take a closer look soon, unless @tokejepsen beats me to it.

linez69 commented 8 years ago

Hey, have you had a chance to look into that already? :-)

mottosso commented 8 years ago

I have not, but I'll bump it up the list for tonight. :)

Were you able to work around it so far? What have you tried?

linez69 commented 8 years ago

Right now, I'm doing pyblish_nuke.setup() before I start pyblish_qml. Then I start pyblish_qml in a shell Then I do pyblish_nuke.show(). That works. But it would be nice to start pyblish_nuke.setup() with a qml already running.