tn5250py-commits Mailing List for tn5250py
Status: Inactive
Brought to you by:
pbielen
You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
|
Feb
|
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <pb...@us...> - 2003-07-02 07:13:58
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv8590/src/lib5250py
Modified Files:
frmConnect.py tn5250.py
Log Message:
Removed UniCode version of wxPython and used normal version instead.
This to be able to make it some more platform independent.
Linux doesn't has an unicode wxPython version.
Index: frmConnect.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/frmConnect.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** frmConnect.py 1 Jul 2003 15:05:30 -0000 1.1
--- frmConnect.py 2 Jul 2003 07:13:55 -0000 1.2
***************
*** 21,25 ****
wxFrame.__init__(self, id=wxID_WXFRAME1, name='', parent=prnt,
pos=wxPoint(350, 272), size=wxSize(370, 310),
! style=wxDEFAULT_FRAME_STYLE, title=u'TN5250PY - Verbindingen')
self._init_utils()
self.SetClientSize(wxSize(362, 276))
--- 21,25 ----
wxFrame.__init__(self, id=wxID_WXFRAME1, name='', parent=prnt,
pos=wxPoint(350, 272), size=wxSize(370, 310),
! style=wxDEFAULT_FRAME_STYLE, title='TN5250PY - Verbindingen')
self._init_utils()
self.SetClientSize(wxSize(362, 276))
***************
*** 29,53 ****
self.grid1.SetDefaultRowSize(15)
! self.button1 = wxButton(id=wxID_WXFRAME1BUTTON1, label=u'Toevoegen',
name='button1', parent=self, pos=wxPoint(25, 210), size=wxSize(90,
23), style=0)
! self.button2 = wxButton(id=wxID_WXFRAME1BUTTON2, label=u'Verwijderen',
name='button2', parent=self, pos=wxPoint(140, 210),
size=wxSize(90, 23), style=0)
! self.button3 = wxButton(id=wxID_WXFRAME1BUTTON3, label=u'Eigenschappen',
name='button3', parent=self, pos=wxPoint(255, 210),
size=wxSize(90, 23), style=0)
! self.button4 = wxButton(id=wxID_WXFRAME1BUTTON4, label=u'Verbinden',
name='button4', parent=self, pos=wxPoint(25, 245), size=wxSize(90,
23), style=0)
! self.button5 = wxButton(id=wxID_WXFRAME1BUTTON5, label=u'Opslaan',
name='button5', parent=self, pos=wxPoint(140, 245),
size=wxSize(90, 23), style=0)
! self.button6 = wxButton(id=wxID_WXFRAME1BUTTON6, label=u'Annuleren',
name='button6', parent=self, pos=wxPoint(255, 245),
size=wxSize(90, 23), style=0)
--- 29,53 ----
self.grid1.SetDefaultRowSize(15)
! self.button1 = wxButton(id=wxID_WXFRAME1BUTTON1, label='Toevoegen',
name='button1', parent=self, pos=wxPoint(25, 210), size=wxSize(90,
23), style=0)
! self.button2 = wxButton(id=wxID_WXFRAME1BUTTON2, label='Verwijderen',
name='button2', parent=self, pos=wxPoint(140, 210),
size=wxSize(90, 23), style=0)
! self.button3 = wxButton(id=wxID_WXFRAME1BUTTON3, label='Eigenschappen',
name='button3', parent=self, pos=wxPoint(255, 210),
size=wxSize(90, 23), style=0)
! self.button4 = wxButton(id=wxID_WXFRAME1BUTTON4, label='Verbinden',
name='button4', parent=self, pos=wxPoint(25, 245), size=wxSize(90,
23), style=0)
! self.button5 = wxButton(id=wxID_WXFRAME1BUTTON5, label='Opslaan',
name='button5', parent=self, pos=wxPoint(140, 245),
size=wxSize(90, 23), style=0)
! self.button6 = wxButton(id=wxID_WXFRAME1BUTTON6, label='Annuleren',
name='button6', parent=self, pos=wxPoint(255, 245),
size=wxSize(90, 23), style=0)
Index: tn5250.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/tn5250.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tn5250.py 1 Jul 2003 14:57:30 -0000 1.4
--- tn5250.py 2 Jul 2003 07:13:55 -0000 1.5
***************
*** 6,10 ****
import frmConnect
! modules ={u'frmConnect': [1, 'Main frame of Application', u'frmConnect.py']}
class BoaApp(wxApp):
--- 6,10 ----
import frmConnect
! modules ={'frmConnect': [1, 'Main frame of Application', 'frmConnect.py']}
class BoaApp(wxApp):
|
|
From: <pb...@us...> - 2003-07-01 15:05:33
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv29073/src/lib5250py
Added Files:
frmConnect.py
Log Message:
Connect-screen.
Dutch Version
Using unicode wxPython !!!
For now Windows only
--- NEW FILE: frmConnect.py ---
#Boa:Frame:wxFrame1
from wxPython.wx import *
from wxPython.grid import *
def create(parent):
return wxFrame1(parent)
[wxID_WXFRAME1, wxID_WXFRAME1BUTTON1, wxID_WXFRAME1BUTTON2,
wxID_WXFRAME1BUTTON3, wxID_WXFRAME1BUTTON4, wxID_WXFRAME1BUTTON5,
wxID_WXFRAME1BUTTON6, wxID_WXFRAME1GRID1,
] = map(lambda _init_ctrls: wxNewId(), range(8))
class wxFrame1(wxFrame):
def _init_utils(self):
# generated method, don't edit
pass
def _init_ctrls(self, prnt):
# generated method, don't edit
wxFrame.__init__(self, id=wxID_WXFRAME1, name='', parent=prnt,
pos=wxPoint(350, 272), size=wxSize(370, 310),
style=wxDEFAULT_FRAME_STYLE, title=u'TN5250PY - Verbindingen')
self._init_utils()
self.SetClientSize(wxSize(362, 276))
self.grid1 = wxGrid(id=wxID_WXFRAME1GRID1, name='grid1', parent=self,
pos=wxPoint(0, 0), size=wxSize(370, 200), style=0)
self.grid1.SetDefaultRowSize(15)
self.button1 = wxButton(id=wxID_WXFRAME1BUTTON1, label=u'Toevoegen',
name='button1', parent=self, pos=wxPoint(25, 210), size=wxSize(90,
23), style=0)
self.button2 = wxButton(id=wxID_WXFRAME1BUTTON2, label=u'Verwijderen',
name='button2', parent=self, pos=wxPoint(140, 210),
size=wxSize(90, 23), style=0)
self.button3 = wxButton(id=wxID_WXFRAME1BUTTON3, label=u'Eigenschappen',
name='button3', parent=self, pos=wxPoint(255, 210),
size=wxSize(90, 23), style=0)
self.button4 = wxButton(id=wxID_WXFRAME1BUTTON4, label=u'Verbinden',
name='button4', parent=self, pos=wxPoint(25, 245), size=wxSize(90,
23), style=0)
self.button5 = wxButton(id=wxID_WXFRAME1BUTTON5, label=u'Opslaan',
name='button5', parent=self, pos=wxPoint(140, 245),
size=wxSize(90, 23), style=0)
self.button6 = wxButton(id=wxID_WXFRAME1BUTTON6, label=u'Annuleren',
name='button6', parent=self, pos=wxPoint(255, 245),
size=wxSize(90, 23), style=0)
def __init__(self, parent):
self._init_ctrls(parent)
|
|
From: <pb...@us...> - 2003-07-01 15:03:51
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py In directory sc8-pr-cvs1:/tmp/cvs-serv27578/src/lib5250py Removed Files: frmConnect.pyc Log Message: Removed, wrong file. --- frmConnect.pyc DELETED --- |
|
From: <pb...@us...> - 2003-07-01 15:02:31
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv27325/src/lib5250py
Added Files:
frmConnect.pyc tn5250.old.py
Log Message:
Started back from Zero using Boa Constructor.
Python 2.2.2 and wxPython (unicode) for gui.
Using Dutch language as default.
Right now runs on Windows.
--- NEW FILE: frmConnect.pyc ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: tn5250.old.py ---
#!/usr/local/bin/python
#########################################################################
# Tk8.0 style main window menus #
#########################################################################
from Tkinter import * # get widget classes
from tkMessageBox import * # get standard dialogs
from tkSimpleDialog import askstring
import Session
import Screen5250
import ScreenFields
from SessionManager import SessionManager
#import Sessions
import CodePage
from sys import argv
__all__ = ["testsession"]
class StartFrame(Frame): # an extended frame
def __init__(self, parent=None): # attach to top-level?
self.first = 1
self.USERID = None
self.PASSWORD = None
self.myScreen = None
Frame.__init__(self, parent) # do superclass init
self.canvas = Canvas(parent,width=600,height=500, bg='black')
self.manager = SessionManager()
self.pack()
self.createWidgets() # attach frames/widgets
self.master.title("TN5250 for Python - Testing")
self.master.iconname("TN5250") # label when iconified
self.strprg()
def outputScreen(self, initiator, startRow, startColumn, endRow, endColumn):
"""
Callable method to get screen updates
"""
print 'ScreenUpdated - initiated from ', initiator, \
' Starting from -> ',startRow,endRow,' to -> ', \
endRow,endColumn
if initiator == 0: ## 0 is from client and 1 is from host
return
# Note we only print the first 12 rows here
indices = range(1,24)
# for idx in indices:
# print self.myScreen.getPlaneData(idx,1,idx,80,1)
# print self.screen.getPlaneData(idx,1,80,2)
fields = self.myScreen.getFields()
if self.USERID == None or self.PASSWORD == None:
self.USERID = raw_input("What's your username ? > ")
self.PASSWORD = raw_input("What's your password ? > ")
if self.first == 1:
field = fields.getItem(0)
field.setString(self.USERID)
field = fields.getItem(1)
field.setString(self.PASSWORD)
for field in fields:
#print field.toString()
print field.getText()
#print fields.readFormatTable(0x42,CodePage.CodePage())
#print myScreen.getFields().readFormatTable(0x52,CodePage.CodePage())
# Note we only print the first 12 rows here
indices = range(1,25)
row = 0
for idx in indices:
text = self.myScreen.getPlaneData(idx,1,idx,80,1)
row += 15
col = 0
indx = range(0,79)
for x in indx:
col += 10
self.canvas.create_text(col,row,text=text[x], anchor=E, fill='green')
print 'number of fields',self.myScreen.getFields().getCount()
"""
Patrick here I just keep pressing enter so that the screens
keep coming up to see the messages. Actually 6 times.
the first is to send username and password. Then 2 more times
to get passed messages and stuff. Then 2 more times to
get messages at the bottom of the screen to make sure all is
coming up. Change this number if you want less for now.
"""
if self.first < 7:
self.myScreen.sendAidKey(0xF1)
self.first += 1
def strprg(self):
if len(argv) >= 2: host = argv[1]
else:
host = askstring('Hostname', "Name of the Host ?")
#ts = testsession()
if len(argv) > 3:
self.USERID = argv[2]
self.PASSWORD = argv[3]
session = self.manager.openSession('Session 1')
session.setHost(host)
#session = Session.Session(host)
session.set_debuglevel(1)
self.myScreen = session.getScreen()
session.getScreen().add_screen_listener(self.outputScreen)
session.connect()
def createWidgets(self):
self.makeMenuBar()
#self.canvas = self.root.createcomponent('canvas', (), None, \
#Canvas, (self.interior(),), width=self.width, \
#height=self.height,background="black")
self.canvas.pack(fill=BOTH)
#text = Text(self, relief=SUNKEN, fg='green', bg='black', \
#width=150, height=50)
#text.pack(fill=BOTH)
def makeMenuBar(self):
self.menubar = Menu(self.master)
self.master.config(menu=self.menubar) # master=top-level window
self.fileMenu()
self.editMenu()
def fileMenu(self):
pulldown = Menu(self.menubar, tearoff=0)
pulldown.add_command(label='Open...', command=self.notdone, \
underline=0)
pulldown.add_command(label='Quit', command=self.quit, \
underline=0)
pulldown.entryconfig(0, state=DISABLED)
self.menubar.add_cascade(label='File', underline=0, menu=pulldown)
def editMenu(self):
pulldown = Menu(self.menubar, tearoff=0)
pulldown.add_command(label='Copy', command=self.notdone)
pulldown.add_command(label='Paste', command=self.notdone)
pulldown.entryconfig(0, state=DISABLED)
pulldown.entryconfig(1, state=DISABLED)
self.menubar.add_cascade(label='Edit', underline=0, menu=pulldown)
def notdone(self):
showerror('Not implemented', 'Not yet available')
def quit(self):
if askyesno('Verify quit', 'Are you sure you want to quit?'):
Frame.quit(self)
if __name__ == '__main__':
#root = Tk()
StartFrame().mainloop()
#root.mainloop() # if I'm run as a script
|
|
From: <pb...@us...> - 2003-07-01 14:57:33
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv26137/src/lib5250py
Modified Files:
tn5250.py
Log Message:
Started back from zero, using Boa Constructor.
Index: tn5250.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/tn5250.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tn5250.py 6 Mar 2003 13:03:54 -0000 1.3
--- tn5250.py 1 Jul 2003 14:57:30 -0000 1.4
***************
*** 1,162 ****
! #!/usr/local/bin/python
! #########################################################################
! # Tk8.0 style main window menus #
! #########################################################################
!
! from Tkinter import * # get widget classes
! from tkMessageBox import * # get standard dialogs
! from tkSimpleDialog import askstring
! import Session
! import Screen5250
! import ScreenFields
! from SessionManager import SessionManager
! #import Sessions
! import CodePage
! from sys import argv
!
! __all__ = ["testsession"]
!
! class StartFrame(Frame): # an extended frame
! def __init__(self, parent=None): # attach to top-level?
! self.first = 1
! self.USERID = None
! self.PASSWORD = None
! self.myScreen = None
!
! Frame.__init__(self, parent) # do superclass init
! self.canvas = Canvas(parent,width=600,height=500, bg='black')
! self.manager = SessionManager()
! self.pack()
!
! self.createWidgets() # attach frames/widgets
! self.master.title("TN5250 for Python - Testing")
! self.master.iconname("TN5250") # label when iconified
! self.strprg()
!
! def outputScreen(self, initiator, startRow, startColumn, endRow, endColumn):
! """
! Callable method to get screen updates
! """
! print 'ScreenUpdated - initiated from ', initiator, \
! ' Starting from -> ',startRow,endRow,' to -> ', \
! endRow,endColumn
!
! if initiator == 0: ## 0 is from client and 1 is from host
! return
!
! # Note we only print the first 12 rows here
! indices = range(1,24)
!
! # for idx in indices:
! # print self.myScreen.getPlaneData(idx,1,idx,80,1)
! # print self.screen.getPlaneData(idx,1,80,2)
!
! fields = self.myScreen.getFields()
!
! if self.USERID == None or self.PASSWORD == None:
! self.USERID = raw_input("What's your username ? > ")
! self.PASSWORD = raw_input("What's your password ? > ")
!
! if self.first == 1:
! field = fields.getItem(0)
! field.setString(self.USERID)
! field = fields.getItem(1)
! field.setString(self.PASSWORD)
!
! for field in fields:
! #print field.toString()
! print field.getText()
!
! #print fields.readFormatTable(0x42,CodePage.CodePage())
! #print myScreen.getFields().readFormatTable(0x52,CodePage.CodePage())
! # Note we only print the first 12 rows here
! indices = range(1,25)
! row = 0
!
! for idx in indices:
! text = self.myScreen.getPlaneData(idx,1,idx,80,1)
! row += 15
! col = 0
! indx = range(0,79)
! for x in indx:
! col += 10
! self.canvas.create_text(col,row,text=text[x], anchor=E, fill='green')
!
! print 'number of fields',self.myScreen.getFields().getCount()
! """
! Patrick here I just keep pressing enter so that the screens
! keep coming up to see the messages. Actually 6 times.
! the first is to send username and password. Then 2 more times
! to get passed messages and stuff. Then 2 more times to
! get messages at the bottom of the screen to make sure all is
! coming up. Change this number if you want less for now.
! """
!
! if self.first < 7:
! self.myScreen.sendAidKey(0xF1)
! self.first += 1
!
! def strprg(self):
! if len(argv) >= 2: host = argv[1]
! else:
! host = askstring('Hostname', "Name of the Host ?")
!
! #ts = testsession()
!
! if len(argv) > 3:
! self.USERID = argv[2]
! self.PASSWORD = argv[3]
!
! session = self.manager.openSession('Session 1')
! session.setHost(host)
! #session = Session.Session(host)
!
! session.set_debuglevel(1)
! self.myScreen = session.getScreen()
! session.getScreen().add_screen_listener(self.outputScreen)
! session.connect()
!
! def createWidgets(self):
! self.makeMenuBar()
! #self.canvas = self.root.createcomponent('canvas', (), None, \
! #Canvas, (self.interior(),), width=self.width, \
! #height=self.height,background="black")
! self.canvas.pack(fill=BOTH)
! #text = Text(self, relief=SUNKEN, fg='green', bg='black', \
! #width=150, height=50)
! #text.pack(fill=BOTH)
! def makeMenuBar(self):
! self.menubar = Menu(self.master)
! self.master.config(menu=self.menubar) # master=top-level window
! self.fileMenu()
! self.editMenu()
! def fileMenu(self):
! pulldown = Menu(self.menubar, tearoff=0)
! pulldown.add_command(label='Open...', command=self.notdone, \
! underline=0)
! pulldown.add_command(label='Quit', command=self.quit, \
! underline=0)
! pulldown.entryconfig(0, state=DISABLED)
! self.menubar.add_cascade(label='File', underline=0, menu=pulldown)
! def editMenu(self):
! pulldown = Menu(self.menubar, tearoff=0)
! pulldown.add_command(label='Copy', command=self.notdone)
! pulldown.add_command(label='Paste', command=self.notdone)
! pulldown.entryconfig(0, state=DISABLED)
! pulldown.entryconfig(1, state=DISABLED)
! self.menubar.add_cascade(label='Edit', underline=0, menu=pulldown)
! def notdone(self):
! showerror('Not implemented', 'Not yet available')
! def quit(self):
! if askyesno('Verify quit', 'Are you sure you want to quit?'):
! Frame.quit(self)
if __name__ == '__main__':
! #root = Tk()
! StartFrame().mainloop()
! #root.mainloop() # if I'm run as a script
--- 1,24 ----
! #!/usr/bin/env python
! #Boa:App:BoaApp
! from wxPython.wx import *
! import frmConnect
! modules ={u'frmConnect': [1, 'Main frame of Application', u'frmConnect.py']}
! class BoaApp(wxApp):
! def OnInit(self):
! wxInitAllImageHandlers()
! self.main = frmConnect.create(None)
! # needed when running from Boa under Windows 9X
! self.SetTopWindow(self.main)
! self.main.Show();self.main.Hide();self.main.Show()
! return True
! def main():
! application = BoaApp(0)
! application.MainLoop()
if __name__ == '__main__':
! main()
|
|
From: <pb...@us...> - 2003-03-06 12:23:45
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv20310/src/lib5250py
Modified Files:
CodePage.py
Log Message:
Code Cleanup
Index: CodePage.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/CodePage.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** CodePage.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- CodePage.py 6 Mar 2003 12:23:42 -0000 1.2
***************
*** 1,97 ****
! """
! CodePage
!
! Used to convert ascii to ebcdic and ebcdic to ascii
!
! Created by Kenneth J. Pouncey 2002-05-18
! Changed by Nate Custer - 2002-05-22
!
! Used some different data types to improve performance/memory usage.
! Used a dict (hash table) instead of a list for the lookup tables.
! The performance of a lookup is faster if you use a dict. Also; used a
! tuple instead of a list for the list at the start. Since tuples aren't
! mutable the python interpreter uses less memory to store them.
!
! Cleaned up by P. Bielen - 2002-05-23
!
! Managed a length of 75 characters at one line, to prevend a lot of
! editors to do a word-wrap.
!
! """
!
__all__ = ["CodePage"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
! # Conversion table generated mechanically by Free `recode' 3.5
! # for sequence IBM037..ISO-8859-1 (reversible). */
!
! codePage37 = ( 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, \
! 12, 13, 14, 15, 16, 17, 18, 19, 157, 133, 8, 135, \
! 24, 25, 146, 143, 28, 29, 30, 31, 128, 129, 130, 131, \
! 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, \
! 7, 144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, \
! 155, 20, 21, 158, 26, 32, 160, 226, 228, 224, 225, 227, \
! 229, 231, 241, 162, 46, 60, 40, 43, 124, 38, 233, 234, \
! 235, 232, 237, 238, 239, 236, 223, 33, 36, 42, 41, \
! 59, 172, 45, 47, 194, 196, 192, 193, 195, 197, 199, 209, \
! 166, 44, 37, 95, 62, 63, 248, 201, 202, 203, 200, \
! 205, 206, 207, 204, 96, 58, 35, 64, 39, 61, 34, \
! 216, 97, 98, 99, 100, 101, 102, 103, 104, 105, 171, \
! 187, 240, 253, 254, 177, 176, 106, 107, 108, 109, 110, \
! 111, 112, 113, 114, 170, 186, 230, 184, 198, 164, 181, \
! 126, 115, 116, 117, 118, 119, 120, 121, 122, 161, 191, \
! 208, 221, 222, 174, 94, 163, 165, 183, 169, 167, 182, 188, \
! 189, 190, 91, 93, 175, 168, 180, 215, 123, 65, 66, \
! 67, 68, 69, 70, 71, 72, 73, 173, 244, 246, 242, 243, \
! 245, 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, 185, \
! 251, 252, 249, 250, 255, 92, 247, 83, 84, 85, 86, 87, \
! 88, 89, 90, 178, 212, 214, 210, 211, 213, 48, 49, 50, \
! 51, 52, 53, 54, 55, 56, 57, 179, 219, 220, 217, 218, \
! 159)
!
! class CodePage: #CodePage class.
!
! def __init__(self,codePage=None): #Constructor.
!
! if codePage:
! self.setCodePage(codePage)
! else:
! self.setCodePage(37)
!
! def setCodePage(self,codePage):
!
! self.ascii = {}
! self.ebcdic = {}
!
! if codePage == 37:
! cp = codePage37
! else:
! cp = codePage37
!
! cpi = 0
!
! while cpi < 256:
! self.ebcdic[cpi] = cp[cpi]
! self.ascii[cp[cpi]] = cpi
! cpi += 1
!
! def getEBCDIC (self,index):
! return self.ascii[index]
!
! def getEBCDICChar (self,index):
! return chr(self.ascii[index])
!
! def getASCII (self,index):
! return self.ebcdic[index]
!
! def getASCIIChar (self,index):
! return chr(self.ebcdic[index])
!
!
! def ebcdic2uni (self,index):
! return self.getASCIIChar(index)
!
! def uni2ebcdic (self,index):
! return self.getEBCDICChar(ord(index))
--- 1,13 ----
! """
CodePage
Used to convert ascii to ebcdic and ebcdic to ascii
Created by Kenneth J. Pouncey 2002-05-18
Changed by Nate Custer - 2002-05-22
Used some different data types to improve performance/memory usage.
Used a dict (hash table) instead of a list for the lookup tables.
The performance of a lookup is faster if you use a dict. Also; used a
tuple instead of a list for the list at the start. Since tuples aren't
mutable the python interpreter uses less memory to store them.
Cleaned up by P. Bielen - 2002-05-23
Managed a length of 75 characters at one line, to prevend a lot of
editors to do a word-wrap.
"""
__all__ = ["CodePage"]
! # Tunable parameters
DEBUGLEVEL = 0
! # Conversion table generated mechanically by Free `recode' 3.5
# for sequence IBM037..ISO-8859-1 (reversible). */
! codePage37 = ( 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, \
12, 13, 14, 15, 16, 17, 18, 19, 157, 133, 8, 135, \
24, 25, 146, 143, 28, 29, 30, 31, 128, 129, 130, 131, \
132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, \
7, 144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, \
155, 20, 21, 158, 26, 32, 160, 226, 228, 224, 225, 227, \
229, 231, 241, 162, 46, 60, 40, 43, 124, 38, 233, 234, \
235, 232, 237, 238, 239, 236, 223, 33, 36, 42, 41, \
59, 172, 45, 47, 194, 196, 192, 193, 195, 197, 199, 209, \
166, 44, 37, 95, 62, 63, 248, 201, 202, 203, 200, \
205, 206, 207, 204, 96, 58, 35, 64, 39, 61, 34, \
216, 97, 98, 99, 100, 101, 102, 103, 104, 105, 171, \
187, 240, 253, 254, 177, 176, 106, 107, 108, 109, 110, \
111, 112, 113, 114, 170, 186, 230, 184, 198, 164, 181, \
126, 115, 116, 117, 118, 119, 120, 121, 122, 161, 191, \
208, 221, 222, 174, 94, 163, 165, 183, 169, 167, 182, 188, \
189, 190, 91, 93, 175, 168, 180, 215, 123, 65, 66, \
67, 68, 69, 70, 71, 72, 73, 173, 244, 246, 242, 243, \
245, 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, 185, \
251, 252, 249, 250, 255, 92, 247, 83, 84, 85, 86, 87, \
88, 89, 90, 178, 212, 214, 210, 211, 213, 48, 49, 50, \
51, 52, 53, 54, 55, 56, 57, 179, 219, 220, 217, 218, \
159)
! class CodePage: #CodePage class.
def __init__(self,codePage=None): #Constructor.
if codePage:
self.setCodePage(codePage)
else:
self.setCodePage(37)
! def setCodePage(self,codePage):
self.ascii = {}
self.ebcdic = {}
if codePage == 37:
cp = codePage37
else:
cp = codePage37
cpi = 0
while cpi < 256:
self.ebcdic[cpi] = cp[cpi]
self.ascii[cp[cpi]] = cpi
cpi += 1
! def getEBCDIC (self,index):
return self.ascii[index]
! def getEBCDICChar (self,index):
return chr(self.ascii[index])
! def getASCII (self,index):
return self.ebcdic[index]
! def getASCIIChar (self,index):
return chr(self.ebcdic[index])
! def ebcdic2uni (self,index):
return self.getASCIIChar(index)
! def uni2ebcdic (self,index):
return self.getEBCDICChar(ord(index))
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 12:21:33
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv19385/src/lib5250py
Modified Files:
Screen5250.py
Log Message:
Code Cleanup
Index: Screen5250.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/Screen5250.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Screen5250.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- Screen5250.py 6 Mar 2003 12:21:29 -0000 1.2
***************
*** 1,343 ****
! """
! Screen object
! Created by Kenneth J. Pouncey 2002-05-18
! """
!
! import ScreenFields
!
__all__ = ["Screen5250"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
! # Initial Attribute
! initAttr = 32
!
! class Screen5250:
!
! #Screen5250 interface class.
!
! # def __init__(self, host=None, port=0):
!
! def __init__(self): #Constructor
!
! self._listeners = []
!
! self.debuglevel = DEBUGLEVEL
!
! # Text Plane of screen
! self.textPlane = []
!
! # Attrubute Plane of screen
! self.attrPlane = []
!
! # number of rows and columns
! self.numRows = 24
! self.numCols = 80
! self.screenLength = self.numRows * self.numCols
!
! # current screen position
! self.lastPos = 0
!
! # current screen home position
! self.homePos = 0
!
! # pending insert flag
! self.pendingInsert = 0
!
! # screen virtual terminal
! self.vt = None
!
! # set default attribute for screen position row 1 column 1
! self.lastAttr = initAttr
!
! # set up our field format table
! self.screenFields = ScreenFields.ScreenFields(self)
!
! loop = 0
! while loop < self.screenLength:
! self.textPlane.append(' ')
! loop += 1
!
! loop = 0
! # initialize the attribute plane to default attribute of 0x32
! while loop < self.screenLength:
! self.attrPlane.append(self.lastAttr)
! loop += 1
!
! def set_debuglevel(self, debuglevel):
! """Set the debug level.
! The higher it is, the more debug output you get (on sys.stdout).
! """
! self.debuglevel = debuglevel
!
! def add_screen_listener( self , func ):
! # this is where we give it a "callback"
! self._listeners.append( func )
!
! def notify_screen_listeners( self, initiator ):
! """
! this is where we actually call back
! """
! for f in self._listeners :
! f(initiator,1,1,24,80)
!
! def getRows(self):
! return self.numRows
!
! def getCols(self):
! return self.numCols
!
! def getCurrentRow(self):
! return (self.lastPos / self.numCols) + 1;
!
! def getCurrentCol(self):
! return (self.lastPos % self.numCols) + 1;
!
! def changePos(self,i):
! """
!
! """
! self.lastPos += i;
! if self.lastPos < 0:
! self.lastPos = self.screenLength + self.lastPos
! if self.lastPos > self.screenLength - 1:
! self.lastPos = self.lastPos - self.screenLength
!
!
! def moveTo(self,row,column):
! """
! This routine is based on offset 1,1 not 0,0 it will translate to
! offset 0,0 and call the goto_XY(int pos) it is mostly used from
! external classes that use the 1,1 offset
! """
! self.moveToPos(((row - 1) * self.numCols) + (column-1))
!
! def moveToPos(self,pos):
! self.lastPos = pos
!
! def addField(self,attr,fLength,ffw0,ffw1,fcw1,fcw2):
! self.lastAttr = attr
!
! self.textPlane[self.lastPos] = 0
! self.attrPlane[self.lastPos] = attr
!
! self.changePos(1)
! pos = self.lastPos
!
! sf = self.screenFields.setField(attr,self.getCurrentRow(),self.getCurrentCol(),fLength,ffw0,ffw1,fcw1,fcw2)
!
! print sf.toString()
!
! # now lets initialize the planes for the field
! while fLength > 0:
! if self.textPlane[pos] == 0:
! self.textPlane[pos] = ' '
! self.attrPlane[pos] = attr
! else:
! self.attrPlane[pos] = attr
! pos +=1
! fLength -=1
!
! spos = self.lastPos
! self.lastPos = pos
!
! self.setAttr(initAttr)
! self.lastAttr = attr
! self.lastPos = spos
!
!
!
! def setAttr(self,attr):
! """
! This routine is used to set attributes in the Attribute Plane
! """
! # print chr(char), ' at ' , self.getCurrentRow(),
! # ' , ' , self.getCurrentCol()
! self.lastAttr = attr
!
! self.attrPlane[self.lastPos] = attr
! self.changePos(1)
!
! pos = self.lastPos
!
! while pos < self.screenLength and self.attrPlane[pos] != \
! self.lastAttr:
! self.attrPlane[pos] = self.lastAttr
! pos += 1
!
!
! def setChar(self,char):
! """
! This routine is used to place characters into the Text Plane
! """
! if char > 0x0 and char < ' ':
! self.textPlane[self.lastPos] = ' '
! self.attrPlane[self.lastPos] = 33
! else:
! self.textPlane[self.lastPos] = char
! self.changePos(1)
!
! def clearAll(self):
!
! self.lastPos = 0
! self.lastAttr = 0x32
! self.clearFFT()
! self.clearPlanes()
!
! def clearFFT(self):
!
! self.screenFields.clearFFT()
! self.pendingInsert = 0
! self.homePos = -1
!
! def clearPlanes(self):
!
! x = 0
! # clear Text Plane
! while x < self.screenLength:
! self.textPlane[x] = ' '
! x += 1
!
! x = 0
! # clear Attribute Plane
! while x < self.screenLength:
! self.attrPlane[x] = self.lastAttr
! x += 1
!
! def getFields(self):
! """
! return an object of Fields contained on the presentation space.
! """
! return self.screenFields
!
! def getPlaneData(self,row,column,endRow,endCol,whichPlane):
!
! loop = 0
!
! start = ((row - 1) * self.numCols) + (column-1)
! end = ((endRow - 1) * self.numCols) + (endCol-1)
!
! length = end - start
!
! if whichPlane == 1: # Text Plane
! plane = ''
! indices = range(start,start + length)
! for idx in indices:
! c = self.textPlane[idx]
! if c < ' ':
! plane += ' '
! else:
! plane += c
! return plane
! elif whichPlane == 2: # Attribute Plane
! return self.attrPlane[start:start + length]
!
! def setVT(self,vt):
! """
! Set the virtual terminal associated with the screen
! """
! self.vt = vt
!
! def sendAidKey(self,aid):
! """
! Send the aid key to the virtual terminal
! """
! self.vt.sendAidKey(aid)
!
!
! def getPos(self,row,col):
! """
! Return a position integer from a passed row and column
! """
! return (row * self.numCols) + col
!
! def getRow(self,pos):
! """
! Return row associated to a position
! """
! row = pos / self.numCols
!
! if row < 0:
! row = self.lastPos / self.numCols
! if row > (self.screenLength - 1):
! row = self.screenLength - 1
!
! return row;
!
! def getCol(self,pos):
! """
! Return col associated to a position
! """
! col = pos % self.numCols
! if col > 0:
! return col
! else:
! return 0
!
! def gotoFieldItem(self,item):
! """
! Move the screen cursor position to the field item
! """
! sizeFields = self.screenFields.getCount()
!
! if item > sizeFields or item < 0:
! return 0
!
! self.screenFields.setCurrentField(self.screenFields.getItem(item-1))
! while self.screenFields.isCurrentFieldBypassField() and item < sizeFields:
! self.screenFields.setCurrentField(self.screenFields.getItem(item))
! item += 1
! return self.gotoField(self.screenFields.getCurrentField())
!
! def gotoField(self,f):
! if f != None:
! self.moveToPos(f.startPos)
! return 1
! else:
! return 0
!
! def setPendingInsert(self, flag, icX, icY):
! self.pendingInsert = flag
!
! if self.pendingInsert:
! self.homePos = self.getPos(icX,icY)
!
! def goHome(self):
! """
! now we try to move to first input field according to
! 14.6 WRITE TO DISPLAY Command
! - If the WTD command is valid, after the command is processed,
! the cursor moves to one of three locations:
! - The location set by an insert cursor order (unless control
! character byte 1, bit 1 is equal to B'1'.)
! - The start of the first non-bypass input field defined in the
! format table
! - A default starting address of row 1 column 1.
! """
! if self.pendingInsert:
! self.moveTo(self.getRow(self.homePos),self.getCol(self.homePos))
! self.isInField() ## we now check if we are in a field
! else:
! if not self.gotoFieldItem(1):
! self.homePos = self.getPos(1,1);
! self.moveTo(1,1);
! self.isInField(row=0,col=0); ## we now check if we are in a field
! else:
! self.homePos = self.getPos(self.getCurrentRow(),self.getCurrentCol())
!
! def isInField(self,pos=None,row=None,col=None,chgToField=None):
!
! if chgToField == None:
! chgToField = 1
! else:
! chgToField = 0
!
! if row != None:
! pos = (row * self.numCols) + col
!
! if pos == None:
! pos = self.lastPos
!
! return self.screenFields.isInField(pos,chgToField)
!
--- 1,33 ----
! """
Screen object
Created by Kenneth J. Pouncey 2002-05-18
"""
import ScreenFields
__all__ = ["Screen5250"]
! # Tunable parameters
DEBUGLEVEL = 0
# Initial Attribute
initAttr = 32
! class Screen5250:
#Screen5250 interface class.
#def __init__(self, host=None, port=0):
def __init__(self): #Constructor
self._listeners = []
self.debuglevel = DEBUGLEVEL
# Text Plane of screen
self.textPlane = []
# Attrubute Plane of screen
self.attrPlane = []
# number of rows and columns
self.numRows = 24
self.numCols = 80
self.screenLength = self.numRows * self.numCols
# current screen position
self.lastPos = 0
# current screen home position
self.homePos = 0
# pending insert flag
self.pendingInsert = 0
# screen virtual terminal
self.vt = None
# set default attribute for screen position row 1 column 1
self.lastAttr = initAttr
# set up our field format table
self.screenFields = ScreenFields.ScreenFields(self)
loop = 0
while loop < self.screenLength:
self.textPlane.append(' ')
loop += 1
loop = 0
# initialize the attribute plane to default attribute of 0x32
while loop < self.screenLength:
self.attrPlane.append(self.lastAttr)
loop += 1
! def set_debuglevel(self, debuglevel):
"""Set the debug level.
The higher it is, the more debug output you get (on sys.stdout).
"""
self.debuglevel = debuglevel
! def add_screen_listener( self , func ):
# this is where we give it a "callback"
self._listeners.append( func )
! def notify_screen_listeners( self, initiator ):
""" this is where we actually call back """
for f in self._listeners :
f(initiator,1,1,24,80)
! def getRows(self):
return self.numRows
! def getCols(self):
return self.numCols
! def getCurrentRow(self):
return (self.lastPos / self.numCols) + 1;
! def getCurrentCol(self):
return (self.lastPos % self.numCols) + 1;
! def changePos(self,i):
self.lastPos += i;
if self.lastPos < 0:
self.lastPos = self.screenLength + self.lastPos
if self.lastPos > self.screenLength - 1:
self.lastPos = self.lastPos - self.screenLength
! def moveTo(self,row,column):
"""
This routine is based on offset 1,1 not 0,0 it will translate to
offset 0,0 and call the goto_XY(int pos) it is mostly used from
external classes that use the 1,1 offset
"""
self.moveToPos(((row - 1) * self.numCols) + (column-1))
! def moveToPos(self,pos):
self.lastPos = pos
! def addField(self,attr,fLength,ffw0,ffw1,fcw1,fcw2):
self.lastAttr = attr
self.textPlane[self.lastPos] = 0
self.attrPlane[self.lastPos] = attr
self.changePos(1)
pos = self.lastPos
sf = self.screenFields.setField(attr,self.getCurrentRow(), \
! self.getCurrentCol(),fLength,ffw0,ffw1,fcw1,fcw2)
print sf.toString()
# now lets initialize the planes for the field
while fLength > 0:
if self.textPlane[pos] == 0:
self.textPlane[pos] = ' '
self.attrPlane[pos] = attr
else:
self.attrPlane[pos] = attr
pos +=1
fLength -=1
spos = self.lastPos
self.lastPos = pos
self.setAttr(initAttr)
self.lastAttr = attr
self.lastPos = spos
! def setAttr(self,attr):
"""
This routine is used to set attributes in the Attribute Plane
"""
# print chr(char), ' at ' , self.getCurrentRow(),
# ' , ' , self.getCurrentCol()
self.lastAttr = attr
self.attrPlane[self.lastPos] = attr
self.changePos(1)
pos = self.lastPos
while pos < self.screenLength and self.attrPlane[pos] != \
self.lastAttr:
self.attrPlane[pos] = self.lastAttr
pos += 1
! def setChar(self,char):
"""
This routine is used to place characters into the Text Plane
"""
if char > 0x0 and char < ' ':
self.textPlane[self.lastPos] = ' '
self.attrPlane[self.lastPos] = 33
else:
self.textPlane[self.lastPos] = char
self.changePos(1)
! def clearAll(self):
self.lastPos = 0
self.lastAttr = 0x32
self.clearFFT()
self.clearPlanes()
! def clearFFT(self):
self.screenFields.clearFFT()
self.pendingInsert = 0
self.homePos = -1
! def clearPlanes(self):
x = 0
# clear Text Plane
while x < self.screenLength:
self.textPlane[x] = ' '
x += 1
x = 0
# clear Attribute Plane
while x < self.screenLength:
self.attrPlane[x] = self.lastAttr
x += 1
! def getFields(self):
"""
return an object of Fields contained on the presentation space.
"""
return self.screenFields
! def getPlaneData(self,row,column,endRow,endCol,whichPlane):
loop = 0
start = ((row - 1) * self.numCols) + (column-1)
end = ((endRow - 1) * self.numCols) + (endCol-1)
length = end - start
if whichPlane == 1: # Text Plane
plane = ''
indices = range(start,start + length)
for idx in indices:
c = self.textPlane[idx]
if c < ' ':
plane += ' '
else:
plane += c
return plane
elif whichPlane == 2: # Attribute Plane
return self.attrPlane[start:start + length]
! def setVT(self,vt):
""" Set the virtual terminal associated with the screen """
self.vt = vt
! def sendAidKey(self,aid):
""" Send the aid key to the virtual terminal """
self.vt.sendAidKey(aid)
! def getPos(self,row,col):
""" Return a position integer from a passed row and column """
return (row * self.numCols) + col
! def getRow(self,pos):
""" Return row associated to a position """
row = pos / self.numCols
if row < 0:
row = self.lastPos / self.numCols
if row > (self.screenLength - 1):
row = self.screenLength - 1
return row;
! def getCol(self,pos):
""" Return col associated to a position """
col = pos % self.numCols
if col > 0:
return col
else:
return 0
! def gotoFieldItem(self,item):
""" Move the screen cursor position to the field item """
sizeFields = self.screenFields.getCount()
if item > sizeFields or item < 0:
return 0
self.screenFields.setCurrentField(self.screenFields.getItem(item-1))
while self.screenFields.isCurrentFieldBypassField() and item < sizeFields:
self.screenFields.setCurrentField(self.screenFields.getItem(item))
item += 1
return self.gotoField(self.screenFields.getCurrentField())
! def gotoField(self,f):
if f != None:
self.moveToPos(f.startPos)
return 1
else:
return 0
! def setPendingInsert(self, flag, icX, icY):
self.pendingInsert = flag
if self.pendingInsert:
self.homePos = self.getPos(icX,icY)
! def goHome(self):
"""
now we try to move to first input field according to
14.6 WRITE TO DISPLAY Command
- If the WTD command is valid, after the command is processed,
the cursor moves to one of three locations:
- The location set by an insert cursor order (unless control
character byte 1, bit 1 is equal to B'1'.)
- The start of the first non-bypass input field defined in the
format table
- A default starting address of row 1 column 1.
"""
if self.pendingInsert:
self.moveTo(self.getRow(self.homePos),self.getCol(self.homePos))
self.isInField() ## we now check if we are in a field
else:
if not self.gotoFieldItem(1):
self.homePos = self.getPos(1,1);
self.moveTo(1,1);
self.isInField(row=0,col=0); ## we now check if we are in a field
else:
self.homePos = self.getPos(self.getCurrentRow(),self.getCurrentCol())
! def isInField(self,pos=None,row=None,col=None,chgToField=None):
if chgToField == None:
chgToField = 1
else:
chgToField = 0
if row != None:
pos = (row * self.numCols) + col
if pos == None:
pos = self.lastPos
return self.screenFields.isInField(pos,chgToField)
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 12:12:41
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv16156/src/lib5250py
Modified Files:
ScreenField.py
Log Message:
Code Cleanup
Index: ScreenField.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/ScreenField.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ScreenField.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- ScreenField.py 6 Mar 2003 12:12:38 -0000 1.2
***************
*** 1,223 ****
! """ScreenField object
!
! Created by Kenneth J. Pouncey 2002-05-23
! """
!
! import Screen5250
__all__ = ["SessionField"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
! class ScreenField:
!
! """Session Field interface class.
!
!
!
! """
! def __init__(self,screen):
! """Constructor.
!
!
! """
! self.debuglevel = DEBUGLEVEL
! self.screen = screen
!
! def set_debuglevel(self, debuglevel):
! """Set the debug level.
!
! The higher it is, the more debug output you get (on sys.stdout).
!
! """
! self.debuglevel = debuglevel
!
! def setField(self,attr,row,col,len,ffw1,ffw2,fcw1,fcw2):
! """Set the field attributes
!
!
! """
! self.length = len
! self.startPos = (row * self.screen.getCols()) + col
! self.endPos = self.startPos + len -1
! self.cursorProg = 0
! self.fieldId = 0
! self.attr = attr
! self.setFFWs(ffw1,ffw2)
! self.setFCWs(fcw1,fcw2)
!
! self.next = None
! self.prev = None
!
! return self
!
! def getAttr(self):
! return self.attr
!
! def getHighlightedAttr(self):
! return self.fcw2 | 0x20
!
! def getLength(self):
! return self.length
!
! def setFFWs(self,ffw1,ffw2):
!
! self.ffw1 = ffw1;
! self.ffw2 = ffw2;
! self.mdt = (ffw1 & 0x8 ) == 0x8;
! return self.mdt;
!
! def setFCWs(self,fcw1,fcw2):
!
! self.fcw1 = fcw1;
! self.fcw2 = fcw2;
!
! if (fcw1 == 0x88):
! self.cursorProg = fcw2;
!
! def getFFW1(self):
! return self.ffw1
!
! def getFFW1(self):
! return self.ffw2
!
! def getFCW1(self):
! return self.ffc1
!
! def getFCW1(self):
! return self.ffc2
!
! def getFieldLength(self):
! return self.length
!
! def getFieldId(self):
! return self.fieldId
!
! def setFieldId(self,fi):
! self.fieldId = fi
!
! def getCursorProgression(self):
! return self.cursorProg
!
! def getCursorRow(self):
! return cursorPos / self.screen.getCols();
!
! def getCursorCol(self):
! return cursorPos % self.screen.getCols();
!
! def changePos(self,i):
! self.cursorPos += i
!
! def getText(self):
! start = self.startPos
! text = []
! while start <= self.endPos:
! text.append(self.screen.textPlane[start])
! start += 1
! return text
!
! def setString(self,text):
! start = self.startPos
! for x in text:
! self.screen.textPlane[start] = x
! start += 1
! self.mdt = 1
! self.screen.notify_screen_listeners(0)
!
! def setFieldChar(self,c):
!
! x = self.length
! self.cursorPos = self.startPos
! while x > 0:
! self.screen.textPlane[cursorPos] = c
! self.changePos(1)
! x -= 1
!
! def resetMDT(self):
! self.mdt = 0
!
! def setMDT(self):
!
! self.mdt = 1
!
! def isBypassField(self):
!
! return (self.ffw1 & 0x20) == 0x20
!
! def getAdjustment(self):
!
! return (self.ffw2 & 0x7)
!
! def isFER(self):
!
! return (self.ffw2 & 0x40) == 0x40
!
! def isMandatoryEnter(self):
!
! return (self.ffw2 & 0x8) == 0x8
!
! def isToUpper(self):
!
! return (self.ffw2 & 0x20) == 0x20
!
! def getFieldShift(self):
! """
! return bits 5 - 7 of FFW1 which holds the shift adjustment
! of the field
! """
!
! return (self.ffw1 & 0x7)
!
! def isHighlightedEntry(self):
!
! return (self.fcw1 == 0x89)
!
! def isAutoEnter(self):
!
! return (self.ffw2 & 0x80) == 0x80
!
! def isSignedNumeric(self):
!
! return (self.getFieldShift() == 7)
!
! def getKeyPosRC(self,row1,col1):
! x = ((row1 * self.screen.getCols()) + col1);
! y = x - self.startPos;
! self.cursorPos = x;
!
! return y;
!
! def getKeyPos(self, pos):
!
! y = self.pos - self.startPos
!
! self.cursorPos = pos
! return y
!
! def getCurrentPos(self):
! return self.cursorPos
!
! def withinField(self,pos):
!
! if (pos >= self.startPos) and (pos <= self.endPos):
! return 1
! return 0
!
! def startPos(self):
! return self.startPos
!
! def startRow(self):
! return self.startPos / self.screen.getCols()
!
! def startCol(self):
! return self.startPos % self.screen.getCols()
!
! def endPos(self):
! return self.endPos
!
! def toString(self):
! return 'startRow =', self.startRow(), 'startCol =',self.startCol(), \
! 'length =',self.length,'ffw1 = ',self.ffw1,'ffw2 = ',self.ffw1, \
! 'is bypass field',self.isBypassField(),'isAutoEnter', \
! self.isAutoEnter(),'is Mandatory Enter',self.isMandatoryEnter(), \
! 'modified',self.mdt
--- 1,45 ----
! """ScreenField object
Created by Kenneth J. Pouncey 2002-05-23
"""
import Screen5250
__all__ = ["SessionField"]
! # Tunable parameters
DEBUGLEVEL = 0
! class ScreenField:
"""Session Field interface class. """
def __init__(self,screen):
"""Constructor. """
self.debuglevel = DEBUGLEVEL
self.screen = screen
! def set_debuglevel(self, debuglevel):
"""Set the debug level.
The higher it is, the more debug output you get (on sys.stdout).
"""
self.debuglevel = debuglevel
! def setField(self,attr,row,col,len,ffw1,ffw2,fcw1,fcw2):
""" Set the field attributes """
self.length = len
self.startPos = (row * self.screen.getCols()) + col
self.endPos = self.startPos + len -1
self.cursorProg = 0
self.fieldId = 0
self.attr = attr
self.setFFWs(ffw1,ffw2)
self.setFCWs(fcw1,fcw2)
self.next = None
self.prev = None
return self
! def getAttr(self):
return self.attr
! def getHighlightedAttr(self):
return self.fcw2 | 0x20
! def getLength(self):
return self.length
! def setFFWs(self,ffw1,ffw2):
self.ffw1 = ffw1;
self.ffw2 = ffw2;
self.mdt = (ffw1 & 0x8 ) == 0x8;
return self.mdt;
! def setFCWs(self,fcw1,fcw2):
self.fcw1 = fcw1;
self.fcw2 = fcw2;
if (fcw1 == 0x88):
self.cursorProg = fcw2;
! def getFFW1(self):
return self.ffw1
! def getFFW1(self):
return self.ffw2
! def getFCW1(self):
return self.ffc1
! def getFCW1(self):
return self.ffc2
! def getFieldLength(self):
return self.length
! def getFieldId(self):
return self.fieldId
! def setFieldId(self,fi):
self.fieldId = fi
! def getCursorProgression(self):
return self.cursorProg
! def getCursorRow(self):
return cursorPos / self.screen.getCols();
! def getCursorCol(self):
return cursorPos % self.screen.getCols();
! def changePos(self,i):
self.cursorPos += i
! def getText(self):
start = self.startPos
text = []
while start <= self.endPos:
text.append(self.screen.textPlane[start])
start += 1
return text
! def setString(self,text):
start = self.startPos
for x in text:
self.screen.textPlane[start] = x
start += 1
self.mdt = 1
self.screen.notify_screen_listeners(0)
! def setFieldChar(self,c):
x = self.length
self.cursorPos = self.startPos
while x > 0:
self.screen.textPlane[cursorPos] = c
self.changePos(1)
x -= 1
! def resetMDT(self):
self.mdt = 0
! def setMDT(self):
self.mdt = 1
! def isBypassField(self):
return (self.ffw1 & 0x20) == 0x20
! def getAdjustment(self):
return (self.ffw2 & 0x7)
! def isFER(self):
return (self.ffw2 & 0x40) == 0x40
! def isMandatoryEnter(self):
return (self.ffw2 & 0x8) == 0x8
! def isToUpper(self):
return (self.ffw2 & 0x20) == 0x20
! def getFieldShift(self):
"""
return bits 5 - 7 of FFW1 which holds the shift adjustment
of the field
"""
return (self.ffw1 & 0x7)
! def isHighlightedEntry(self):
return (self.fcw1 == 0x89)
! def isAutoEnter(self):
return (self.ffw2 & 0x80) == 0x80
! def isSignedNumeric(self):
return (self.getFieldShift() == 7)
! def getKeyPosRC(self,row1,col1):
x = ((row1 * self.screen.getCols()) + col1);
y = x - self.startPos;
self.cursorPos = x;
return y;
! def getKeyPos(self, pos):
y = self.pos - self.startPos
self.cursorPos = pos
return y
! def getCurrentPos(self):
return self.cursorPos
! def withinField(self,pos):
if (pos >= self.startPos) and (pos <= self.endPos):
return 1
return 0
! def startPos(self):
return self.startPos
! def startRow(self):
return self.startPos / self.screen.getCols()
! def startCol(self):
return self.startPos % self.screen.getCols()
! def endPos(self):
return self.endPos
! def toString(self):
return 'startRow =', self.startRow(), 'startCol =',self.startCol(), \
'length =',self.length,'ffw1 = ',self.ffw1,'ffw2 = ',self.ffw1, \
'is bypass field',self.isBypassField(),'isAutoEnter', \
self.isAutoEnter(),'is Mandatory Enter',self.isMandatoryEnter(), \
'modified',self.mdt
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 12:07:08
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv14432/src/lib5250py
Modified Files:
ScreenFields.py
Log Message:
Code cleanup
Index: ScreenFields.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/ScreenFields.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ScreenFields.py 6 Jul 2002 11:12:59 -0000 1.1.1.1
--- ScreenFields.py 6 Mar 2003 12:07:05 -0000 1.2
***************
*** 1,207 ****
! """ScreenFields object
!
! Created by Kenneth J. Pouncey 2002-05-23
! """
!
! import Screen5250
! import ScreenField
!
__all__ = ["SessionFields"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
! CMD_READ_INPUT_FIELDS = 0x42 ## 66
! CMD_READ_MDT_FIELDS = 0x52 ## 82
! CMD_READ_MDT_IMMEDIATE_ALT = 0x83 ## 131
!
! class ScreenFields:
!
! """SessionFields interface class.
!
!
!
! """
! def __init__(self,screen):
! """Constructor.
!
!
! """
! self.debuglevel = DEBUGLEVEL
! self.screen = screen
! self.clearFFT()
!
!
! def set_debuglevel(self, debuglevel):
! """Set the debug level.
!
! The higher it is, the more debug output you get (on sys.stdout).
!
! """
! self.debuglevel = debuglevel
!
! def clearFFT(self):
! """
! clear field format table
!
!
! """
! self.screenFields = []
! self.currentField = None
! self.sizeFields = 0
! self.nextField = 0
! self.fieldIds = 0
! self.cpfExists = 0; # clear the cursor progression fields flag
! masterMDT = 0;
!
! def existsAtPos(self,pos):
! """
! does a field exist at the position passed in
!
! """
! for x in self.fields:
! sf = self.fields[x]
!
! if pos == sf.startPos():
! self.currentField = sf
! return 1
! return 0
!
! def isMasterMDT(self):
! """
! Is the master modified data tag set
!
! """
! return self.masterMDT
!
! def setCurrentField(self,field):
! """
! Set the current field to the field passed in
! """
!
! self.currentField = field
!
! def isCurrentFieldBypassField(self):
! """
! Return whether or not the current field is a bypass field or not
! """
! self.currentField.isBypassField()
!
! def isCurrentField(self):
! """
! Do we have a current field set
!
! """
! return self.currentField == None
!
! def getCurrentField(self):
! """
! return the current field position within the field plane
!
! """
! return self.currentField
!
! def setField(self,attr,row,col,len,ffw1,ffw2,fcw1,fcw2):
! """
! Set a field in the current session screen
!
! """
! self.screenFields.append(ScreenField.ScreenField(self.screen))
! sf = self.screenFields[self.nextField]
! sf.setField(attr,row-1,col-1,len,ffw1,ffw2,fcw1,fcw2)
! self.nextField += 1
! self.sizeFields += 1
!
! if not sf.isBypassField():
! self.fieldIds += 1
! sf.setFieldId(self.fieldIds)
!
! if fcw1 == 0x88:
! self.cpfExists = 1
!
! if self.currentField != None:
! self.currentField.next = sf
! sf.prev = self.currentField
!
! self.currentField = sf
!
! masterMDT = self.currentField.mdt
!
! return self.currentField
!
! def readFormatTable(self,boasp,readType,codePage):
! """
! Read the current screen fields and format them so that they can
! be sent to the Host
! """
!
! isSigned = 0
! sb = None
! if self.isMasterMDT:
!
! for sf in self.screenFields:
!
! if sf.mdt or (readType == CMD_READ_INPUT_FIELDS):
!
! sb = sf.getText()
! if readType == CMD_READ_MDT_FIELDS or \
! readType == CMD_READ_MDT_IMMEDIATE_ALT:
! len2 = len(sb) - 1
!
! while len2 >= 0 and sb[len2] < ' ':
! sb = sb[:-1]
! len2 -= 1
!
! if sf.isSignedNumeric() and len(sb) > 0 and sb[-1] == '-':
! isSigned = 1
!
! len3 = len(sb)
!
! if len3 > 0 or (readType == CMD_READ_MDT_FIELDS or \
! readType == CMD_READ_MDT_IMMEDIATE_ALT):
!
! if len3 > 0 or (readType == CMD_READ_MDT_FIELDS or \
! readType == CMD_READ_MDT_IMMEDIATE_ALT):
!
! boasp.append(17)
! boasp.append(sf.startRow() + 1)
! boasp.append(sf.startCol() + 1)
!
! k = 0
! while k < len3:
! if sb[k] < ' ':
! boasp.append(codePage.uni2ebcdic(' '))
! else:
! if isSigned and k == len3 -1:
! boasp.append(0xd0 | (0x0f & c))
! else:
! boasp.append(ord(codePage.uni2ebcdic(sb[k])))
! k +=1
!
!
! def __getitem__(self,i):
! if i < self.sizeFields:
! return self.screenFields[i]
! else:
! raise IndexError
!
! def getItem(self,i):
! if i < self.sizeFields:
! return self.screenFields[i]
! else:
! raise IndexError
!
! def getCount(self):
! """
! Return the number of fields in the current field plane
! """
! return self.sizeFields
!
! def isInField(self, pos, chgToField):
!
! for sf in self.screenFields:
! if sf.withinField(pos):
! if chgToField:
! self.currentField = sf
! return 1
! return 0
!
--- 1,18 ----
! """ScreenFields object
Created by Kenneth J. Pouncey 2002-05-23
"""
import Screen5250
import ScreenField
__all__ = ["SessionFields"]
! # Tunable parameters
DEBUGLEVEL = 0
CMD_READ_INPUT_FIELDS = 0x42 ## 66
CMD_READ_MDT_FIELDS = 0x52 ## 82
CMD_READ_MDT_IMMEDIATE_ALT = 0x83 ## 131
! class ScreenFields:
"""SessionFields interface class."""
def __init__(self,screen):
"""Constructor."""
self.debuglevel = DEBUGLEVEL
self.screen = screen
self.clearFFT()
! def set_debuglevel(self, debuglevel):
"""Set the debug level.
The higher it is, the more debug output you get (on sys.stdout).
"""
self.debuglevel = debuglevel
! def clearFFT(self):
"""
clear field format table
"""
self.screenFields = []
self.currentField = None
self.sizeFields = 0
self.nextField = 0
self.fieldIds = 0
self.cpfExists = 0; # clear the cursor progression fields flag
masterMDT = 0;
! def existsAtPos(self,pos):
"""
does a field exist at the position passed in
"""
for x in self.fields:
sf = self.fields[x]
if pos == sf.startPos():
self.currentField = sf
return 1
return 0
! def isMasterMDT(self):
""" Is the master modified data tag set """
return self.masterMDT
! def setCurrentField(self,field):
""" Set the current field to the field passed in """
self.currentField = field
! def isCurrentFieldBypassField(self):
"""
Return whether or not the current field is a bypass field or not
"""
self.currentField.isBypassField()
! def isCurrentField(self):
""" Do we have a current field set """
return self.currentField == None
! def getCurrentField(self):
"""
return the current field position within the field plane
"""
return self.currentField
! def setField(self,attr,row,col,len,ffw1,ffw2,fcw1,fcw2):
"""
Set a field in the current session screen
"""
self.screenFields.append(ScreenField.ScreenField(self.screen))
sf = self.screenFields[self.nextField]
sf.setField(attr,row-1,col-1,len,ffw1,ffw2,fcw1,fcw2)
self.nextField += 1
self.sizeFields += 1
if not sf.isBypassField():
self.fieldIds += 1
sf.setFieldId(self.fieldIds)
if fcw1 == 0x88:
self.cpfExists = 1
if self.currentField != None:
self.currentField.next = sf
sf.prev = self.currentField
self.currentField = sf
masterMDT = self.currentField.mdt
return self.currentField
! def readFormatTable(self,boasp,readType,codePage):
"""
Read the current screen fields and format them so that they can
be sent to the Host
"""
isSigned = 0
sb = None
if self.isMasterMDT:
for sf in self.screenFields:
if sf.mdt or (readType == CMD_READ_INPUT_FIELDS):
sb = sf.getText()
if readType == CMD_READ_MDT_FIELDS or \
readType == CMD_READ_MDT_IMMEDIATE_ALT:
len2 = len(sb) - 1
while len2 >= 0 and sb[len2] < ' ':
sb = sb[:-1]
len2 -= 1
if sf.isSignedNumeric() and len(sb) > 0 and sb[-1] == '-':
isSigned = 1
len3 = len(sb)
if len3 > 0 or (readType == CMD_READ_MDT_FIELDS or \
readType == CMD_READ_MDT_IMMEDIATE_ALT):
if len3 > 0 or (readType == CMD_READ_MDT_FIELDS or \
readType == CMD_READ_MDT_IMMEDIATE_ALT):
boasp.append(17)
boasp.append(sf.startRow() + 1)
boasp.append(sf.startCol() + 1)
k = 0
while k < len3:
if sb[k] < ' ':
boasp.append(codePage.uni2ebcdic(' '))
else:
if isSigned and k == len3 -1:
boasp.append(0xd0 | (0x0f & c))
else:
boasp.append(ord(codePage.uni2ebcdic(sb[k])))
k +=1
! def __getitem__(self,i):
if i < self.sizeFields:
return self.screenFields[i]
else:
raise IndexError
! def getItem(self,i):
if i < self.sizeFields:
return self.screenFields[i]
else:
raise IndexError
! def getCount(self):
""" Return the number of fields in the current field plane """
return self.sizeFields
! def isInField(self, pos, chgToField):
for sf in self.screenFields:
if sf.withinField(pos):
if chgToField:
self.currentField = sf
return 1
return 0
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 12:01:59
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv12853/src/lib5250py
Modified Files:
Session.py
Log Message:
Code cleanup
Index: Session.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/Session.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Session.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- Session.py 6 Mar 2003 12:01:56 -0000 1.2
***************
*** 1,73 ****
! """
! Session object
! Created by Kenneth J. Pouncey 2002-05-19
! """
!
! from vt5250 import vt5250
! from Screen5250 import Screen5250
!
__all__ = ["Session"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
! # Telnet Port
! TELNET_PORT = 23
!
! class Session:
!
! """Session interface class."""
!
! def __init__(self,host=None,port=0):
!
! """Constructor."""
!
! self.debuglevel = DEBUGLEVEL
! self.vt = vt5250()
! self.vt.set_debuglevel(self.debuglevel)
! self.screen = Screen5250()
! self.screen.set_debuglevel(self.debuglevel)
! self.vt.setScreen(self.screen)
! self.screen.setVT(self.vt)
!
! if host:
! self.host = host
! else:
! self.host = 'localhost'
!
! if port:
! self.setPort(port)
! else:
! self.port = TELNET_PORT
!
! def set_debuglevel(self, debuglevel):
! """
! Set the debug level.
! The higher it is, the more debug output you get (on sys.stdout).
! """
! self.debuglevel = debuglevel
! self.vt.set_debuglevel(self.debuglevel)
! self.screen.set_debuglevel(self.debuglevel)
!
! def connect(self):
! self.vt.open(self.host,self.port)
!
! def disconnect(self):
! self.vt.close()
!
! def setHost(self,host):
! self.host = host
!
! def setPort(self,port):
! try:
! self.port = int(port)
! except ValueError:
! self.port = TELNET_PORT
!
! def getScreen(self):
! return self.screen
!
!
!
!
!
--- 1,10 ----
! """
Session object
Created by Kenneth J. Pouncey 2002-05-19
"""
from vt5250 import vt5250
from Screen5250 import Screen5250
__all__ = ["Session"]
! # Tunable parameters
DEBUGLEVEL = 0
# Telnet Port
TELNET_PORT = 23
! class Session:
"""Session interface class."""
def __init__(self,host=None,port=0):
"""Constructor."""
self.debuglevel = DEBUGLEVEL
self.vt = vt5250()
self.vt.set_debuglevel(self.debuglevel)
self.screen = Screen5250()
self.screen.set_debuglevel(self.debuglevel)
self.vt.setScreen(self.screen)
self.screen.setVT(self.vt)
if host:
self.host = host
else:
self.host = 'localhost'
if port:
self.setPort(port)
else:
self.port = TELNET_PORT
! def set_debuglevel(self, debuglevel):
"""
Set the debug level.
The higher it is, the more debug output you get (on sys.stdout).
"""
self.debuglevel = debuglevel
self.vt.set_debuglevel(self.debuglevel)
self.screen.set_debuglevel(self.debuglevel)
! def connect(self):
self.vt.open(self.host,self.port)
! def disconnect(self):
self.vt.close()
! def setHost(self,host):
self.host = host
! def setPort(self,port):
try:
self.port = int(port)
except ValueError:
self.port = TELNET_PORT
! def getScreen(self):
return self.screen
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 12:00:13
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv12201/src/lib5250py
Modified Files:
SessionManager.py
Log Message:
Code cleanup
Index: SessionManager.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/SessionManager.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SessionManager.py 19 Jul 2002 16:30:35 -0000 1.2
--- SessionManager.py 6 Mar 2003 12:00:09 -0000 1.3
***************
*** 3,7 ****
Created by Nathanael Custer 2002-07-01
"""
-
from Sessions import Sessions
--- 3,6 ----
***************
*** 10,28 ****
# Tunable parameters
DEBUGLEVEL = 0
!
! # Telnet Port
! TELNET_PORT = 23
class SessionManager:
def __init__(self):
self.MasterSessionList = Sessions()
def getSessions(self):
return self.MasterSessionList
def openSession(self, name=''):
self.MasterSessionList._addSession(name)
return self.MasterSessionList.item(name)
def closeSession(self, name=''):
session = self.MasterSessionList.item(name)
self.MasterSessionList._delSession(name)
def refresh(self):
return self.MasterSessionList
--- 9,29 ----
# Tunable parameters
DEBUGLEVEL = 0
! # Telnet Port
TELNET_PORT = 23
class SessionManager:
def __init__(self):
self.MasterSessionList = Sessions()
+
def getSessions(self):
return self.MasterSessionList
+
def openSession(self, name=''):
self.MasterSessionList._addSession(name)
return self.MasterSessionList.item(name)
+
def closeSession(self, name=''):
session = self.MasterSessionList.item(name)
self.MasterSessionList._delSession(name)
+
def refresh(self):
return self.MasterSessionList
***************
*** 42,44 ****
print "One less"
print a.list
-
--- 43,44 ----
|
|
From: <pb...@us...> - 2003-03-06 11:59:08
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv11738/src/lib5250py
Modified Files:
Sessions.py
Log Message:
Code cleanup
Index: Sessions.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/Sessions.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Sessions.py 19 Jul 2002 16:30:35 -0000 1.2
--- Sessions.py 6 Mar 2003 11:59:04 -0000 1.3
***************
*** 1,40 ****
! """
! SessionManager and Sessions objects
! Created by Nathanael Custer 2002-07-01
! """
!
! from Session import Session
!
__all__ = ["Sessions"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
! # Telnet Port
! TELNET_PORT = 23
!
! class Sessions:
! def __init__(self):
! self.list = []
! def _addSession(self, name=''):
! session = [name, Session()]
! self.list.append(session)
! def _delSession(self, name=''):
! for x in self.list:
! if name == x[0]:
! self.list.remove(x)
! # else:
! # raise error here
! def item(self, name=''):
! for x in self.list:
! if name == x[0]:
! return x[1]
! def item_index(self, index=0):
! return self.list[index][1]
! def _list(self):
! return self.list
!
!
!
!
!
--- 1,9 ----
! """
SessionManager and Sessions objects
Created by Nathanael Custer 2002-07-01
"""
from Session import Session
__all__ = ["Sessions"]
! # Tunable parameters
DEBUGLEVEL = 0
# Telnet Port
TELNET_PORT = 23
! class Sessions:
def __init__(self):
self.list = []
! def _addSession(self, name=''):
session = [name, Session()]
self.list.append(session)
! def _delSession(self, name=''):
for x in self.list:
if name == x[0]:
self.list.remove(x)
#else:
#raise error here
! def item(self, name=''):
for x in self.list:
if name == x[0]:
return x[1]
! def item_index(self, index=0):
return self.list[index][1]
! def _list(self):
return self.list
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 11:57:30
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv11310/src/lib5250py
Modified Files:
testsession.py
Log Message:
code cleanup
Index: testsession.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/testsession.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** testsession.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- testsession.py 6 Mar 2003 11:57:27 -0000 1.2
***************
*** 1,81 ****
! import Session
! import Screen5250
! import ScreenFields
! import CodePage
! from sys import argv
!
! __all__ = ["testsession"]
!
! myScreen = None
!
! class testsession:
!
! def __init__(self):
! self.first = 1
! self.USERID = None
! self.PASSWORD = None
!
! def outputScreen(self,initiator,startRow,startColumn,endRow,endColumn):
! """
! Callable method to get screen updates
! """
! print 'ScreenUpdated - initiated from ',initiator, \
! ' Starting from -> ',startRow,endRow,' to -> ',endRow,endColumn
!
! if initiator == 0: ## 0 is from client and 1 is from host
! return
!
! # Note we only print the first 12 rows here
! indices = range(1,24)
! # for idx in indices:
! # print myScreen.getPlaneData(idx,1,idx,80,1)
! # print self.screen.getPlaneData(idx,1,80,2)
!
! fields = myScreen.getFields()
!
! if self.USERID == None or self.PASSWORD == None:
! self.USERID = raw_input("What's your username ? > ")
! self.PASSWORD = raw_input("What's your password ? > ")
!
! if self.first == 1:
! field = fields.getItem(0)
! field.setString(self.USERID)
! field = fields.getItem(1)
! field.setString(self.PASSWORD)
!
! for field in fields:
! # print field.toString()
! print field.getText()
!
! # print fields.readFormatTable(0x42,CodePage.CodePage())
! # print myScreen.getFields().readFormatTable(0x52,CodePage.CodePage())
! # Note we only print the first 12 rows here
! indices = range(1,25)
! for idx in indices:
! print myScreen.getPlaneData(idx,1,idx,80,1)
!
! print 'number of fields',myScreen.getFields().getCount()
!
! if self.first < 7:
! myScreen.sendAidKey(0xF1)
! self.first += 1
!
!
! if __name__ == '__main__':
!
!
! if len(argv) >= 2: host = argv[1]
! else:
! host = raw_input('Enter the name of the AS/400-machine > ')
!
!
! ts = testsession()
! if len(argv) > 3:
! ts.USERID = argv[2]
! ts.PASSWORD = argv[3]
! session = Session.Session(host)
! session.set_debuglevel(1)
! myScreen = session.getScreen()
! session.getScreen().add_screen_listener(ts.outputScreen)
! session.connect()
!
--- 1,5 ----
! import Session
import Screen5250
import ScreenFields
import CodePage
from sys import argv
! __all__ = ["testsession"]
myScreen = None
! class testsession:
def __init__(self):
self.first = 1
self.USERID = None
self.PASSWORD = None
! def outputScreen(self,initiator,startRow,startColumn,endRow,endColumn):
"""
Callable method to get screen updates
"""
print 'ScreenUpdated - initiated from ',initiator, \
' Starting from -> ',startRow,endRow,' to -> ',endRow,endColumn
if initiator == 0: ## 0 is from client and 1 is from host
return
# Note we only print the first 12 rows here
indices = range(1,24)
#for idx in indices:
#print myScreen.getPlaneData(idx,1,idx,80,1)
#print self.screen.getPlaneData(idx,1,80,2)
fields = myScreen.getFields()
if self.USERID == None or self.PASSWORD == None:
self.USERID = raw_input("What's your username ? > ")
self.PASSWORD = raw_input("What's your password ? > ")
if self.first == 1:
field = fields.getItem(0)
field.setString(self.USERID)
field = fields.getItem(1)
field.setString(self.PASSWORD)
for field in fields:
#print field.toString()
print field.getText()
#print fields.readFormatTable(0x42,CodePage.CodePage())
#print myScreen.getFields().readFormatTable(0x52,CodePage.CodePage())
# Note we only print the first 12 rows here
indices = range(1,25)
for idx in indices:
print myScreen.getPlaneData(idx,1,idx,80,1)
print 'number of fields',myScreen.getFields().getCount()
if self.first < 7:
myScreen.sendAidKey(0xF1)
self.first += 1
! if __name__ == '__main__':
if len(argv) >= 2: host = argv[1]
else:
host = raw_input('Enter the name of the AS/400-machine > ')
ts = testsession()
if len(argv) > 3:
ts.USERID = argv[2]
ts.PASSWORD = argv[3]
session = Session.Session(host)
session.set_debuglevel(1)
myScreen = session.getScreen()
session.getScreen().add_screen_listener(ts.outputScreen)
session.connect()
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 11:54:08
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv9983/src/lib5250py
Modified Files:
vt5250.py
Log Message:
Code cleanup because of corrupted upload.
Index: vt5250.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/vt5250.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** vt5250.py 6 Jul 2002 11:12:59 -0000 1.1.1.1
--- vt5250.py 6 Mar 2003 11:54:04 -0000 1.2
***************
*** 1,1023 ****
! """Enhanced Telnet 5250 client class.
! Based on RFC 1205: 5250 Telnet Protocol Specification, by P. Chmielewski
! Example:
! >>>from tnvtlib import Telnet5250 tn = Telnet5250('www.net400.org', 23)
! >>>connect to as400 host
! Created by Kenneth J. Pouncey 2002-05-10
! """
!
! # Imported modules
! import sys
[...1042 lines suppressed...]
! def process_negotiations(self):
"""
Transfer from raw queue to cooked queue.
Set self.eof when connection is closed.
Don't block unless in the midst of an IAC sequence.
"""
buf = ''
done = 0
try:
c = self.rawq_getchar()
while c == IAC:
c = self.rawq_getchar()
if c == IAC:
buf = buf + c
elif c == DO:
opt = self.rawq_getchar()
if opt == NEW_ENVIRONMENT:
self.msg('IAC DO NEW_ENVIRONMENT')
self.msg('sending : IAC WONT NEW_ENVIRONMENT')
self.sock.send(IAC + WONT + NEW_ENVIRONMENT)
elif opt == TERMINAL_TYPE:
self.msg('IAC DO TERMINAL_TYPE')
self.msg('sending : IAC WILL TERMINAL_TYPE')
self.sock.send(IAC + WILL + TERMINAL_TYPE)
elif opt == OPT_END_OF_RECORD:
self.msg('IAC DO OPT_END_OF_RECORD')
self.msg('sending : IAC WILL OPT_END_OF_RECORD')
self.sock.send(IAC + WILL + OPT_END_OF_RECORD)
elif opt == TRANSMIT_BINARY:
self.msg('IAC DO TRANSMIT_BINARY')
self.msg('sending: IAC WILL TRANSMIT_BINARY')
self.sock.send(IAC + WILL + TRANSMIT_BINARY)
else:
# default that we wont
self.msg('IAC DO %d', ord(opt))
self.msg('sending : IAC WONT %d', ord(opt))
self.sock.send(IAC + WONT + opt)
elif c == DONT:
opt = self.rawq_getchar()
self.msg('IAC %s %d', c == DO and 'DO' or 'DONT', \
ord(c))
self.sock.send(IAC + WONT + opt)
elif c == WILL:
opt = self.rawq_getchar()
if opt == OPT_END_OF_RECORD:
self.msg('IAC WILL OPT_END_OF_RECORD')
self.msg('sending : IAC DO OPT_END_OF_RECORD')
self.sock.send(IAC + DO + OPT_END_OF_RECORD)
elif opt == TRANSMIT_BINARY:
self.msg('IAC WILL TRANSMIT_BINARY')
self.msg('sending : IAC DO TRANSMIT_BINARY')
self.sock.send(IAC + DO + TRANSMIT_BINARY)
else:
self.msg('IAC WILL %d', ord(opt))
self.msg('sending : IAC DONT %d', ord(opt))
self.sock.send(IAC + DONT + opt)
elif c == WONT:
opt = self.rawq_getchar()
self.msg('IAC %s %d',
c == WILL and 'WILL' or 'WONT', ord(c))
self.sock.send(IAC + DONT + opt)
elif c == SB:
sbOpt = self.rawq_getchar()
if sbOpt == TERMINAL_TYPE:
if self.rawq_getchar() == chr(1):
self.msg('sending: TERMINAL_TYPE')
self.sock.send(IAC + SB + TERMINAL_TYPE + \
QUAL_IS + 'IBM-3179-2' + \
IAC + SE)
elif c == SE:
self.msg('ENDING Subnegotiation')
else:
self.msg('IAC %s not recognized' % `c`)
c = self.rawq_getchar()
except EOFError: # raised by self.rawq_getchar()
pass
self.cookedq = self.cookedq + buf
self.buffer = self.rawq
! def negotiate_session(self):
self.process_negotiations()
while not self.cookedq and not self.eof and self.sock_avail():
self.fill_rawq()
self.process_negotiations()
! def interact(self):
"""Interaction function, emulates a very dumb telnet client."""
while 1:
try:
text = self.negotiate_session()
if not text:
break
except EOFError:
break
self.mt_interact()
! def mt_interact(self):
"""Multithreaded version of interact()."""
import threading
self.running = 1
self.dataProducerThread = threading.Thread(target=self.listener)
self.dataProducerThread.start()
self.dataConsumerThread = \
threading.Thread(target=self.parse_stream)
self.dataConsumerThread.start()
! def listener(self):
"""Helper for mt_interact() -- this executes in the other thread."""
# load the first response from host
self.loadStream(self.buffer)
while self.running:
try:
print 'listener running'
self.read_incoming()
except EOFError:
print '*** Connection closed by remote host ***'
return
print 'ended'
! def parse_stream(self):
import struct
import operator
self.msg ('parse stream running')
while self.running:
self.dataStream = self.queue.get()
if self.dataStream == None:
print 'data stream is None'
self.running = 0
continue
# Check contents of message and do what it says
# As a test, we simply print it
self.msg( 'message from queue %s', `self.dataStream`)
self.msgLen = ((ord(self.dataStream[0]) & 0xff) << 8) | \
(ord(self.dataStream[1]) & 0xff)
opcode = ord(self.dataStream[9] )
dataStart = 6 + ord(self.dataStream[6])
self.pos = dataStart
self.msg( 'opcode from stream buffer %s', `opcode`)
self.msg( 'msg length from stream buffer %s', \
`self.msgLen`)
self.msg( 'data start from stream buffer %s', `dataStart`)
if opcode == 0:
self.msg( 'No Operation ')
elif opcode == 1:
self.msg( 'Invite Operation ')
self.parseIncoming()
elif opcode == 2:
self.msg( 'Output only ')
self.parseIncoming()
elif opcode == 3:
self.msg( 'Put/Get Operation ')
self.parseIncoming()
elif opcode == 4:
self.msg( 'Save Screen Operation ')
self.parseIncoming()
elif opcode == 5:
self.msg( 'Restore Screen Operation ')
self.parseIncoming()
elif opcode == 6:
self.msg( 'Read Immediate ')
elif opcode == 7:
self.msg( 'Reserved ')
elif opcode == 8:
self.msg( 'Read Screen Operation ')
elif opcode == 9:
self.msg( 'Reserved ')
elif opcode == 10:
self.msg( 'Cancel Invite ')
elif opcode == 11:
self.msg( 'Turn on message light ')
elif opcode == 12:
self.msg( 'Turn off message light ')
else:
self.msg( 'Invalid Operation Code ')
self.msg('at end of queue')
! def parseIncoming(self):
"""Parse the incoming data stream."""
buf = ''
done = 0
error = 0
control0 = 0
control1 = 0
controlChars = 0
while self.pos < self.msgLen and not done:
self.pos += 1
b = ord(self.dataStream[self.pos] )
if b == 0 or b == 1 or b == 4:
pass
elif b == 2 or b == 3:
self.msg( 'Save Screen')
elif b == 7:
self.msg( 'Audible bell')
self.pos += 2
elif b == 17:
self.msg( 'Write to display')
self.writeToDisplay(0)
elif b == 18 or b == 19:
self.msg( 'Restore Screen')
elif b == 32:
self.msg( 'Clear unit Alternate')
self.screen.clearAll()
elif b == 33:
self.msg( 'Write Error Code')
elif b == 34:
self.msg( 'Write Error Code to Window')
elif b == 64:
self.msg( 'Clear Unit')
self.screen.clearAll()
elif b == 80:
self.msg( 'Clear Format Table')
self.screen.clearFFT()
elif b == 98 or b == 102:
self.msg( 'Read Screen Immediate')
elif b == 66 or b == 82:
self.msg( 'Read Input Fields or MDT Fields ')
self.readType = b
self.screen.goHome()
self.screen.notify_screen_listeners(1)
elif b == 83:
self.msg( 'Read MDT Immediate Alt')
elif b == 243:
self.msg( 'Write Structured Field')
self.writeStructuredField()
else:
self.msg( 'invalid option %s',b)
! def writeToDisplay(self,controlsExist):
"""Parse the incoming data stream."""
pos = 0
error = 0
done = 0
attr = 0
nextOne = 0
control0 = 0
control1 = 0
# initialize from Screen object later
saRows = 24
saColumns = 80
if controlsExist:
self.pos += 1
control0 = self.dataStream[self.pos]
self.pos += 1
control1 = self.dataStream[self.pos]
#print 'in write to display'
while self.pos < self.msgLen and not done:
self.pos += 1
which1 = ord(self.dataStream[self.pos])
if which1 == 1: # Start of Header
self.msg( 'Start of Header')
error = self.processSOH()
elif which1 == 2: # Repeat to Address
row = self.screen.getCurrentRow()
col = self.screen.getCurrentCol()
self.pos += 1
toRow = ord(self.dataStream[self.pos])
self.pos += 1
toCol = (ord(self.dataStream[self.pos]) & 0xff)
rows = self.screen.getRows()
cols = self.screen.getCols()
if toRow >= row:
self.pos += 1
repeat = ord(self.dataStream[self.pos])
if row == 1 and col == 2 and toRow == rows and \
toCol == cols:
! self.screen.clearAll()
else:
if repeat != 0:
repeat = self.getASCIIChar(repeat)
times = ((toRow * cols) + toCol) - \
((row * cols) + col)
while times >= 0:
self.screen.setChar(repeat)
times -= 1
self.msg( 'RA - Repeat to address %s, %s',toRow,toCol)
elif which1 == 3: # EA - Erase to address
# need to implement later
self.msg( 'Erase to Address')
elif which1 == 4: # Escape
done = 1
self.msg('Escape')
elif which1 == 16: # Transparent Data
# need to implent later
self.msg('Transparent Data')
elif which1 == 17: # SBA - Set buffer address
self.pos += 1
saRow = ord(self.dataStream[self.pos])
self.pos += 1
saCol = (ord(self.dataStream[self.pos]) & 0xff)
self.screen.moveTo(saRow,saCol)
self.msg('SBA - Set buffer Address %s %s',saRow,saCol)
elif which1 == 18: # WEA - Extended Attribute
self.pos += 1
self.dataStream[self.pos]
self.pos += 1
self.dataStream[self.pos]
self.msg('WEA - Extended Attribute')
elif which1 == 19 or which1 == 20 : # IC - Insert Cursor
# MC - Move Cursor
self.pos += 1
icX = ord(self.dataStream[self.pos])
self.pos += 1
icY = (ord(self.dataStream[self.pos]) & 0xff)
self.msg( 'IC or MC - Insert Cursor or Move Cursor \
%s,%s',icX,icY)
self.screen.setPendingInsert(1,icX,icY)
elif which1 == 21:
# WTDSF - Write to Display Structured Field order
# implement later
self.msg( 'WTDSF - \
Write to Display Structured Field order')
elif which1 == 29: # SOF - Start of field
"""Subtopic 15.6.12"""
# lets initialize the Field format
# word and field control word
fcw1 = 0
fcw2 = 0
ffw1 = 0
ffw0 = 0
# get the first byte of the Field format word
self.pos += 1
ffw0 = ord(self.dataStream[self.pos]) # FFW0
# The first two bits of this byte determine if the FFW
# exits or not because it is optional we use a logical and
# to get the value of the first two bits. If the first
# two bits contain the value 01 then we have a Field format
# word.
if (ffw0 & 0x40) == 0x40:
self.pos += 1
ffw1 = (ord(self.dataStream[self.pos]) & 0xff) # FFW1
self.pos += 1
fcw1 = (ord(self.dataStream[self.pos]) & 0xff)
#check for field
# after processing the Field format word we check if
# the next byte is the field attribute byte or not.
# If it is not an attribute byte then we have a field
# control word and the attribute will follow the next
# two bytes.
if not self.isAttribute(fcw1):
self.pos += 1
fcw2 = (ord(self.dataStream[self.pos]) & 0xff)
# FCW2
self.pos += 1
attr = (ord(self.dataStream[self.pos]) & 0xff)
# attribute
else:
attr = fcw1 # attribute of field
fcw1 = 0
else:
# If the check for the Field format word was not
# successful then we just use the byte read as the
# field attribute
attr = ffw0
# We then parse the length of the field by using the next
# to bytes. Shifting the first byte and using logical or
# of the next byte will obtain us the length of the field
fLength = ((ord(self.dataStream[self.pos + 1]) & 0xff) \
<< 8) | (ord(self.dataStream[self.pos + 2]) \
& 0xff)
self.pos += 2
self.screen.addField(attr,fLength,ffw0,ffw1,fcw1,fcw2)
self.msg(' Start of field with <length %s> <ffw0 %s> \
<ffw1 %s> <fcw1 %s> <fcw2 %s>',fLength,ffw0,ffw1,fcw1,fcw2)
else:
byte0 = (ord(self.dataStream[self.pos]) & 0xff)
if self.isAttribute(byte0):
self.screen.setAttr(byte0)
elif byte0 < 64:
self.screen.setChar(byte0)
else:
self.screen.setChar(self.getASCIIChar(byte0))
if error:
done = 1
return error
! def processSOH(self):
""" Process start of header information """
self.pos += 1
len = ord(self.dataStream[self.pos])
if len > 0 and len <= 7:
self.pos += 1
self.dataStream[self.pos] # flag byte 2
self.pos += 1
self.dataStream[self.pos] # Reserved
self.pos += 1
self.dataStream[self.pos] # Resequence fields
# add support for parse error line later
self.pos += 1
self.dataStream[self.pos] # Error line
byte1 = 0
if len >= 5 :
self.pos += 1
byte1 = ord(self.dataStream[self.pos])
if len >= 6 :
self.pos += 1
byte1 = ord(self.dataStream[self.pos])
if len >= 7 :
self.pos += 1
byte1 = ord(self.dataStream[self.pos])
return 0
else:
return 1
! def isAttribute(self,byte):
""" Check if the byte is an attribute byte or not """
return (byte & 0xe0) == 0x20;
! def getASCIIChar(self,byte):
return self.codePage.ebcdic2uni(byte)
! def setScreen(self,screen):
self.screen = screen
! def sendAidKey(self,aid):
"""
Send aid key and associated field format data to host
"""
boasp = []
boasp.append(self.screen.getCurrentRow())
boasp.append(self.screen.getCurrentCol())
boasp.append(aid)
self.screen.getFields().readFormatTable(boasp,self.readType,self.codePage)
self.writeGDS(0,3,boasp)
! def writeStructuredField(self):
"""
Write structured field for query message response
"""
length = ((ord(self.dataStream[self.pos + 1]) & 0xff) \
<< 8) | (ord(self.dataStream[self.pos + 2]) \
& 0xff)
self.pos += 2
print length
self.pos += 1
StartOfHeaderOrder = ord(self.dataStream[self.pos])
print StartOfHeaderOrder
self.pos += 1
queryrequest = ord(self.dataStream[self.pos])
print queryrequest
self.pos += 1
ord(self.dataStream[self.pos])
print 'now lets send query response'
self.sendQueryResponse()
! def sendQueryResponse(self):
"""
The query command is used to obtain information about the capabilities
of the 5250 display.
The Query command must follow an Escape (0x04) and Write Structured
Field command (0xF3).
This section is modeled after the rfc1205 - 5250 Telnet Interface section
5.3
"""
abyte = []
abyte.append(0x00) ## Cursor row column set to 0,0
abyte.append(0x00)
abyte.append(0x88) ## 0x88 inbound write structure field aid
abyte.append(0x00) ## length of query response
abyte.append(0x3A) ## Set to 58 for normal emulation
abyte.append(0xD9) ## command class
abyte.append(0x70) ## command type query
abyte.append(0x80) ## Flag byte
abyte.append(0x06) ## controller hardware class
abyte.append(0x00) ## 0x0600 - other WSF or another 5250 emulator
abyte.append(0x01) ## Controller Code Level
abyte.append(0x01)
abyte.append(0x00)
abyte.append(0x0) ## 13 - 28 are reserved
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x01) ## device type - 0x01 5250 Emulator
abyte.append(ord(self.codePage.uni2ebcdic('5'))) ## device type character
abyte.append(ord(self.codePage.uni2ebcdic('2')))
abyte.append(ord(self.codePage.uni2ebcdic('5')))
abyte.append(ord(self.codePage.uni2ebcdic('1')))
abyte.append(ord(self.codePage.uni2ebcdic('0')))
abyte.append(ord(self.codePage.uni2ebcdic('1')))
abyte.append(ord(self.codePage.uni2ebcdic('1')))
abyte.append(0x02) ## keyboard id - 0x02 Standard Keyboard
abyte.append(0x00) ## extended keyboard id
abyte.append(0x00) ## reserved
abyte.append(0x00) ## 40 - 43 Display Serial Number
abyte.append(36)
abyte.append(36)
abyte.append(0x00)
abyte.append(0x01) ## Maximum number of display fields - 256
abyte.append(0x00) ## 0x0100
abyte.append(0x0) ## 46 - 48 reserved set to 0x00
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x01) ## 49 - 53 Controller Display Capability
abyte.append(16)
abyte.append(0x0)
abyte.append(0x0)
"""
53
Bit 0-2: B'000' - no graphics capability
B'001' - 5292-2 style graphics
Bit 3-7: B '00000' = reserved (it seems for Client access)
"""
abyte.append(0x0) ## 0x0 is normal emulation
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
abyte.append(0x0)
self.writeGDS(0,0,abyte)
! def test():
"""Test program for tnvtlib.
Usage: python tnvtlib.py [-d] ... [host [port]]
Default host is localhost; default port is 23.
"""
import signal
import Screen5250
debuglevel = 0
while sys.argv[1:] and sys.argv[1] == '-d':
debuglevel = debuglevel+1
del sys.argv[1]
host = 'localhost'
if sys.argv[1:]:
host = sys.argv[1]
port = 0
if sys.argv[2:]:
portstr = sys.argv[2]
try:
port = int(portstr)
except ValueError:
port = socket.getservbyname(portstr, 'tcp')
tn = vt5250()
tn.set_debuglevel(debuglevel)
tn.setScreen(Screen5250.Screen5250())
tn.open(host, port)
while tn.running:
pass
tn.close()
print 'I am here'
sys.exit
print 'After exit'
! def onSignal(signum, stackFrame):
"""
Let's capture the signals and close connections
so we do not get zombie processes.
"""
tn.close()
! if __name__ == '__main__':
test()
\ No newline at end of file
|
|
From: <pb...@us...> - 2003-03-06 11:20:11
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory sc8-pr-cvs1:/tmp/cvs-serv25346/src/lib5250py
Modified Files:
tn5250.py
Log Message:
Cleaning up modules because of wrong upload.
Index: tn5250.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/tn5250.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** tn5250.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- tn5250.py 6 Mar 2003 11:20:06 -0000 1.2
***************
*** 1,161 ****
! #!/usr/local/bin/python
!
! #########################################################################
! # Tk8.0 style main window menus #
! #########################################################################
!
! from Tkinter import * # get widget classes
! from tkMessageBox import * # get standard dialogs
! from tkSimpleDialog import askstring
! import Session
! import Screen5250
! import ScreenFields
! from SessionManager import SessionManager
! #import Sessions
! import CodePage
! from sys import argv
!
__all__ = ["testsession"]
!
! class StartFrame(Frame): # an extended frame
! def __init__(self, parent=None): # attach to top-level?
! self.first = 1
! self.USERID = None
! self.PASSWORD = None
! self.myScreen = None
!
! Frame.__init__(self, parent) # do superclass init
! self.canvas = Canvas(parent,width=600,height=500, bg='black')
! self.manager = SessionManager()
! self.pack()
! self.createWidgets() # attach frames/widgets
! self.master.title("TN5250 for Python - Testing")
! self.master.iconname("TN5250") # label when iconified
! self.strprg()
!
! def outputScreen(self,initiator,startRow,startColumn,endRow,endColumn):
! """
! Callable method to get screen updates
! """
! print 'ScreenUpdated - initiated from ',initiator, \
! ' Starting from -> ',startRow,endRow,' to -> ', \
! endRow,endColumn
!
! if initiator == 0: ## 0 is from client and 1 is from host
! return
!
! # Note we only print the first 12 rows here
! indices = range(1,24)
! # for idx in indices:
! # print self.myScreen.getPlaneData(idx,1,idx,80,1)
! # print self.screen.getPlaneData(idx,1,80,2)
!
fields = self.myScreen.getFields()
!
! if self.USERID == None or self.PASSWORD == None:
! self.USERID = raw_input("What's your username ? > ")
! self.PASSWORD = raw_input("What's your password ? > ")
!
! if self.first == 1:
! field = fields.getItem(0)
! field.setString(self.USERID)
! field = fields.getItem(1)
! field.setString(self.PASSWORD)
!
! for field in fields:
! # print field.toString()
! print field.getText()
!
! # print fields.readFormatTable(0x42,CodePage.CodePage())
! # print myScreen.getFields().readFormatTable(0x52,CodePage.CodePage())
! # Note we only print the first 12 rows here
! indices = range(1,25)
! row = 0
! for idx in indices:
! text = self.myScreen.getPlaneData(idx,1,idx,80,1)
! row += 15
! col = 0
! indx = range(0,79)
! for x in indx:
! col += 10
! self.canvas.create_text(col,row,text=text[x], anchor=E, fill='green')
!
! print 'number of fields',self.myScreen.getFields().getCount()
!
! """
! Patrick here I just keep pressing enter so that the screens
! keep coming up to see the messages. Actually 6 times.
! the first is to send username and password. Then 2 more times
! to get passed messages and stuff. Then 2 more times to
! get messages at the bottom of the screen to make sure all is
! coming up. Change this number if you want less for now.
! """
! if self.first < 7:
! self.myScreen.sendAidKey(0xF1)
! self.first += 1
!
! def strprg(self):
!
! if len(argv) >= 2: host = argv[1]
! else:
! host = askstring('Hostname', "Name of the Host ?")
!
! ## ts = testsession()
!
! if len(argv) > 3:
! self.USERID = argv[2]
! self.PASSWORD = argv[3]
!
! session = self.manager.openSession('Session 1')
! session.setHost(host)
! ## session = Session.Session(host)
! session.set_debuglevel(1)
! self.myScreen = session.getScreen()
! session.getScreen().add_screen_listener(self.outputScreen)
! session.connect()
!
! def createWidgets(self):
! self.makeMenuBar()
! # self.canvas = self.root.createcomponent('canvas', (), None, \
! # Canvas, (self.interior(),), width=self.width, \
! # height=self.height,background="black")
! self.canvas.pack(fill=BOTH)
! # text = Text(self, relief=SUNKEN, fg='green', bg='black', \
! # width=150, height=50)
! # text.pack(fill=BOTH)
!
! def makeMenuBar(self):
! self.menubar = Menu(self.master)
! self.master.config(menu=self.menubar) # master=top-level window
! self.fileMenu()
! self.editMenu()
!
! def fileMenu(self):
! pulldown = Menu(self.menubar, tearoff=0)
! pulldown.add_command(label='Open...', command=self.notdone, \
! underline=0)
! pulldown.add_command(label='Quit', command=self.quit, \
! underline=0)
! pulldown.entryconfig(0, state=DISABLED)
! self.menubar.add_cascade(label='File', underline=0, menu=pulldown)
!
! def editMenu(self):
! pulldown = Menu(self.menubar, tearoff=0)
! pulldown.add_command(label='Copy', command=self.notdone)
! pulldown.add_command(label='Paste', command=self.notdone)
! pulldown.entryconfig(0, state=DISABLED)
! pulldown.entryconfig(1, state=DISABLED)
! self.menubar.add_cascade(label='Edit', underline=0, menu=pulldown)
!
! def notdone(self):
! showerror('Not implemented', 'Not yet available')
!
! def quit(self):
! if askyesno('Verify quit', 'Are you sure you want to quit?'):
! Frame.quit(self)
!
! if __name__ == '__main__':
! # root = Tk()
! StartFrame().mainloop()
! # root.mainloop() # if I'm run as a script
!
--- 1,30 ----
! #!/usr/local/bin/python
#########################################################################
# Tk8.0 style main window menus #
#########################################################################
! from Tkinter import * # get widget classes
from tkMessageBox import * # get standard dialogs
from tkSimpleDialog import askstring
import Session
import Screen5250
import ScreenFields
from SessionManager import SessionManager
#import Sessions
import CodePage
from sys import argv
__all__ = ["testsession"]
! class StartFrame(Frame): # an extended frame
def __init__(self, parent=None): # attach to top-level?
self.first = 1
self.USERID = None
self.PASSWORD = None
self.myScreen = None
! Frame.__init__(self, parent) # do superclass init
self.canvas = Canvas(parent,width=600,height=500, bg='black')
self.manager = SessionManager()
self.pack()
! self.createWidgets() # attach frames/widgets
self.master.title("TN5250 for Python - Testing")
self.master.iconname("TN5250") # label when iconified
self.strprg()
! def outputScreen(self,initiator,startRow,startColumn,endRow,endColumn):
"""
Callable method to get screen updates
"""
print 'ScreenUpdated - initiated from ',initiator, \
' Starting from -> ',startRow,endRow,' to -> ', \
endRow,endColumn
! if initiator == 0: ## 0 is from client and 1 is from host
return
! # Note we only print the first 12 rows here
indices = range(1,24)
! # for idx in indices:
# print self.myScreen.getPlaneData(idx,1,idx,80,1)
# print self.screen.getPlaneData(idx,1,80,2)
fields = self.myScreen.getFields()
! if self.USERID == None or self.PASSWORD == None:
self.USERID = raw_input("What's your username ? > ")
self.PASSWORD = raw_input("What's your password ? > ")
! if self.first == 1:
field = fields.getItem(0)
field.setString(self.USERID)
field = fields.getItem(1)
field.setString(self.PASSWORD)
! for field in fields:
#print field.toString()
print field.getText()
! #print fields.readFormatTable(0x42,CodePage.CodePage())
#print myScreen.getFields().readFormatTable(0x52,CodePage.CodePage())
# Note we only print the first 12 rows here
indices = range(1,25)
row = 0
! for idx in indices:
text = self.myScreen.getPlaneData(idx,1,idx,80,1)
row += 15
col = 0
indx = range(0,79)
for x in indx:
col += 10
self.canvas.create_text(col,row,text=text[x], anchor=E, fill='green')
! print 'number of fields',self.myScreen.getFields().getCount()
"""
Patrick here I just keep pressing enter so that the screens
keep coming up to see the messages. Actually 6 times.
the first is to send username and password. Then 2 more times
to get passed messages and stuff. Then 2 more times to
get messages at the bottom of the screen to make sure all is
coming up. Change this number if you want less for now.
"""
! if self.first < 7:
self.myScreen.sendAidKey(0xF1)
self.first += 1
! def strprg(self):
if len(argv) >= 2: host = argv[1]
else:
host = askstring('Hostname', "Name of the Host ?")
! #ts = testsession()
! if len(argv) > 3:
self.USERID = argv[2]
self.PASSWORD = argv[3]
! session = self.manager.openSession('Session 1')
session.setHost(host)
#session = Session.Session(host)
! session.set_debuglevel(1)
self.myScreen = session.getScreen()
session.getScreen().add_screen_listener(self.outputScreen)
session.connect()
! def createWidgets(self):
self.makeMenuBar()
#self.canvas = self.root.createcomponent('canvas', (), None, \
#Canvas, (self.interior(),), width=self.width, \
#height=self.height,background="black")
self.canvas.pack(fill=BOTH)
#text = Text(self, relief=SUNKEN, fg='green', bg='black', \
#width=150, height=50)
#text.pack(fill=BOTH)
! def makeMenuBar(self):
self.menubar = Menu(self.master)
self.master.config(menu=self.menubar) # master=top-level window
self.fileMenu()
self.editMenu()
! def fileMenu(self):
pulldown = Menu(self.menubar, tearoff=0)
pulldown.add_command(label='Open...', command=self.notdone, \
underline=0)
pulldown.add_command(label='Quit', command=self.quit, \
underline=0)
pulldown.entryconfig(0, state=DISABLED)
self.menubar.add_cascade(label='File', underline=0, menu=pulldown)
! def editMenu(self):
pulldown = Menu(self.menubar, tearoff=0)
pulldown.add_command(label='Copy', command=self.notdone)
pulldown.add_command(label='Paste', command=self.notdone)
pulldown.entryconfig(0, state=DISABLED)
pulldown.entryconfig(1, state=DISABLED)
self.menubar.add_cascade(label='Edit', underline=0, menu=pulldown)
! def notdone(self):
showerror('Not implemented', 'Not yet available')
! def quit(self):
if askyesno('Verify quit', 'Are you sure you want to quit?'):
Frame.quit(self)
! if __name__ == '__main__':
#root = Tk()
StartFrame().mainloop()
#root.mainloop() # if I'm run as a script
\ No newline at end of file
|
|
From: <gen...@us...> - 2002-07-19 16:40:48
|
Update of /cvsroot/tn5250py/tn5250py/doc
In directory usw-pr-cvs1:/tmp/cvs-serv26416/doc
Modified Files:
tn5250py-outline.txt
Log Message:
Documentation Change. Updates Doc for SessionManager and Sessions class
Index: tn5250py-outline.txt
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/doc/tn5250py-outline.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** tn5250py-outline.txt 6 Jul 2002 11:12:58 -0000 1.1.1.1
--- tn5250py-outline.txt 19 Jul 2002 16:40:44 -0000 1.2
***************
*** 4,15 ****
Functions:
closeSession(Session) - closes a session object
! closeSession(String) - closes a session object based on a string
! name/description
getSessions() - Returns an Sessions object containing a list of
! Session object
! available.
! openSession(String,String) - Returns a Session object based on the
! parameters
! provided.
--- 4,12 ----
Functions:
closeSession(Session) - closes a session object
! closeSession(String) - closes a session object based on a string name
getSessions() - Returns an Sessions object containing a list of
! Session object available.
! openSession(String) - Returns a Session object based on the parameters provided.
! refresh() - same as getSessions()
***************
*** 18,25 ****
getCount() - Returns the number of Session objects contained within
this object
! item(int) - Returns the Session object at the given index.
item(String) - Returns the Session object with the given session
Name
- refresh() - Updates the collection of Session objects
- Session - An actual host session.
--- 15,21 ----
getCount() - Returns the number of Session objects contained within
this object
! item_index(int) - Returns the Session object at the given index.
item(String) - Returns the Session object with the given session
Name
- Session - An actual host session.
|
|
From: <gen...@us...> - 2002-07-19 16:30:39
|
Update of /cvsroot/tn5250py/tn5250py/src/lib5250py
In directory usw-pr-cvs1:/tmp/cvs-serv21742/src/lib5250py
Modified Files:
SessionManager.py Sessions.py
Log Message:
This is the some testing code for the session manager. It should prove that the session manager works.
Index: SessionManager.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/SessionManager.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SessionManager.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- SessionManager.py 19 Jul 2002 16:30:35 -0000 1.2
***************
*** 1,30 ****
! """
! SessionManager and Sessions objects
! Created by Nathanael Custer 2002-07-01
! """
!
! from Sessions import Sessions
!
! __all__ = ["SessionManager"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
# Telnet Port
! TELNET_PORT = 23
!
! class SessionManager:
! def __init__(self):
! self.MasterSessionList = Sessions()
! def getSessions(self):
! return self.MasterSessionList
! def openSession(self, name=''):
! self.MasterSessionList._addSession(name)
! return self.MasterSessionList.item(name)
! def closeSession(self, name=''):
! session = self.MasterSessionList.item(name)
! if session.isConected():
! session.disconect()
! self.MasterSessionList._delSession(name)
! def refresh(self):
! return self.MasterSessionList
--- 1,44 ----
! """
! SessionManager and Sessions objects
! Created by Nathanael Custer 2002-07-01
! """
!
! from Sessions import Sessions
!
! __all__ = ["SessionManager"]
!
! # Tunable parameters
! DEBUGLEVEL = 0
!
# Telnet Port
! TELNET_PORT = 23
!
! class SessionManager:
! def __init__(self):
! self.MasterSessionList = Sessions()
! def getSessions(self):
! return self.MasterSessionList
! def openSession(self, name=''):
! self.MasterSessionList._addSession(name)
! return self.MasterSessionList.item(name)
! def closeSession(self, name=''):
! session = self.MasterSessionList.item(name)
! self.MasterSessionList._delSession(name)
! def refresh(self):
! return self.MasterSessionList
!
! if __name__ == '__main__':
! test = SessionManager()
! print "Generating 10 test sessions."
! for x in range(10):
! test.openSession('test' + str(x))
! print "Here is the list of the sessions:"
! a = test.getSessions()
! print a.list
! print "Now removing the sessions one at a time"
! for x in range(10):
! test.closeSession('test' + str(x))
! a = test.refresh()
! print "One less"
! print a.list
!
Index: Sessions.py
===================================================================
RCS file: /cvsroot/tn5250py/tn5250py/src/lib5250py/Sessions.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Sessions.py 6 Jul 2002 11:13:00 -0000 1.1.1.1
--- Sessions.py 19 Jul 2002 16:30:35 -0000 1.2
***************
*** 23,27 ****
for x in self.list:
if name == x[0]:
! self.list.remove(name)
# else:
# raise error here
--- 23,27 ----
for x in self.list:
if name == x[0]:
! self.list.remove(x)
# else:
# raise error here
|
|
From: <kj...@us...> - 2002-07-09 06:39:06
|
Update of /cvsroot/tn5250py/tn5250py/src/gui5250py/gtk In directory usw-pr-cvs1:/tmp/cvs-serv2582/gui5250py/gtk Modified Files: guigtk Log Message: Change it back Index: guigtk =================================================================== RCS file: /cvsroot/tn5250py/tn5250py/src/gui5250py/gtk/guigtk,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** guigtk 9 Jul 2002 06:21:29 -0000 1.2 --- guigtk 9 Jul 2002 06:39:04 -0000 1.3 *************** *** 1,2 **** Intentionally left blank to create directory structures - test cvs commits of general list --- 1 ---- |
|
From: <kj...@us...> - 2002-07-09 06:21:32
|
Update of /cvsroot/tn5250py/tn5250py/src/gui5250py/gtk In directory usw-pr-cvs1:/tmp/cvs-serv30866 Modified Files: guigtk Log Message: test cvs commits of general list Index: guigtk =================================================================== RCS file: /cvsroot/tn5250py/tn5250py/src/gui5250py/gtk/guigtk,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** guigtk 6 Jul 2002 11:23:35 -0000 1.1 --- guigtk 9 Jul 2002 06:21:29 -0000 1.2 *************** *** 1 **** --- 1,2 ---- Intentionally left blank to create directory structures + test cvs commits of general list |