Try to use os.mkfifo() --- currently not implemented by Jython

Asked by Michael A. Phillips

Using some python n00b knowledge, I suspect you have to create a named pipe to pass to something like gnome-terminal as arguments and not to the binary app itself:

http://stackoverflow.com/questions/5558720/using-pythons-subprocess-to-display-output-in-new-xterm-window

I get the error, " os.mkfifo(PIPE_PATH) AttributeError: 'module' object has no attribute 'mkfifo'"

I am using variables and loops, which greatly complicate my code.

for TIME in TIMEFILE:
    Popen(['gnome-terminal', '--title=MIKE', '--geometry=50x12', '-x', '/usr/local/bin/mike.sh', TIME, 'otherargs', PIPE_PATH])

Using Sikuli X-1.0rc2 on Ubuntu 10.04

Thanks!

Mike

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

The use of Popen is not the problem, you forgot to mention the usage of os.mkfifo() before, to try to open a pipe.

The Jython module os does not contain an implementation of mkfifo despite the fact, that it is mentioned in the docs to be available on Unix (but this might be because the Jython docs are copies of the Python docs in the first place and revised later).
This is valid both for Jython 2.5.1 (Sikuli X rc2) and Jython 2.5.2 (Sikuli X rc3). Even in their bug list nothing is mentioned about it.

So, sorry, this is currently not possible using a pipe.

You have to setup a protocol based on a real file.

Revision history for this message
Michael A. Phillips (maphilli14) said :
#2

Raimud, somehow I knew you'd be the best authority! Thanks for the answer. By 'protocol based on a real file' do you mean, not a named pipe? I may continue to call my old bash scripts in the meantime. Is it worth cleanup of the docs or notifying those that maintain them that those functions are not implemented in jython?

Thanks!

Mike

Revision history for this message
Michael A. Phillips (maphilli14) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

--- protocol based on a real file
no, pipes seem not to be supported at all currently (besides the ones in the Popen() calls).
e.g. a one way pipe: You might write in a file at the one side, if it has size 0. on the other side wait until it has a size > 0 and ends with a certain string. Then read it and reset it to size 0.
This is some primitive private protocol, that should work, since you know, what you are doing.

only an idea, I do not know, whether this fits to you requirements.

--- jython missing mkfifo()
I will check it again in the Jython boards the next days and decide what to do (at least the docs should have a comment).
What I indeed found: some modules or python packages check whether mkfifo() is available. So using mkfifo() seems to be a general "risk".