Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

test_tem.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2002
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 """TEM test
00011 Contents:
00012 Script for testing TEM
00013 """
00014 __facility__ = "Online"
00015 __abstract__ = "Script for testing TEM"
00016 __author__   = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST I&T/Online"
00017 __date__     = ("$Date: 2005/08/04 20:43:08 $").split(' ')[1]
00018 __version__  = "$Revision: 2.8 $"
00019 __release__  = "$Name: R04-12-00 $"
00020 __credits__  = "SLAC"
00021 
00022 import LATTE.copyright_SLAC
00023 
00024 from LATTE.client.gOptions import Options
00025 from LATTE.client.gCmdCli  import CmdCli
00026 from LATTE.database.gLAT   import GLAT
00027 from LATTE.database.gGLT   import GGLT
00028 from LATTE.database.gXBR   import GXBRD
00029 from LATTE.database.gPlumber import Plumber
00030 
00031 
00032 import os
00033 import logging as log
00034 
00035 def test(c=None, disconnectOnExit=1):
00036   global tem, glt, lat, cmd, xbrd
00037 
00038   log.getLogger("").setLevel(log.DEBUG)
00039 
00040   options = Options(['server', 'schema'],
00041                     ['fswmsglevel', 'cmddebug'],
00042                     ['initforce', 'ocsverbose', 'nocommander'])
00043   try:
00044     options.parse()
00045   except Exception, msg:
00046     options.usage(str(msg))
00047     return
00048 
00049   if options.fswmsglevel is not None:
00050     msglevel = int(options.fswmsglevel)
00051   else:
00052     msglevel = 3
00053   verbose = (options.ocsverbose != None)
00054   force = (options.initforce != None)
00055   commander = not(options.nocommander != None)
00056 
00057   if c == None:
00058     cmd = CmdCli()
00059     cmd.connect(options.server)
00060     if options.cmddebug is not None:
00061       cmd.setDebug(options.cmddebug)
00062   else:
00063     cmd = c
00064 
00065   lat = GLAT(cmd)
00066   lat.readSchema(options.schema)
00067 
00068   xbrd = GXBRD(cmd)
00069   xbrd = xbrd.readSchema(options.schema)
00070 
00071   plumber = Plumber(lat, xbrd)
00072   plumber.initialize(msglevel, verbose, force, commander)
00073 
00074   lat.applyConfig()
00075 
00076   # Get a TEM instance
00077   if lat.TEMcnt() == 1:
00078     tem = lat.TEM[lat.TEM.keys()[0]]
00079   elif lat.TEMcnt() > 1:
00080     tem = lat.TEM.all()
00081   else:
00082     log.fatal("No TEM(s) found in the schema")
00083     if disconnectOnExit:
00084       cmd.disconnect()
00085     return -1
00086 
00087   glt = GGLT(cmd)
00088   glt.initialize()
00089 
00090   if disconnectOnExit:
00091     cmd.disconnect()
00092 
00093 if __name__ == '__main__':
00094   test(None, 0)

Generated on Fri Jul 21 13:26:32 2006 for LATTE R04-12-00 by doxygen 1.4.3