test_bay.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2009, Willow Garage, Inc.
00006 # All rights reserved.
00007 #
00008 # Redistribution and use in source and binary forms, with or without
00009 # modification, are permitted provided that the following conditions
00010 # are met:
00011 #
00012 #  * Redistributions of source code must retain the above copyright
00013 #    notice, this list of conditions and the following disclaimer.
00014 #  * Redistributions in binary form must reproduce the above
00015 #    copyright notice, this list of conditions and the following
00016 #    disclaimer in the documentation and/or other materials provided
00017 #    with the distribution.
00018 #  * Neither the name of the Willow Garage nor the names of its
00019 #    contributors may be used to endorse or promote products derived
00020 #    from this software without specific prior written permission.
00021 #
00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 # POSSIBILITY OF SUCH DAMAGE.
00034 
00035 ##\author Kevin Watts
00036 
00037 PKG = 'life_test'
00038 
00039 #import roslib
00040 #roslib.load_manifest(PKG)
00041 
00042 
00043 class FailedLoadError(Exception): pass
00044 class BayNameExistsError(Exception): pass
00045 
00046 ##\brief Collection of test bays
00047 class TestRoom:
00048     def __init__(self, hostname):
00049         self.hostname = hostname
00050         self._bays = {}
00051 
00052     def add_bay(self, bay):
00053         if self._bays.has_key(bay.name):
00054             raise BayNameExistsError("Bay %s already exists in room %s." % 
00055                                      (bay.name, self.hostname))
00056         self._bays[bay.name] = bay
00057 
00058     def get_bay_names(self, need_power):
00059         if not need_power:
00060             bays = self._bays.keys()
00061             bays.sort()
00062             return bays
00063 
00064         names = []
00065         for name in self._bays.keys():
00066             if self._bays[name].board is not None:
00067                 names.append(name)
00068         names.sort()
00069         return names
00070 
00071     def get_bay(self, name):
00072         if not self._bays.has_key(name):
00073             return None
00074         return self._bays[name]
00075 
00076 ##\brief Computer, powerboard and breaker to run test
00077 class TestBay:
00078     def __init__(self, xml_doc):
00079         self.name = xml_doc.attributes['name'].value
00080         self.machine = xml_doc.attributes['machine'].value
00081         if xml_doc.attributes.has_key('board'):
00082             self.board = int(xml_doc.attributes['board'].value)
00083             self.breaker = int(xml_doc.attributes['breaker'].value)
00084             if self.breaker not in [0, 1, 2]:
00085                 raise FailedLoadError("Invalid power breaker. Must be [0, 1, 2]")
00086         else:
00087             self.board = None
00088             self.breaker = None
00089         
00090 
00091 
00092 
00093 
00094                             
00095                             


life_test
Author(s): Kevin Watts
autogenerated on Sat Dec 28 2013 17:56:37