1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#!/bin/env python
#/*******************************************************************/
#/* XDMF */
#/* eXtensible Data Model and Format */
#/* */
#/* Id : $Id: NdgmLs.py,v 1.2 2009-01-23 20:48:54 clarke Exp $ */
#/* Date : $Date: 2009-01-23 20:48:54 $ */
#/* Version : $Revision: 1.2 $ */
#/* */
#/* Author: */
#/* Jerry A. Clarke */
#/* clarke@arl.army.mil */
#/* US Army Research Laboratory */
#/* Aberdeen Proving Ground, MD */
#/* */
#/* Copyright @ 2002 US Army Research Laboratory */
#/* All Rights Reserved */
#/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */
#/* */
#/* This software is distributed WITHOUT ANY WARRANTY; without */
#/* even the implied warranty of MERCHANTABILITY or FITNESS */
#/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
#/* for more information. */
#/* */
#/*******************************************************************/
from __future__ import print_function
import sys
import string
import Xdmf
class NdgmLs :
def __init__( self, Hostname = None ) :
self.BufferLength = 4000
self.Ndgm = Xdmf.XdmfNDGM()
self.Ndgm.SetModeToClient()
self.entries = None
if Hostname != None :
self.Ndgm.SetNdgmHost( Hostname )
def Ls( self ) :
status = self.Ndgm.Open()
if status <= 0 :
print ("Can't Connect to NDGM Server on " + self.Ndgm.GetNdgmHost())
return None
# Get the Length
Length = self.Ndgm.GetTotalLength()
# print ('NDGM on %s is %d bytes' % ( self.Ndgm.GetNdgmHost(), Length ))
self.RawString = string.split( Xdmf.XdmfGetNdgmEntries() )
return self.RawString
def Format( self, Raw = None) :
if Raw == None :
Raw = self.RawString
NumberOfEntries = len( self.RawString ) / 4
Index = 0
self.entries = []
for i in range( NumberOfEntries ) :
# Skip -NDGM_ENTRY-
Index += 1
Name = self.RawString[ Index ]
Index += 1
Start = self.RawString[ Index ]
Index += 1
End = self.RawString[ Index ]
Index += 1
self.entries += ['%-20s %12d %12d' % (Name, int(Start), int(End))]
return( self.entries )
if __name__ == '__main__' :
argc = len( sys.argv )
if argc > 1 :
Hostname = sys.argv[ argc - 1 ]
else :
Hostname = None
n = NdgmLs( Hostname )
l = n.Ls()
if l == None :
sys.exit( 1 )
e = n.Format()
NumberOfEntries = len( e )
if NumberOfEntries < 1 :
print ('-1 : No Entries in NDGM')
else :
for i in range( NumberOfEntries ) :
print '%2d : %s' % ( i, e[ i ])
|