Skip to content

Commit

Permalink
Merge pull request #10 from Altran-PT-GDC/change_wait_time_after_write
Browse files Browse the repository at this point in the history
Change wait time after write
  • Loading branch information
samuelpcabral committed Mar 14, 2019
2 parents bdbd08a + 7d60d7f commit 86ef9ce
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 19 deletions.
2 changes: 1 addition & 1 deletion __init__.py
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
from .source.x3270 import x3270

__version__ = "2.5"
__version__ = "2.6"

class Mainframe3270(x3270):
"""Mainframe3270 is a library for Robot Framework based on [https://pypi.org/project/py3270/|py3270 project],
Expand Down
37 changes: 30 additions & 7 deletions doc/Mainframe3270.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<keywordspec generated="20190228 16:53:58" type="library" name="Mainframe3270" format="ROBOT">
<version>2.5</version>
<keywordspec generated="20190314 16:58:13" type="library" name="Mainframe3270" format="ROBOT">
<version>2.6</version>
<scope>global</scope>
<namedargs>yes</namedargs>
<doc>Mainframe3270 is a library for Robot Framework based on [https://pypi.org/project/py3270/|py3270 project],
Expand Down Expand Up @@ -38,6 +38,7 @@ but is you set the visible to false, the py3270 will run the ws3270.exe.
<arg>visible=True</arg>
<arg>timeout=30</arg>
<arg>wait_time=0.5</arg>
<arg>wait_time_after_write=0</arg>
<arg>img_folder=.</arg>
</arguments>
<doc>You can change to hide the emulator screen set the argument visible=${False}
Expand All @@ -59,9 +60,8 @@ see the `Set Screenshot Folder` and to change the timeout see the `Change Timeou
<arguments>
<arg>wait_time</arg>
</arguments>
<doc>To give time for the mainframe screen to be "drawn" and receive the
next commands, a "wait time" has been created which by default is set to
0.5 seconds. This is a sleep applied after the follow keywords:
<doc>To give time for the mainframe screen to be "drawn" and receive the next commands, a "wait time" has been
created, which by default is set to 0.5 seconds. This is a sleep applied AFTER the follow keywords:

`Execute Command`
`Send Enter`
Expand All @@ -72,11 +72,34 @@ next commands, a "wait time" has been created which by default is set to
If you want to change this value just use this keyword passing the time in seconds.

Examples:
| Change Wait Time | 0.5 |
| Change Wait Time | 0.1 |
| Change Wait Time | 2 |</doc>
<tags>
</tags>
</kw>
<kw name="Change Wait Time After Write">
<arguments>
<arg>wait_time_after_write</arg>
</arguments>
<doc>To give the user time to see what is happening inside the mainframe, a "change wait time after write" has
been created, which by default is set to 0 seconds. This is a sleep applied AFTER the string sent in this
keywords:

`Write`
`Write Bare`
`Write in position`
`Write Bare in position`

If you want to change this value just use this keyword passing the time in seconds.

Note: This keyword is useful for debug purpose

Examples:
| Change Wait Time After Write | 0.5 |
| Change Wait Time After Write | 2 |</doc>
<tags>
</tags>
</kw>
<kw name="Close Connection">
<arguments>
</arguments>
Expand Down Expand Up @@ -154,7 +177,7 @@ Examples:
<arg>port=23</arg>
</arguments>
<doc>Create a connection with IBM3270 mainframe with the default port 23. To make a connection with the mainframe
you only must inform the Host. You can pass the Logical Unit Name and the Port as opcional.
you only must inform the Host. You can pass the Logical Unit Name and the Port as optional.

Example:
| Open Connection | Hostname |
Expand Down
2 changes: 1 addition & 1 deletion doc/documentation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/__init__.py
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
from .x3270 import x3270

__version__ = "2.5"
__version__ = "2.6"


class Mainframe3270(x3270):
Expand Down
38 changes: 29 additions & 9 deletions source/x3270.py
Expand Up @@ -10,7 +10,7 @@


class x3270(object):
def __init__(self, visible=True, timeout='30', wait_time='0.5', img_folder='.'):
def __init__(self, visible=True, timeout='30', wait_time='0.5', wait_time_after_write='0', img_folder='.'):
"""You can change to hide the emulator screen set the argument visible=${False}
For change the wait_time see `Change Wait Time`, to change the img_folder
Expand All @@ -28,17 +28,18 @@ def __init__(self, visible=True, timeout='30', wait_time='0.5', img_folder='.'):
if hasattr(e, 'message') and e.message == 'Cannot access execution context': self.output_folder = os.getcwd()
else: raise AssertionError(e)
self.wait = float(wait_time)
self.wait_write = float(wait_time_after_write)
self.timeout = int(timeout)
self.mf = Emulator(visible=bool(visible), timeout=int(timeout))

