diff options
author | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2011-05-05 03:14:14 +0000 |
---|---|---|
committer | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2011-05-05 03:14:14 +0000 |
commit | ad1f20696798a98eae0255fc7f1b6a275beac6f3 (patch) | |
tree | 877a57bb41310f7987f0a8e9fc07015cddc56f4e /client | |
parent | c5f21e98e7ba36843d90b707a7b5de6038247f17 (diff) |
Utils: Moving function ask to common lib utils
This way we can use it in other interactive scripts in autotest.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@5350 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'client')
-rw-r--r-- | client/common_lib/base_utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/client/common_lib/base_utils.py b/client/common_lib/base_utils.py index c8f2f1af..db7b8698 100644 --- a/client/common_lib/base_utils.py +++ b/client/common_lib/base_utils.py @@ -1715,3 +1715,17 @@ def get_unused_port(): # Check if this port is unused on the other protocol. if port and try_bind(port, socket.SOCK_DGRAM, socket.IPPROTO_UDP): return port + + +def ask(question, auto=False): + """ + Raw input with a prompt that emulates logging. + + @param question: Question to be asked + @param auto: Whether to return "y" instead of asking the question + """ + if auto: + logging.info("%s (y/n) y" % question) + return "y" + return raw_input("%s INFO | %s (y/n) " % + (time.strftime("%H:%M:%S", time.localtime()), question)) |