home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fnb101.zip / fnping.cmd < prev   
OS/2 REXX Batch file  |  1999-06-28  |  3KB  |  104 lines

  1. extproc python -x %PYTHONHOME%\fnping.cmd
  2. #############################################################################
  3. # Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997, 1998, 1999
  4. # All Rights Reserved.
  5. #
  6. # The software contained on this media is the property of the DSTC Pty
  7. # Ltd.  Use of this software is strictly in accordance with the
  8. # license agreement in the accompanying LICENSE.HTML file.  If your
  9. # distribution of this software does not contain a LICENSE.HTML file
  10. # then you have no rights to use this software in any manner and
  11. # should contact DSTC at the address below to determine an appropriate
  12. # licensing arrangement.
  13. #      DSTC Pty Ltd
  14. #      Level 7, GP South
  15. #      Staff House Road
  16. #      University of Queensland
  17. #      St Lucia, 4072
  18. #      Australia
  19. #      Tel: +61 7 3365 4310
  20. #      Fax: +61 7 3365 4311
  21. #      Email: enquiries@dstc.edu.au
  22. # This software is being provided "AS IS" without warranty of any
  23. # kind.  In no event shall DSTC Pty Ltd be liable for damage of any
  24. # kind arising out of or in connection with the use or performance of
  25. # this software.
  26. #
  27. # Project:      Fnorb
  28. # File:         $Source: /units/arch/src/Fnorb/script/RCS/fnping,v $
  29. # Version:      @(#)$RCSfile: fnping,v $ $Revision: 1.4 $
  30. #
  31. #############################################################################
  32. """ Read a UOL from stdin and 'ping' the object. """
  33.  
  34.  
  35. # Standard/built-in modules.
  36. import sys, time
  37.  
  38. # Fnorb modules.
  39. from Fnorb.orb import CORBA
  40.  
  41.  
  42. def main(argv):
  43.     """ Do it! """
  44.  
  45.     # fixme: This a hack to remove the spurious last argument ('\n') on
  46.     # Windows 95.
  47.     if argv[-1] == '\n':
  48.     del argv[-1]
  49.  
  50.     if len(argv) == 1:
  51.     # Read a UOL from stdin.
  52.     uol = sys.stdin.read()
  53.  
  54.     elif len(argv) == 2:
  55.     # Read a stringified IOR from the command line.
  56.     uol = argv[1]
  57.  
  58.     elif len(argv) == 3 and argv[1] == '-f':
  59.     # Read a stringified IOR from a file.
  60.     uol = open(argv[2]).read()
  61.  
  62.     else:
  63.     print 'Usage: fnping [-f file | UOL]'
  64.     return 1
  65.  
  66.     # Ping!
  67.     object = CORBA.ORB_init().string_to_object(uol)
  68.  
  69.     print 'FNPING',
  70.     print '%s:%d' % (object._fnorb_host(), object._fnorb_port()),
  71.     print object._fnorb_object_key()
  72.  
  73.     try:
  74.     while 1:
  75.         start = time.clock()
  76.         object._is_a('IDL:omg.org/CORBA/Object:1.0')
  77.         end = time.clock()
  78.  
  79.         print 'Reply from',
  80.         print '%s:%d' % (object._fnorb_host(), object._fnorb_port()),
  81.         print object._fnorb_object_key(),
  82.         print 'time=', int((end - start) * 1000), 'ms'
  83.  
  84.         time.sleep(1)
  85.  
  86.     except CORBA.SystemException, ex:
  87.     print ex.__class__.__name__, ex
  88.  
  89.     return 0
  90.  
  91. #############################################################################
  92.  
  93. if __name__ == '__main__':
  94.     # Do it!
  95.     try:
  96.     sys.exit(main(sys.argv[1:]))
  97.  
  98.     except KeyboardInterrupt:
  99.     pass
  100.  
  101. #############################################################################
  102.