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 __facility__ = "Online" 00011 __abstract__ = "Example test suite" 00012 __author__ = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online" 00013 __date__ = ("$Date: 2005/03/25 00:50:19 $").split(' ')[1] 00014 __version__ = "$Revision: 1.5 $" 00015 __credits__ = "SLAC" 00016 00017 import LATTE.copyright_SLAC 00018 00019 # History: 00020 # $Log: testSuite2.py,v $ 00021 # Revision 1.5 2005/03/25 00:50:19 stuvi 00022 # no message 00023 # 00024 # Revision 1.4 2005/03/25 00:39:59 stuvi 00025 # Pass event count as a parameter to testSAppCal 00026 # 00027 # Revision 1.3 2005/01/27 23:07:54 stuvi 00028 # Allow the nested suite to be run by itself by checking StopRequestedException. 00029 # Call doStopRun if not run as nested suite. 00030 # 00031 # Revision 1.2 2004/08/18 18:00:15 stuvi 00032 # Updated for LATTE 4. 00033 # All hippo functions go through the Qt GUI bridge now. 00034 # 00035 # Revision 1.1 2004/08/07 02:10:42 stuvi 00036 # Test suite examples. 00037 # 00038 # Revision 1.2 2004/01/24 00:27:17 stuvi 00039 # Modified to use the appdir from preferences 00040 # 00041 # Revision 1.1 2003/12/11 01:22:34 stuvi 00042 # A sample test suite that is called as a sub suite from the testSuite sample. 00043 # 00044 # Revision 1.2 2003/07/26 04:15:30 stuvi 00045 # Fixed schema path 00046 # 00047 # Revision 1.1 2003/03/28 03:21:41 stuvi 00048 # Fixed FITS file status display 00049 # Added test suite capability 00050 # 00051 00052 from LATTE.runcontrol.rcSuite import rcSuite 00053 import logging as log 00054 import os 00055 00056 00057 class userSuite(rcSuite): 00058 "Implmentation class for a user application" 00059 def __init__(self, gui, userId, debug): 00060 rcSuite.__init__(self, gui, userId, debug) 00061 log.debug("userSuite.__init__()") 00062 00063 def getName(self): 00064 return __name__ 00065 00066 def setupSuite(self): 00067 pass 00068 00069 def startSuite(self): 00070 try: 00071 sessionContext = {"test":"abc", "eventCount":3} 00072 # The following script will change the value of session var "test" 00073 appDir = self.gui.preferences()['appdir'] 00074 sessionStateAfterTest1 = self.scriptRun(module=os.path.join(appDir,'testSAppCal'), 00075 context=sessionContext) 00076 log.info("In %s: SESSION VAR=%s" % (self.getName(), self.getSessionVar("test"))) 00077 # The following script will print the value of session var "test" and modify it 00078 sessionStateAfterTest2 = self.scriptRun(module=os.path.join(appDir,'testSAppEvt')) 00079 # Finally let's print the value of the session var "test" here 00080 print sessionStateAfterTest1 00081 print sessionStateAfterTest2 00082 log.info("In %s: SESSION VAR=%s" % (self.getName(), self.getSessionVar("test"))) 00083 except rcSuite.StopRequestedException, e: 00084 log.info("%s, suite: %s, module: %s" % (e.msg, e.suite, e.module)) 00085 if self.getSuite() is not None: 00086 raise e 00087 00088 if self.gui is not None and self.getSuite() is None: 00089 # Stop the suite if it wasn't called from a parent suite 00090 self.gui.doStopRun() 00091 00092 00093 def stopSuite(self): 00094 log.info("End of suite 2")