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

  1. extproc python -x %PYTHONHOME%\fnior.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/fnior,v $
  29. # Version:      @(#)$RCSfile: fnior,v $ $Revision: 1.6 $
  30. #
  31. #############################################################################
  32. """ Read a stringified IOR from stdin and print its details on stdout. """
  33.  
  34.  
  35. # Standard/built-in modules.
  36. import new, sys
  37.  
  38. # Fnorb modules.
  39. from Fnorb.orb import IOP
  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 stringified IOR from stdin.
  52.     stringified_ior = sys.stdin.read()
  53.  
  54.     elif len(argv) == 2 and argv[1][:4] == 'IOR:':
  55.     # Read a stringified IOR from the command line.
  56.     stringified_ior = argv[1]
  57.  
  58.     elif len(argv) == 3 and argv[1] == '-f':
  59.     # Read a stringified IOR from a file.
  60.     stringified_ior = open(argv[2]).read()
  61.  
  62.     else:
  63.     print 'Usage: fnior [-f file | IOR:...]'
  64.     return 1
  65.  
  66.     # Create a new IOR instance and initialise it from the stringified IOR.
  67.     ior = new.instance(IOP.IOR, {})
  68.     ior._fnorb_from_string(stringified_ior)
  69.  
  70.     # Print out the details.
  71.     print
  72.     print 'Type Id              :', ior.type_id
  73.     for p in ior.profiles:
  74.     # IIOP profile
  75.     if p.tag == IOP.TAG_INTERNET_IOP:
  76.         print 'Profile              : IIOP'
  77.         major = ord(p.profile_data.iiop_version.major)
  78.         minor = ord(p.profile_data.iiop_version.minor)
  79.         print 'IIOP Version         : %d.%d' % (major, minor)
  80.         print 'Host                 :', p.profile_data.host
  81.         print 'Port                 :', p.profile_data.port
  82.         print 'Object Key           :', p.profile_data.object_key
  83.         print 'Key length           :', len(p.profile_data.object_key)
  84.         print 'Octal key dump       :',
  85.         # Dump of object key.
  86.         i = 0
  87.         for c in p.profile_data.object_key:
  88.         print '%03o' % ord(c),
  89.         i = i + 1
  90.         if i % 10 == 0:
  91.             print '\n' + ' ' * 22,
  92.  
  93.         print '\n'
  94.  
  95.     # Multiple component profile.    
  96.     elif p.tag == IOP.TAG_MULTIPLE_COMPONENTS:
  97.         print 'Profile              : Multiple Components'
  98.         for co in p.profile_data:
  99.         print 'Component id         :', co.tag
  100.         print 'Component            :', co.component_data
  101.         print 'Component length     :', len(co.component_data)
  102.         print 'Octal component dump :',
  103.         # Dump of component data.
  104.         i = 0
  105.         for c in co.component_data:
  106.             print '%03o' % ord(c),
  107.             i = i + 1
  108.             if i % 10 == 0:
  109.             print '\n' + ' ' * 22,
  110.  
  111.         print '\n'
  112.  
  113.     else:
  114.         print 'Unknown profile tag  :', p.tag
  115.         print '\n'
  116.         
  117.     return 0
  118.  
  119. #############################################################################
  120.  
  121. if __name__ == '__main__':
  122.     # Do it!
  123.     sys.exit(main(sys.argv[1:]))
  124.  
  125. #############################################################################
  126.