test_manager.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2008, 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 PKG = 'life_test'
00036 import roslib
00037 roslib.load_manifest(PKG)
00038 
00039 import wx
00040 
00041 import rospy
00042 
00043 import sys, os
00044 
00045 from roslaunch_caller import roslaunch_caller
00046 
00047 import traceback
00048 
00049 class TestManagerApp(wx.App):
00050     def OnInit(self, debug = False):
00051 
00052         args = rospy.myargv()
00053         debug = len(args) > 1 and args[1] == '--debug'
00054 
00055         try:
00056           self._core_launcher = roslaunch_caller.launch_core()
00057         except Exception, e:
00058             print >> sys.stderr, 'Failed to launch core. Another core may already be running.\n\n'
00059             wx.MessageBox('A ROS core is still running and preventing the Test Manager system from starting. Shut down ROS processes by using the "Kill ROS" icon.','ROS Already Running', wx.OK|wx.ICON_ERROR, None)
00060             traceback.print_exc()
00061             sys.exit(1)
00062             
00063         import life_test.result_dir 
00064         if not life_test.result_dir.check_results_dir():
00065             print >> sys.stderr, "Unable to write to results directory. Permissions invalid"
00066             wx.MessageBox("Unable to write to the \"~/wg_hardware_test/test_manager\" directory. Open a terminal and type, \"sudo chmod +rwx -R ~/wg_hardware_test/test_manager\" to fix the offending directory. You will have to restart Test Manager",
00067                           "Unable to Write Results", wx.OK|wx.ICON_ERROR, None)
00068             sys.exit(1)
00069 
00070         img_path = os.path.join(roslib.packages.get_pkg_dir(PKG), 'xrc', 'splash.jpg')
00071         
00072         bitmap = wx.Bitmap(img_path, type=wx.BITMAP_TYPE_JPEG)
00073         self._splash = wx.SplashScreen(bitmap, wx.SPLASH_CENTRE_ON_SCREEN, 30000, None, -1)
00074 
00075         rospy.init_node("Test_Manager")
00076 
00077         import life_test.manager
00078 
00079         self._frame = life_test.manager.TestManagerFrame(None, debug)
00080         self._frame.SetSize(wx.Size(1600, 1100))
00081         self._frame.Layout()
00082         self._frame.Centre()
00083 
00084         self._splash.Destroy()
00085         self._splash = None
00086 
00087         self._frame.Show(True)
00088 
00089         return True
00090 
00091     def OnExit(self):
00092         self._core_launcher.stop()
00093 
00094         if self._splash:
00095           self._splash.Destroy()
00096 
00097 if __name__ == '__main__':
00098   try:
00099     app = TestManagerApp(0)
00100     app.MainLoop()
00101   except Exception, e:
00102     print >> sys.stderr, "Caught exception in TestManagerApp Main Loop"
00103     import traceback
00104     traceback.print_exc()


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