From 016a674bf79676a2aabda9164fde2a3d94bd839d Mon Sep 17 00:00:00 2001 From: Benedek Racz Date: Tue, 24 Sep 2019 15:00:14 +0200 Subject: [PATCH] [ADD] issues folder for active issues --- issues/README.md | 1 + issues/bla.py | 11 ++++++++++ issues/bla2.py | 24 ++++++++++++++++++++++ issues/i09_cmd_error.py | 37 ++++++++++++++++++++++++++++++++++ issues/i09_py_sim_no_error.py | 33 ++++++++++++++++++++++++++++++ issues/i09_py_sim_no_error2.py | 37 ++++++++++++++++++++++++++++++++++ wexpect.py | 27 ++++++++++++++----------- 7 files changed, 158 insertions(+), 12 deletions(-) create mode 100644 issues/README.md create mode 100644 issues/bla.py create mode 100644 issues/bla2.py create mode 100644 issues/i09_cmd_error.py create mode 100644 issues/i09_py_sim_no_error.py create mode 100644 issues/i09_py_sim_no_error2.py diff --git a/issues/README.md b/issues/README.md new file mode 100644 index 0000000..b8d5127 --- /dev/null +++ b/issues/README.md @@ -0,0 +1 @@ +issues folder contains scripts to help to reproduce a given issue diff --git a/issues/bla.py b/issues/bla.py new file mode 100644 index 0000000..9fa25b4 --- /dev/null +++ b/issues/bla.py @@ -0,0 +1,11 @@ +import time + +# Wait the given time +for i in range(2): + print('apple\tbanana\tmelone\tcherry') + print('pepper tomato\tcorn cabbage') + print('apple banana\tmelone\tcherry2') + print('pepper tomato\tcorn cabbage2') + print('prompt> ') + time.sleep(0.5) + diff --git a/issues/bla2.py b/issues/bla2.py new file mode 100644 index 0000000..abbab5d --- /dev/null +++ b/issues/bla2.py @@ -0,0 +1,24 @@ +''' +This is is a very basic stdio handler script. This is used by python.py example. +''' + +import time + + +print('Welcome!') + +while True: + print('>', end='') + cmd = input() + + # Wait the given time + if cmd == 'ls': + print('apple\tbanana\tmelone\tcherry') + print('pepper tomato\tcorn cabbage') + print('apple banana\tmelone\tcherry2') + print('pepper tomato\tcorn cabbage2') + continue + if cmd == 'exit': + break + else: + print('unknown command') \ No newline at end of file diff --git a/issues/i09_cmd_error.py b/issues/i09_cmd_error.py new file mode 100644 index 0000000..851eb14 --- /dev/null +++ b/issues/i09_cmd_error.py @@ -0,0 +1,37 @@ + +import wexpect +import time + +print(wexpect.__version__) + + +def testPath(): + # Path of cmd executable: + cmdPath = 'cmd' + cmdPrompt = '>' + referenceOut = None + + while True: + # Start the child process + p = wexpect.spawn(cmdPath) + + # Wait for prompt + p.expect(cmdPrompt) + + # Send a command + p.sendline('ls') + # time.sleep(0.6) + p.expect(cmdPrompt) + + + print(cmdPath + " >>" + p.before + '<<') + if referenceOut: + if referenceOut != p.before: + p.interact() + time.sleep(5) + raise Exception() + else: + referenceOut = p.before + +testPath() + diff --git a/issues/i09_py_sim_no_error.py b/issues/i09_py_sim_no_error.py new file mode 100644 index 0000000..9e0b046 --- /dev/null +++ b/issues/i09_py_sim_no_error.py @@ -0,0 +1,33 @@ + +import wexpect +import time + +print(wexpect.__version__) + + +def testPath(): + # Path of cmd executable: + cmdPath = 'python bugfix\\bla.py' + cmdPrompt = '> ' + referenceOut = None + + while True: + # Start the child process + p = wexpect.spawn(cmdPath) + + # Wait for prompt + p.expect(cmdPrompt) + # Wait for prompt + p.expect(cmdPrompt) + + print(cmdPath + " >>" + p.before + '<<') + if referenceOut: + if referenceOut != p.before: + p.interact() + time.sleep(5) + raise Exception() + else: + referenceOut = p.before + +testPath() + diff --git a/issues/i09_py_sim_no_error2.py b/issues/i09_py_sim_no_error2.py new file mode 100644 index 0000000..8aaaf11 --- /dev/null +++ b/issues/i09_py_sim_no_error2.py @@ -0,0 +1,37 @@ + +import wexpect +import time + +print(wexpect.__version__) + + +def testPath(): + # Path of cmd executable: + cmdPath = 'python bugfix\\bla2.py' + cmdPrompt = '>' + referenceOut = None + + while True: + # Start the child process + p = wexpect.spawn(cmdPath) + + # Wait for prompt + p.expect(cmdPrompt) + + # Send a command + p.sendline('ls') + # time.sleep(0.6) + p.expect(cmdPrompt) + + + print(cmdPath + " >>" + p.before + '<<') + if referenceOut: + if referenceOut != p.before: + p.interact() + time.sleep(5) + raise Exception() + else: + referenceOut = p.before + +testPath() + diff --git a/wexpect.py b/wexpect.py index d6691c2..55a220a 100644 --- a/wexpect.py +++ b/wexpect.py @@ -110,12 +110,26 @@ except ImportError as e: screenbufferfillchar = '\4' maxconsoleY = 8000 + +# The version is handled by the package: pbr, which derives the version from the git tags. +try: + __version__ = pkg_resources.require("wexpect")[0].version +except: + __version__ = '0.0.1.unkowndev0' +__revision__ = '$Revision: 399 $' + +__all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'which', + 'split_command_line', '__version__', '__revision__'] + # # Create logger: We write logs only to file. Printing out logs are dangerous, because of the deep # console manipulation. # logger = logging.getLogger('wexpect') -logger.setLevel(logging.DEBUG) +if 'dev' in __version__ : + logger.setLevel(logging.DEBUG) +else: + logger.setLevel(logging.INFO) fh = logging.FileHandler('wexpect.log') formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) @@ -124,17 +138,6 @@ logger.addHandler(fh) # Test the logger logger.info('wexpect imported; logger working') -# The version is handled by the package: pbr, which derives the version from the git tags. -try: - __version__ = pkg_resources.require("wexpect")[0].version -except: - __version__ = '0.0.1.unkown0' -__revision__ = '$Revision: 399 $' - -__all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'which', - 'split_command_line', '__version__', '__revision__'] - - #################################################################################################### # # Exceptions