remi-daigle / MarxanConnect

Marxan Connect
http://marxanconnect.ca/
MIT License
13 stars 5 forks source link

macOS Marxan feedback #58

Open remi-daigle opened 5 years ago

remi-daigle commented 5 years ago

Description

Marxan Connect is currently 'frozen' when it runs Marxan on macOS and doesn't provide any text output until it's done because I haven't found a way to call the Marxan executable in a new terminal as I do in Windows.

On Windows:

subprocess.call(os.path.join(marxanpath, 'Marxan243', marxan_exec) + ' ' +
                            self.project['filepaths']['marxan_input'],
                            creationflags=subprocess.CREATE_NEW_CONSOLE,
                            cwd=inputpath)

but subprocess.CREATE_NEW_CONSOLE is not compatible with macOS, so I've had to find an alternative.

Currently, on macOS:

proc = pexpect.spawnu(os.path.join(marxanpath, 'Marxan243', marxan_exec)+' '+os.path.relpath(self.project['filepaths']['marxan_input'],inputpath),cwd=inputpath)
            proc.logfile = sys.stdout
            proc.expect('.*Press return to exit.*')
            proc.close()

This does run the Marxan executable with the correct input.dat file but only provides output AFTER it's done all the replicates. It does update normally when running from python with no output redirection (i.e. self.log = LogForm(parent=self)) but then GUI users get no output at all.

I have spent a few days troubleshooting this and the current solution is the best I can come up with, but I'm fully willing to explore this again if someone has bright ideas!