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

gException.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2004
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 
00011 __facility__ = "Online"
00012 __abstract__ = "Exception classes"
00013 __author__   = "Amedeo Perazzo <perazzo@slac.stanford.edu> SLAC - GLAST I&T/Online"
00014 __date__     = ("$Date: 2004/11/05 00:52:47 $").split(' ')[1]
00015 __version__  = "$Revision: 2.13 $"
00016 __release__  = "$Name: R04-12-00 $"
00017 __credits__  = "SLAC"
00018 
00019 import LATTE.copyright_SLAC
00020 
00021 import exceptions
00022 import gOcsMessages
00023 import gFswMessages
00024 
00025 class LATInterfaceStatus(object):
00026   __ERRSTR = {}
00027 
00028   def __invertdict(byid):
00029     byid.update(gOcsMessages.OcsMessages.OCSSTR)
00030     byid.update(gFswMessages.FswMessages.FSWSTR)
00031     byname = {}
00032     for (id, name) in byid.items():
00033       byname[name[0]] = id
00034     return byname
00035 
00036   __ERRSTATUS = __invertdict(__ERRSTR)
00037 
00038   def status(name):
00039     try:
00040       return LATInterfaceStatus.__ERRSTATUS[name]
00041     except:
00042       return None
00043 
00044   def name(status):
00045     try:
00046       return LATInterfaceStatus.__ERRSTR[status]
00047     except:
00048       return ["OCS_UNKNERR",
00049               "OCS client/server don't agree on error code: 0x%08x" %status]
00050 
00051   def message(status):
00052     [name, desc] = LATInterfaceStatus.name(status)
00053     return ' %s (0x%08x): %s' % (name, status, desc)
00054 
00055   status  = staticmethod(status)
00056   name    = staticmethod(name)
00057   message = staticmethod(message)
00058 
00059   def __init__(self, status):
00060     self.__status = status
00061 
00062   def __str__(self):
00063     return LATInterfaceStatus.message(self.__status)
00064 
00065   def errstr(self, status=None):
00066     if status is not None: self.__status = status
00067     return LATInterfaceStatus.name(self.__status)
00068 
00069 
00070 class LATInterfaceException(exceptions.Exception):
00071   def __init__(self, status):
00072     exceptions.Exception.__init__(self, status)
00073     self.status = status
00074 
00075   def __str__(self):
00076     return LATInterfaceStatus.message(self.status)
00077 
00078   def errstr(self):
00079     return LATInterfaceStatus.name(self.status)
00080 

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