rcParamVerifier.py

Go to the documentation of this file.
00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2005
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__ = "Parameter verifier class"
00012 __author__   = "S. Tuvi <STuvi@SLAC.Stanford.edu>"
00013 __date__     = "2005/07/23 00:08:27"
00014 __updated__  = "$Date: 2005/09/22 00:29:30 $"
00015 __version__  = "$Revision: 1.4 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 from rcParamVerifyGUIImpl import rcParamVerifyGUIImpl
00022 
00023 class rcParamVerifier(object):
00024   """!\brief Parameter verifier class.
00025 
00026   This class gets activated during a secure session and
00027   is used to get a sign off on the parameters specified
00028   in the ScriptEngine GUI in addition to the parameters
00029   specified in the test script itself.
00030 
00031   The scripts can add additional parameters to be verified
00032   by calling the add method.
00033   """
00034   def __init__(self, common, parent = None, name = None, fl = 0):
00035     """!\brief rcParamVerifier constructor.
00036 
00037     \param common ScriptEngineCommon instance
00038     \param parent Parent GUI
00039     \param name   GUI name
00040     \param fl     GUI flag
00041     """
00042     self.__verifyGUI = rcParamVerifyGUIImpl(common, parent, name, fl)
00043     self.__common = common
00044 
00045   def initialize(self, testName):
00046     """!\brief Initialize the parameter verifier.
00047 
00048     \param testName Name of the test script
00049     """
00050     self.__parNames = []
00051     self.__parValues = []
00052     self.__testName = testName
00053 
00054   def add(self, parName, parValue):
00055     """!\brief Add parameter and its value to the verify list
00056 
00057     \param parName Parameter name or description
00058     \param parValue Parameter value that the operator inputted
00059     """
00060     if parName not in self.__parNames:
00061       self.__parNames.append(parName)
00062       self.__parValues.append(parValue)
00063     else:
00064       raise KeyError, "Parameter with name: %s already added." % parName
00065 
00066   def getParameters(self, parName=None):
00067     """!\brief Retrieve parameters to verify
00068 
00069     \param parName Parameter to retrieve from the verify list (optional)
00070 
00071     \return A list containing the parameter name and value tuple if \a parName is specified or
00072             A list of parameter name and value tuples if \a parName is None.
00073     """
00074     if parName is not None:
00075       if parName in self.__parNames:
00076         return [(parName, self.__parValues[self.__parNames.index(parName)])]
00077     else:
00078       return map(None, self.__parNames, self.__parValues)
00079 
00080   def verify(self):
00081     """!\brief Fill the GUI with data and show it.
00082 
00083     \return 1: If all the parameters have been verified.
00084             0: If there are no parameters or if the operator
00085                hit cancel.
00086     """
00087     if len(self.getParameters()) > 0:
00088       self.__verifyGUI.initialize(self.__testName)
00089       for (parName, parValue) in self.getParameters():
00090         self.__verifyGUI.addParameter(parName, parValue)
00091       self.__verifyGUI.show()
00092       return self.__verifyGUI.exec_loop()
00093     else:
00094       return 1

Generated on Thu Apr 27 20:52:43 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO