Subprocess and 16-bit FORTRAN

F

Federico Ceccatto

Hello,

For the past year I've been building an XP Python/wxPython shell of
sorts for several dozen command line FORTRAN tools developed for
various material science problems. Given how the methods and how-to's
have been lost to everyone but the original creators for these 80's to
90's pieces of code and the fact I am no physicist, I've relied on the
subprocess module in order to feed info according to their output.

I/O in general has worked wonders up to a handful of applications that
act in the strangest of ways. I strongly believe it's a bug in the
original programs/compiler, but that gets me nowhere. There's also the
fact the error shows up in two tools compiled with different FORTRAN
versions and made by different authors. I'll probably go cry for help
in a FORTRAN forum too.

Can't quite paste code due to its size and threaded nature, but
basically I have the output PIPE rigged to a class that parses text
into a tidy list (for easier analyzing), and a function that returns
input characters to the stdin method of the subprocess object
according to wether there has been any new data from stdout and
certain conditions (specific to the executable) are met.

I've got prints and repr()s everywhere to check nothing is ignored,
written multiple times or the child process is reporting errors. As I
mentioned, it works wonders for several other executables. None of the
obvious errors seem to be the case. As far as I can tell, the
input/output is ideal until the misbehaviour described below rears its
ugly head.

This is the kind of 'bugs' i've run into, perhaps someone could shed
some light onto them?

- Sometimes execution of child process (in this case, NTVDM.exe and
its children) stops and the object is destroyed for no reason
whatsoever. Very silent, no errors.

- Sometimes '\x03' as input is ignored, working simply as a '\n' of
sorts, while most of the time it simply kills the program as expected.

- Sometimes specific points in the code where the user is asked for
input and execution should be temporarily halted are ignored, as if
somehow it got a newline character.

None of these bugs are reproducible by running the same child
processess via NTVDM.exe through say, cmd.exe and such.

This has been driving me nuts for the last three weeks...

Thanks for your time.

- F.
 
N

Nick Craig-Wood

Federico Ceccatto said:
This is the kind of 'bugs' i've run into, perhaps someone could shed
some light onto them?

- Sometimes execution of child process (in this case, NTVDM.exe and
its children) stops and the object is destroyed for no reason
whatsoever. Very silent, no errors.

- Sometimes '\x03' as input is ignored, working simply as a '\n' of
sorts, while most of the time it simply kills the program as expected.

- Sometimes specific points in the code where the user is asked for
input and execution should be temporarily halted are ignored, as if
somehow it got a newline character.

None of these bugs are reproducible by running the same child
processess via NTVDM.exe through say, cmd.exe and such.

This has been driving me nuts for the last three weeks...

It sounds like you want an interactive channel to your process -
unfortunately subprocess doesn't really work when a conversation is
expected between your process and the subprocess - there is too much
buffering involved.

On unix you'd use the python expect module to work around these
problems. Unfortunately there isn't a windows version :-(

You could try the non blocking subprocess modification here

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

You could also try wx.Process and wx.Execute from wxPython.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top