4

I'm using Python 2.7.3 on recently installed macOS 10.14 (Mojave). The code is running within Nuke by Foundry.

a=nuke.selectedNode()
b=a['file'].value()
#b now has path to some file
u=os.path.split(b) [0]
u = os.path.normpath (u)
if u != ".":
    subprocess.Popen(['open', '-R', '%s' % (u)])

What I'm trying to do is open Finder window where file is located. With previous version of macOS it would open Finder instantly. With latest upgrade it take 30-60 seconds to open (sometime it does not even work).

Any help please. Thank you.

KLB
  • 45
  • 5
  • I am having a rather similar issue with Emacs on macOS Mojave. It seems to have something to do with opening subprocesses. I've noticed similar phenomena with other apps, too. I'd suggest that you report this to Apple, since it seems to be a bug on their part. – GDP2 Feb 04 '19 at 23:28

1 Answers1

1

After a thorough investigation I’ve found out that such a delay in opening a system directory with a command sent from NUKE 11.3v4 Script Editor in macOS Mojave 10.14.5 using a subprocess.Popen() class, is neither a macOS issue nor Python’s issue itself. I tried to call not only a subprocess.Popen() class with a System Integrity Protection enabled in Mojave or when SIP was disabled (see here how to enable and disable SIP), but also I tried such the deprecated methods as os.popen() and commands.getoutput().



For this test I used the following code:



import nuke
from os import name, popen
from sys import platform
from subprocess import Popen
from os.path import abspath, join, dirname
from commands import getoutput

n = nuke.toNode('Read1')['file'].value()

if name == 'posix' and platform == 'darwin':
    path = abspath(join(dirname(n)))
    command = "open %s" % path

    if path is not ".":
        # commands.getoutput() method is deprecated since Python 2.6 
        # But it's still working in Python 2.7...
        ''' It takes 21 second to open a directory using getoutput() '''
        getoutput(command)

        # os.popen() method is deprecated since Python 2.6 
        # But it's still working in Python 2.7...
        ''' It takes 21 second to open a directory using popen() '''
        popen(command)

        # subprocess.Popen() class is a working horse now...
        ''' It takes 21 second to open a directory using Popen() '''
        Popen(command, shell=True)



No matter what system method or class I used in Mojave, it took 21 seconds (I work on MBP 15” 2017) to open a desired folder with open command.



So, I could conclude that this drawback came from The Foundry developers. I suppose in future release of NUKE 12 for macOS 10.15 Catalina they adapt these methods much better.

Also, you can find all the Python methods and classes what you can use from NUKE in /Applications/Nuke11.3v4/Nuke11.3v4.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

Zoe
  • 27,060
  • 21
  • 118
  • 148
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220