Updated jython script for printer-management (Java 1.5.0)
"Patrick Bielen" <[email protected]> Tue, 17 Feb 2004 09:44:41 +0100
| Newsgroups | gmane.comp.java.tn5250j.general,gmane.comp.java.tn5250j.scripting |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
------=_NextPart_000_0000_01C3F53A.AA81FDE0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0001_01C3F53A.AA81FDE0"
------=_NextPart_001_0001_01C3F53A.AA81FDE0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi All,
Included with this mail you'll find the updated prtsts.py script
fixed to be runned on the new Java version 1.5.0.
If anybody want the new compiled jython.jar to run at 1.5.0
please let me know, i recompiled it this morning, and
provided it to the users of the jython mailinglist also.
Anyway when trying to recompile tn5250j with the new java
be sure to have a recompiled jython.jar for 1.5.0 also, cause
otherwise the scription-features in tn5250j will be broken !!!
So be warned !
The advantage of my jython-script is that it needs a free
session to work on, but if any of you find the script usefull
and have some experience with the java toolkit please help
me to make the script run outside a session, adding some
nice gui (in the new java it looks delicious), and some more
functionality, like answering the printer-messages and such.
So kenneth tell me, is it possible to add a new tab for a
session, but instead of a session using the new tabbed
pane to add some java-components, like labels, textarea's
buttons etc to create a completely tab to manage your
printers, without the need for a new session ???
Hope you guys enjoy the script.
Best Regards,
Patrick
Sysop/Java-programmer Stafa Holland BV
Administrator/Programmer Memoranda-project (SourceForge)
Programmer TN5250J-project (SourceForge)
Programmer DBPirate-project (Java.net)
------=_NextPart_001_0001_01C3F53A.AA81FDE0
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>Hi=20
All,</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>Included with this=20
mail you'll find the updated prtsts.py script</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>fixed =
to be runned=20
on the new Java version 1.5.0.</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>If =
anybody want the=20
new compiled jython.jar to run at 1.5.0</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>please =
let me know,=20
i recompiled it this morning, and </FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>provided it to the=20
users of the jython mailinglist also.</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>Anyway =
when trying=20
to recompile tn5250j with the new java</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>be =
sure to have a=20
recompiled jython.jar for 1.5.0 also, cause</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>otherwise the=20
scription-features in tn5250j will be broken !!!</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>So be =
warned=20
!</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>The =
advantage of my=20
jython-script is that it needs a free </FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>session to work on,=20
but if any of you find the script usefull</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>and =
have some=20
experience with the java toolkit please help</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>me to =
make the=20
script run outside a session, adding some</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>nice =
gui (in the new=20
java it looks delicious), and some more</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>functionality, like=20
answering the printer-messages and such.</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>So =
kenneth tell me,=20
is it possible to add a new tab for a</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>session, but instead=20
of a session using the new tabbed</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>pane =
to add some=20
java-components, like labels, textarea's</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>buttons etc to=20
create a completely tab to manage your</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial =
size=3D2>printers, without=20
the need for a new session ???</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>Hope =
you guys enjoy=20
the script.</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial size=3D2>Best=20
Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D234543508-17022004><FONT face=3DArial=20
size=3D2>Patrick</FONT></SPAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV align=3Dleft><FONT face=3DArial size=3D2>Sysop/Java-programmer =
Stafa Holland=20
BV</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial size=3D2>Administrator/Programmer=20
Memoranda-project (SourceForge)</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial =
size=3D2>Programmer TN5250J-project=20
(SourceForge)</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial =
size=3D2>Programmer DBPirate-project=20
(Java.net)</FONT></DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_001_0001_01C3F53A.AA81FDE0--
------=_NextPart_000_0000_01C3F53A.AA81FDE0
Content-Type: text/plain;
name="prtsts.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="prtsts.py"
######################################################################
# PRTSTS.PY #
# ================================================================== #
# Programmer : Patrick Gerrit Jackie Bielen #
# Company : Stafa Holland BV - Feeling for fasteners #
# Functionality : Script for easy printer-management on your AS/400 #
# Specially created for system-operators. #
# How it works : When there is a message waiting for a specific #
# printer, a window pops up telling you wich printer #
# has a message waiting to be answered. #
# Feedback : tn5250j-mailinglist or directly to bielen@st... #
# ICQ #24140635 or private email pbielen@pl... #
######################################################################
import java
import time
from javax import swing
import java.awt as awt
def DebugWindow():
msg = swing.JDialog()
msg.show()
def fillWithValues(row,col,width,sb):
sPos = ((row - 1) * screen.getCols()) + (col - 1)
while width > 0:
sb.append(screenChars[sPos])
sPos += 1
width -= 1
def StatusWindow():
win = swing.JFrame("Printer Status")
win.size = (200,75 + (count * 25))
win.contentPane.background = awt.Color.white
win.contentPane.setLayout(awt.BorderLayout())
win.contentPane.add(list,awt.BorderLayout.CENTER)
win.show()
def waitWhileLocked(timeSeconds):
while screen.isKeyboardLocked():
time.sleep(timeSeconds)
#DebugWindow()
debug = 0
print debug.toString()
screen = _session.getScreen()
prtdev = java.lang.StringBuffer()
status = java.lang.StringBuffer()
modus = java.lang.StringBuffer()
done = 0 # Window displayed
basic = 0 # Basic or Advanced Mode - Reset at exit
amount = 0 # Amount of printers
count = 0 # Amount of messages waiting
# Checking Modus from here
screen.sendKeys("[pf9]WRKWTR[enter][pf21]")
waitWhileLocked(1)
screenChars = screen.getScreenAsChars()
modus = java.lang.StringBuffer()
fillWithValues(10, 37, 1, modus)
if modus.toString() == "1":
basic = 1
screen.sendKeys("2[enter]")
else:
screen.sendKeys("[pf12]")
# Count the amount of printers
waitWhileLocked(1)
screenfields = screen.getScreenFields()
fields = screenfields.getFields()
FirstRow = 256
LastRow = 0
for x in fields:
if x.startRow() < FirstRow:
FirstRow = x.startRow()
# Remember that the column is offset 0,0 so you have to make sure that
# it is less than 6 instead of 7 where the screen offset would start
if x.startRow() > LastRow and x.startCol() < 6:
LastRow = x.startRow()
amount += 1
# The emulator keeps everything on base position 0,0 not 1,1
# so we must add one to them at the end.
FirstRow += 1
LastRow += 1
# Debug mode (display amount and first and last row)
if debug:
print "FirstRow : " + FirstRow.toString()
print "LastRow : " + LastRow.toString()
print "Amount : " + amount.toString()
while not _session.isStopMacroRequested() and not done:
screen.sendKeys("[pf5]")
waitWhileLocked(1)
screenChars = screen.getScreenAsChars()
times = 0
lm = swing.DefaultListModel()
list = swing.JList(lm)
while times < amount:
prtdev = java.lang.StringBuffer()
fillWithValues(9 + times,7,10,prtdev)
status = java.lang.StringBuffer()
fillWithValues(9 + times,19,4,status)
if status.toString() == "MSGW":
lm.addElement(" " + prtdev.toString() + " " + \
"Check Printer")
count += 1
times += 1
if not lm.isEmpty():
done = 1
StatusWindow()
else:
if screen.isKeyboardLocked():
waitWhileLocked(10)
else:
time.sleep(10)
if basic == 1:
screen.sendKeys("[pf21]1[enter][pf12][pf12]")
------=_NextPart_000_0000_01C3F53A.AA81FDE0--
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click