[opensuse-buildservice] [PATCH0/0] raw_input checks if stdin is tty
Hi community, The biggest problem during usage and testing of a remote build feature is the fact osc asks user several times for the input. In this case, remote process simply hangs and waits for the response, which is not even displayed, because of stdout buffering. The samy apply for non-interactive usage - if osc is called from a script, then it hangs waiting on something on stdin, which will never come. Therefor I've added a simple check os.isatty(sys.stdin.fileno()) to the osc.core.raw_input() - in case it's not terminal, the new RawInputError is raised. It will show-up the question on stderr and program will be terminated. I'd say there is some non-interactive osc feature requested by L3 team, which can be partially solved by this patch @milan, can you follow up? BTW: I've added the osc.core.raw_input to oscssl.py and build.py as well, to enforce the new behavior. The cmdln.py remains untouched, because I was not sure if this code is even used by osc. Michal Vyskocil (1): raw_input checks if stdin is tty osc/build.py | 1 + osc/core.py | 2 ++ osc/oscerr.py | 8 ++++++++ osc/oscssl.py | 2 ++ 4 files changed, 13 insertions(+) -- 1.7.10.4
On Wed, Oct 31, 2012 at 11:21:41AM +0100, Michal Vyskocil wrote:
Hi community,
Hallo, I has been asked by mvancura to not change the behavior, as they handle the stdin from their scripts. This has to be revorked somehow ... Regards Michal Vyskocil
The biggest problem during usage and testing of a remote build feature is the fact osc asks user several times for the input. In this case, remote process simply hangs and waits for the response, which is not even displayed, because of stdout buffering. The samy apply for non-interactive usage - if osc is called from a script, then it hangs waiting on something on stdin, which will never come.
Therefor I've added a simple check os.isatty(sys.stdin.fileno()) to the osc.core.raw_input() - in case it's not terminal, the new RawInputError is raised. It will show-up the question on stderr and program will be terminated.
I'd say there is some non-interactive osc feature requested by L3 team, which can be partially solved by this patch @milan, can you follow up?
BTW: I've added the osc.core.raw_input to oscssl.py and build.py as well, to enforce the new behavior. The cmdln.py remains untouched, because I was not sure if this code is even used by osc.
Michal Vyskocil (1): raw_input checks if stdin is tty
osc/build.py | 1 + osc/core.py | 2 ++ osc/oscerr.py | 8 ++++++++ osc/oscssl.py | 2 ++ 4 files changed, 13 insertions(+)
-- 1.7.10.4
On Fri, Nov 02, 2012 at 10:10:15AM +0100, Michal Vyskocil wrote:
On Wed, Oct 31, 2012 at 11:21:41AM +0100, Michal Vyskocil wrote:
Hi community,
Hallo,
I has been asked by mvancura to not change the behavior, as they handle the stdin from their scripts.
This has to be revorked somehow ...
BTW: what is a bit strange to me is the fact, Python's raw_input already tests it http://hg.python.org/cpython/file/466cbfb3c0c6/Python/bltinmodule.c#l2039 if (PyFile_AsFile(fin) && PyFile_AsFile(fout) && isatty(fileno(PyFile_AsFile(fin))) && isatty(fileno(PyFile_AsFile(fout)))) { Regards Michal Vyskocil
Hi Michal, On 2012-10-31 11:21:41 +0100, Michal Vyskocil wrote:
The biggest problem during usage and testing of a remote build feature is the fact osc asks user several times for the input. In this case, remote process simply hangs and waits for the response, which is not even displayed, because of stdout buffering.
In this case ssh should be invoked with the "-t" parameter.
The samy apply for non-interactive usage - if osc is called from a script, then it hangs waiting on something on stdin, which will never come.
Therefor I've added a simple check os.isatty(sys.stdin.fileno()) to the osc.core.raw_input() - in case it's not terminal, the new RawInputError is raised. It will show-up the question on stderr and program will be terminated.
We could add something like a "--script-mode" (config) option. If "osc --script-mode <cmd>" is invoked and <cmd> requires a user input an exception is raised. What do you think?
I'd say there is some non-interactive osc feature requested by L3 team, which can be partially solved by this patch @milan, can you follow up?
BTW: I've added the osc.core.raw_input to oscssl.py and build.py as well, to enforce the new behavior. The cmdln.py remains untouched, because I was not sure if this code is even used by osc.
The codepath in cmdln.py which uses the "raw_input" call isn't executed by osc. Marcus -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-buildservice+owner@opensuse.org
On Sun, Nov 04, 2012 at 10:28:41PM +0100, Marcus Hüwe wrote:
Hi Michal,
On 2012-10-31 11:21:41 +0100, Michal Vyskocil wrote:
The biggest problem during usage and testing of a remote build feature is the fact osc asks user several times for the input. In this case, remote process simply hangs and waits for the response, which is not even displayed, because of stdout buffering.
In this case ssh should be invoked with the "-t" parameter.
Corret, I'll update my --host patch instead
The samy apply for non-interactive usage - if osc is called from a script, then it hangs waiting on something on stdin, which will never come.
Therefor I've added a simple check os.isatty(sys.stdin.fileno()) to the osc.core.raw_input() - in case it's not terminal, the new RawInputError is raised. It will show-up the question on stderr and program will be terminated.
We could add something like a "--script-mode" (config) option. If "osc --script-mode <cmd>" is invoked and <cmd> requires a user input an exception is raised.
What do you think?
To be honest, I'd not invest a lot of effort in osc (1.x). Having a reliable scripting mode (IOW not wait on stdin, provide reasonalbe return codes, ...) can be a nice enhancenment of osc2, can't it? Regards Michal Vyskocil
participants (2)
-
Marcus Hüwe
-
Michal Vyskocil