def change_timeout(self, seconds):
"""Change the timeout for connection in seconds.
"""
self.timeout = int(seconds)
self.timeout = float(seconds)

def open_connection(self, host, LU=None, port=23):
"""Create a connection with IBM3270 mainframe with the default port 23. To make a connection with the mainframe
you only must inform the Host. You can pass the Logical Unit Name and the Port as opcional.
you only must inform the Host. You can pass the Logical Unit Name and the Port as optional.
Example:
| Open Connection | Hostname |
Expand All @@ -63,9 +64,8 @@ def close_connection(self):
pass

def change_wait_time(self, wait_time):
"""To give time for the mainframe screen to be "drawn" and receive the
next commands, a "wait time" has been created which by default is set to
0.5 seconds. This is a sleep applied after the follow keywords:
"""To give time for the mainframe screen to be "drawn" and receive the next commands, a "wait time" has been
created, which by default is set to 0.5 seconds. This is a sleep applied AFTER the follow keywords:
`Execute Command`
`Send Enter`
Expand All @@ -76,11 +76,31 @@ def change_wait_time(self, wait_time):
If you want to change this value just use this keyword passing the time in seconds.
Examples:
| Change Wait Time | 0.5 |
| Change Wait Time | 0.1 |
| Change Wait Time | 2 |
"""
self.wait = float(wait_time)

def change_wait_time_after_write(self, wait_time_after_write):
"""To give the user time to see what is happening inside the mainframe, a "change wait time after write" has
been created, which by default is set to 0 seconds. This is a sleep applied AFTER the string sent in this
keywords:
`Write`
`Write Bare`
`Write in position`
`Write Bare in position`
If you want to change this value just use this keyword passing the time in seconds.
Note: This keyword is useful for debug purpose
Examples:
| Change Wait Time After Write | 0.5 |
| Change Wait Time After Write | 2 |
"""
self.wait_write = float(wait_time_after_write)

def read(self, ypos, xpos, length):
"""Get a string of "length" at screen co-ordinates "ypos"/"xpos".
Expand Down Expand Up @@ -234,7 +254,6 @@ def write_in_position(self, txt, ypos, xpos):
Example:
| Write in Position | something | 9 | 11 |
"""
self._check_limits(ypos, xpos)
self._write(txt, ypos=ypos, xpos=xpos, enter='1')

def write_bare_in_position(self, txt, ypos, xpos):
Expand All @@ -246,15 +265,16 @@ def write_bare_in_position(self, txt, ypos, xpos):
Example:
| Write Bare in Position | something | 9 | 11 |
"""
self._check_limits(ypos, xpos)
self._write(txt, ypos=ypos, xpos=xpos)

def _write(self, txt, ypos=None, xpos=None, enter='0'):
txt = txt.encode('utf-8')
if ypos is not None and xpos is not None:
self._check_limits(int(ypos), int(xpos))
self.mf.move_to(int(ypos), int(xpos))
if not isinstance(txt, (list, tuple)): txt = [txt]
[self.mf.send_string(el) for el in txt if el != '']
time.sleep(self.wait_write)
for i in range(int(enter)):
self.mf.send_enter()
time.sleep(self.wait)
Expand Down

0 comments on commit 86ef9ce

Please sign in to comment.