startScriptEngine.py

Go to the documentation of this file.
00001 ## \mainpage LICOS Documentation
00002 ## \image html "glast_galaxie.gif"
00003 ##
00004 
00005 #!/usr/local/bin/python
00006 #
00007 #                               Copyright 2005
00008 #                                     by
00009 #                        The Board of Trustees of the
00010 #                     Leland Stanford Junior University.
00011 #                            All rights reserved.
00012 #
00013 
00014 
00015 __facility__ = "Online"
00016 __abstract__ = "Main GUI startup code - modified from startupMainGUI for LICOS"
00017 __author__   = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST I&T/Online"
00018 __date__     = "2005/07/15 23:45:02"
00019 __updated__  = "$Date: 2006/03/08 00:32:20 $"
00020 __version__  = "$Revision: 1.5 $"
00021 __release__  = "$Name: HEAD $"
00022 __credits__  = "SLAC"
00023 
00024 
00025 import LICOS.copyright_SLAC
00026 
00027 import os, threading
00028 from qt import *
00029 import logging as log
00030 
00031 from LICOS.scriptEngine.ScriptEngineCommon import ScriptEngineCommon
00032 from LICOS.scriptEngine.ScriptEngineMain   import ScriptEngineMain
00033 
00034 def startupScriptEngine():
00035   """!\brief Start up the script engine.
00036 
00037   """
00038 
00039   # Declare DBN as global so that we can access it from the Python Shell
00040   global DBN
00041 
00042   rcCommon = ScriptEngineCommon()
00043 
00044   app = rcCommon.getQtApp()
00045   QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
00046 
00047   rcCommon.initialize(startup=True)
00048   #rcCommon.startLogger()
00049   rcCommon.EBFdistribution()
00050 
00051   initStyle(rcCommon.preferences())
00052   runCtl = ScriptEngineMain(rcCommon)
00053   runCtl.connectClicked()
00054   app.setMainWidget(runCtl)
00055   runCtl.show()
00056 
00057   if rcCommon.options().securedir is not None:
00058     login = runCtl.login()
00059     if login == None or login == -2:
00060       app.quit()
00061       return
00062   else:
00063     runCtl.fileLogoutAction.setEnabled(0)
00064 
00065   if rcCommon.options().vscConfig is not None:
00066     if not rcCommon.configureHardware():
00067       app.quit()
00068       return
00069 
00070   DBN = rcCommon.getDBN()
00071   DBN['_prefs'] = rcCommon.preferences()
00072 
00073   threading.currentThread().setName("LICOS_GUI")
00074   app.exec_loop()
00075 
00076 def initStyle(prefs):
00077   """!\brief Initialize the visual style based on preferences.
00078 
00079   \param prefs Preferences
00080 
00081   """
00082   if prefs.has_key('style'):
00083     style = prefs['style']
00084     if style in QStyleFactory.keys():
00085       qApp.setStyle(QStyleFactory.create(style))
00086   font = QApplication.font()
00087   if prefs.has_key('fontfamily'):
00088     font.setFamily(prefs['fontfamily'])
00089   if prefs.has_key('fontsize'):
00090     font.setPointSize(int(prefs['fontsize']))
00091   if prefs.has_key('fontweight'):
00092     font.setWeight(int(prefs['fontweight']))
00093   if prefs.has_key('fontitalic'):
00094     font.setItalic(int(prefs['fontitalic']))
00095   qApp.setFont(font)
00096 
00097 if __name__ == '__main__':
00098   # For profiling, uncomment the two lines below
00099   # and comment out the line after them.
00100   # After running, use the following code to
00101   # analyze the profiling data:
00102   #   import pstats
00103   #   p = pstats.Stats('profile')
00104   #   p.strip_dirs().sort_stats(-1).print_stats()
00105 
00106   #import profile
00107   #profile.run('startupScriptEngine()', 'profile')
00108   startupScriptEngine()

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