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

Trendable.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 __facility__ = "Online"
00011 __abstract__ = "GLAST LAT Housekeeping server infrastructure"
00012 __author__   = "Jim Panetta <panetta@slac.stanford.edu> SLAC - GLAST I&T"
00013 __date__     = "07/28/04"
00014 __version__  = "$Revision: 1.2 $"
00015 __release__  = "$Name: R04-12-00 $"
00016 __credits__  = "SLAC"
00017 
00018 import LATTE.copyright_SLAC
00019 
00020 class Trendable(object):
00021   def __init__(self,name,time,content={}):
00022     self.name    = name
00023     self.time    = time
00024     self.content = content
00025 
00026   def __str__(self):
00027     fstring = '%s | %s' + len(self.content.keys()) * ' | %s'
00028     data    = (self.name, self.time) + tuple(self.content.values())
00029     return fstring % data
00030 
00031 
00032 class TrendLimit(object):
00033   def __init__(self,name,compare,limit):
00034     self.name  =name
00035     self.limit =limit
00036     if compare is 'lt':
00037       self.add = 1
00038     elif compare is 'gt':
00039       self.add = -1
00040     else:
00041       raise TypeError("Comparison should be \'lt\' or \'gt\'")
00042     
00043   def check(self, value):
00044     if cmp(value, self.limit) + self.add:
00045       return 'ok'
00046     else:
00047       return self.name

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