Sign in to follow this  
Followers 0
spac3m0nk3y

Display StdoutRead in ListView

3 posts in this topic

I'm trying to display some string data from StdoutRead in a listview. I have the data from StdoutRead, but I'm not sure how to extract the data I need there is some info that I don't need. If anybody could point me in the right direction, I would appreciate it.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Constants.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1)
#Region ### START GUI section ###
$CondorUtil = GUICreate("Condor Util", 633, 454, 266, 136)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenu("About")
GUISetOnEvent($GUI_EVENT_CLOSE, "CondorUtilClose")
$bQueue = GUICtrlCreateButton("Queue", 8, 400, 97, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "bQueueClick")
$bStatus = GUICtrlCreateButton("Status", 126, 400, 97, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "bStatusClick")
$bRemove = GUICtrlCreateButton("Remove", 243, 400, 97, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "bRemoveClick")
$bExit = GUICtrlCreateButton("Exit", 529, 400, 97, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "bExitClick")
$hListView = GUICtrlCreateListView("", 8, 0, 617, 385)
GUICtrlSetOnEvent(-1, "MenuItem1Click")
GUICtrlSetOnEvent(-1, "MenuItem2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END GUI section ###

_Main()

While 1
    Sleep(100)
WEnd

Func _Main()

EndFunc

Func bExitClick()
    Exit
EndFunc

Func bQueueClick()

EndFunc

Func bRemoveClick()

EndFunc

Func bStatusClick()
    _GUICtrlListView_AddColumn($hListView, "Node", 190)
    _GUICtrlListView_AddColumn($hListView, "State", 100, 2)
    _GUICtrlListView_AddColumn($hListView, "Activity", 100, 2)
    _GUICtrlListView_AddColumn($hListView, "Load Av", 100, 2)
    _GUICtrlListView_AddColumn($hListView, "Act Time", 100, 2)
    Local $sStatus = Run(@ComSpec & " /c condor_status", @SystemDir, @SW_HIDE, 8)
    Local $sBuf
    While 1
        $sBuf &= StdoutRead($sStatus)
        If @error Then ExitLoop
    Wend
EndFunc

Func CondorUtilClose()
    Exit
EndFunc

Func MenuItem1Click()

EndFunc
Func MenuItem2Click()

EndFunc

I need the Name in one listview column, State in another, Activity in another LoadAv in another and ActivityTime in another. How the heck do I do this?

Output from "condor_status" above:

Name               OpSys      Arch   State     Activity LoadAv Mem   ActvtyTime

vm1@sm-node-1.jetd WINNT52    INTEL  Claimed   Busy     0.970  2047  0+00:02:57
vm2@sm-node-1.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+05:03:50
vm3@sm-node-1.jetd WINNT52    INTEL  Unclaimed Idle     0.050  2047  0+05:03:51
vm4@sm-node-1.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+05:03:52
vm1@sm-node-10.jet WINNT52    INTEL  Claimed   Busy     0.570  2047[?????]
vm2@sm-node-10.jet WINNT52    INTEL  Unclaimed Idle     0.150  2047  0+04:58:52
vm3@sm-node-10.jet WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:53
vm4@sm-node-10.jet WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:54
vm1@sm-node-2.jetd WINNT52    INTEL  Claimed   Busy     0.000  2047[?????]
vm2@sm-node-2.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:53
vm3@sm-node-2.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:54
vm4@sm-node-2.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:55
vm1@sm-node-3.jetd WINNT52    INTEL  Claimed   Busy     0.450  2047[?????]
vm2@sm-node-3.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:50
vm3@sm-node-3.jetd WINNT52    INTEL  Unclaimed Idle     0.090  2047  0+04:58:51
vm4@sm-node-3.jetd WINNT52    INTEL  Unclaimed Idle     0.090  2047  0+04:58:52
vm1@sm-node-4.jetd WINNT52    INTEL  Claimed   Busy     0.000  2047[?????]
vm2@sm-node-4.jetd WINNT52    INTEL  Unclaimed Idle     0.010  2047  0+04:58:49
vm3@sm-node-4.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:50
vm4@sm-node-4.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:51
vm1@sm-node-5.jetd WINNT52    INTEL  Claimed   Busy     0.000  2047[?????]
vm2@sm-node-5.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:50
vm3@sm-node-5.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:51
vm4@sm-node-5.jetd WINNT52    INTEL  Unclaimed Idle     0.080  2047  0+04:58:52
vm1@sm-node-6.jetd WINNT52    INTEL  Claimed   Busy     0.000  2047[?????]
vm2@sm-node-6.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:51
vm3@sm-node-6.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:52
vm4@sm-node-6.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:53
vm1@sm-node-7.jetd WINNT52    INTEL  Claimed   Busy     0.020  2047[?????]
vm2@sm-node-7.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:52
vm3@sm-node-7.jetd WINNT52    INTEL  Unclaimed Idle     0.100  2047  0+04:58:53
vm4@sm-node-7.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:54
vm1@sm-node-8.jetd WINNT52    INTEL  Claimed   Busy     0.140  2047[?????]
vm2@sm-node-8.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:50
vm3@sm-node-8.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:51
vm4@sm-node-8.jetd WINNT52    INTEL  Unclaimed Idle     0.090  2047  0+04:58:52
vm1@sm-node-9.jetd WINNT52    INTEL  Claimed   Busy     0.100  2047[?????]
vm2@sm-node-9.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:50
vm3@sm-node-9.jetd WINNT52    INTEL  Unclaimed Idle     0.080  2047  0+00:58:46
vm4@sm-node-9.jetd WINNT52    INTEL  Unclaimed Idle     0.000  2047  0+04:58:52

                     Total Owner Claimed Unclaimed Matched Preempting Backfill

       INTEL/WINNT52    40     0      10        30       0          0        0

               Total    40     0      10        30       0          0        0

Share this post


Link to post
Share on other sites



Separate the text in lines (split for @CRLF)

StringStripWS($Line, 4) (strips any double-space or more between words)

StringSplit the result for " " (space) and you'll get the values in one array (you can do that safely because it doesn't appear that any entry contains white speaces).

Once you get the array of values, updating the ListView is trivial.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Separate the text in lines (split for @CRLF)

StringStripWS($Line, 4) (strips any double-space or more between words)

StringSplit the result for " " (space) and you'll get the values in one array (you can do that safely because it doesn't appear that any entry contains white speaces).

Once you get the array of values, updating the ListView is trivial.

Thanks for your reply. I part of it figured out, and below is the code I inserted after my while statement:

$aString = StringSplit(StringStripWS($sBuf, 4), @CRLF)
    $sNewString = _ArrayToString($aString, " ")
    $sTest = StringSplit($sNewString, " ")

Does that look correct?

This results in an array of all the individual items, but it's all mixed up, guess I have some array sorting to do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0