The stdin buffer problem in the py3270

210 views
Skip to first unread message

Aiden Luo

unread,
Jul 25, 2013, 1:35:41 AM7/25/13
to blaz...@googlegroups.com
Hi Randy,

I create a project based on the py3270 package, but I found some problem in the py3270.
Example:
================================================
>>> b.rcms.string_get(14, 27, 8)
'11/10/20'
>>> b.rcms.string_get(12, 27, 8)
'14/10/19'
>>> b.rcms.string_get(12, 27, 8)
'11/10/20'
>>> b.rcms.string_get(14, 27, 8)
'11/10/20'
>>> b.rcms.string_get(14, 27, 8)

Traceback (most recent call last):
  File "<pyshell#58>", line 1, in <module>
    b.rcms.string_get(14, 27, 8)
  File "C:\Program Files\Python27\lib\site-packages\py3270-0.1.5-py2.7.egg\py3270\__init__.py", line 276, in string_get
    assert len(cmd.data) == 1, cmd.data
AssertionError: []
>>> b.rcms.string_get(14, 27, 8)

Traceback (most recent call last):
  File "<pyshell#59>", line 1, in <module>
    b.rcms.string_get(14, 27, 8)
  File "C:\Program Files\Python27\lib\site-packages\py3270-0.1.5-py2.7.egg\py3270\__init__.py", line 274, in string_get
    cmd = self.exec_command('Ascii({0},{1},{2})'.format(ypos, xpos, length))
  File "C:\Program Files\Python27\lib\site-packages\py3270-0.1.5-py2.7.egg\py3270\__init__.py", line 158, in exec_command
    c.execute()
  File "C:\Program Files\Python27\lib\site-packages\py3270-0.1.5-py2.7.egg\py3270\__init__.py", line 50, in execute
    return self.handle_result(result)
  File "C:\Program Files\Python27\lib\site-packages\py3270-0.1.5-py2.7.egg\py3270\__init__.py", line 68, in handle_result
    raise CommandError(msg)
CommandError: Unknown action: scii
>>> b.rcms.string_get(14, 27, 8)
'14/10/19'
==============================================
the "b.rcms" is a Emulator instance, it seems that the py3270 has some buffer problem.

I try to  resolved the problem through add stdin.flush() to the class command, like this:
class Command(object):

    """
        Represents a x3270 script command
    """

    def __init__(self, sp, cmdstr):
        self.sp = sp
        self.cmdstr = cmdstr
        self.status_line = None
        self.data = []
        self.sp.stdin.flush()
        ............................
Now, the py3270 seems work normal. 
Hope it useful.
py3270 buffer problem.jpg

Randy Syring

unread,
Jul 25, 2013, 3:34:00 PM7/25/13
to blaz...@googlegroups.com
Thanks so much for this report!  I was just having similar problems, but didn't have time to troubleshoot further.

Randy Syring
Development | Executive Director
Direct: 502.276.0459
Office: 812.285.8766

Level 12
            Technologies
Principled People | Technology that Works

--
You received this message because you are subscribed to the Google Groups "BlazeLibs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blazelibs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Randy Syring

unread,
Jul 26, 2013, 3:29:07 PM7/26/13
to blaz...@googlegroups.com
It seems to me that he proper place to put the .flush() is after we send data to the pipe.  I made this fix:

https://bitbucket.org/rsyring/py3270/commits/34d9358f3ea831014e86afa1c4af828bfc913f76

Can you please pull py3270 tip from bitbucket and see if this change also fixes your problem?

Thanks so much for the feedback!


Randy Syring
Development | Executive Director
Direct: 502.276.0459
Office: 812.285.8766

Level 12
            Technologies
Principled People | Technology that Works

On 07/25/2013 01:35 AM, Aiden Luo wrote:
Reply all
Reply to author
Forward
0 new messages