Package Ganga :: Package Runtime :: Module bootstrap
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Runtime.bootstrap

   1  ################################################################################ 
   2  # Ganga - a computational task management tool for easy access to Grid resources 
   3  # http://cern.ch/ganga 
   4  # 
   5  # Copyright (C) 2003 The Ganga Project 
   6  # 
   7  # This program is free software; you can redistribute it and/or modify 
   8  # it under the terms of the GNU General Public License as published by 
   9  # the Free Software Foundation; either version 2 of the License, or 
  10  # (at your option) any later version. 
  11  # 
  12  # This program is distributed in the hope that it will be useful, 
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  15  # GNU General Public License for more details. 
  16  # 
  17  # You should have received a copy of the GNU General Public License 
  18  # along with this program; if not, write to the Free Software 
  19  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  20  # 
  21  ################################################################################ 
  22   
  23  # store Ganga version based on CVS sticky tag for this file 
  24  _gangaVersion = "$Name: Ganga-5-6-2 $" 
  25   
  26  import re 
  27  # [N] in the pattern is important because it prevents CVS from expanding the pattern itself! 
  28  r = re.compile(r'\$[N]ame: (?P<version>\S+) \$').match(_gangaVersion) 
  29  if r: 
  30     _gangaVersion = r.group('version') 
  31  else: 
  32     _gangaVersion = "SVN_TRUNK" 
  33   
  34  # store a path to Ganga libraries 
  35   
  36  import os.path, Ganga 
  37  _gangaPythonPath = os.path.dirname(os.path.dirname(Ganga.__file__)) 
  38   
  39  from Ganga.Utility.files import fullpath 
  40   
  41  import sys,time 
  42   
  43  #import atexit, traceback 
  44  #def register(f): 
  45  #   print '*'*10 
  46  #   print 'register',f 
  47  #   traceback.print_stack() 
  48  #   _register(f) 
  49  #_register = atexit.register 
  50  #atexit.register = register 
  51   
  52   
  53  TRANSITION_MESSAGE_545 =  """ 
  54  ------------------------------------- 
  55  THIS IS A NEW MAJOR RELEASE OF GANGA 
  56  ------------------------------------- 
  57   
  58  In Ganga 5.5.0 a new version of the Ganga XML Repository (v6.0) is 
  59  introduced. Its main features are enhanced reliability, concurrent 
  60  access from several ganga sessions, and the introduction of a Ganga 
  61  "box", where any Ganga object can be saved. 
  62   
  63  On the first startup of 5.5.0, old AMGA and XML repositories as well as 
  64  GangaTasks from the same gangadir will be automatically imported. The 
  65  old repositories and tasks will not be touched, only a file 
  66  "converted.to.XML.6.0" will be created in 
  67  <gangadir>/repository/Name/LocalAMGA or respectively LocalXML/jobs, 
  68  LocalXML/templates or <gangadir>/tasks.xml.converted.to.XML.6.0. 
  69   
  70  To repeat the import process from scratch, just delete these files 
  71  together with the new repository <gangadir>/repository/Name/LocalXML/6.0 
  72   
  73  The new repository may use much more disk space than the old AMGA 
  74  repository, and some more space than the old XML repository. This does 
  75  however only affect <gangadir>/repository, and not the usually much 
  76  larger workspace directory <gangadir>/workspace. 
  77   
  78  When you are happy with the conversion and completely sure you do not 
  79  want to revert to a previous release you can delete the old repository 
  80  and tasks located in 
  81   
  82  <gangadir>/repository/Name/LocalAMGA 
  83  <gangadir>/repository/Name/LocalXML/5.0 
  84  <gangadir>/tasks.xml 
  85   
  86  ------------------------------------- 
  87  THIS IS A NEW MAJOR RELEASE OF GANGA 
  88  ------------------------------------- 
  89  """ 
  90   
  91   
92 -class GangaProgram:
93 """ High level API to create instances of Ganga programs and configure/run it """ 94
95 - def __init__(self,hello_string=None,argv=sys.argv):
96 """ make an instance of Ganga program 97 use default hello_string if not specified 98 use sys.argv as arguments if not specified""" 99 100 self.argv = argv[:] 101 102 #record the start time.Currently we are using this in performance measurements 103 # see Ganga/test/Performance tests 104 self.start_time = time.time() 105 106 if hello_string is None: 107 self.hello_string = """ 108 *** Welcome to Ganga *** 109 Version: %s 110 Documentation and support: http://cern.ch/ganga 111 Type help() or help('index') for online help. 112 113 This is free software (GPL), and you are welcome to redistribute it 114 under certain conditions; type license() for details. 115 116 """ % _gangaVersion 117 else: 118 self.hello_string = hello_string 119 120 # by default enter interactive mode 121 self.interactive = True 122 123 import os.path 124 self.default_config_file = os.path.expanduser('~/.gangarc')
125 126 # this is a TEMPORARY hack to enable some GUI-specific parts of the core such as monitoring 127 # replaced by self.options.GUI 128 #self.gui_enabled_hack = False 129
130 - def exit(self,*msg):
131 print >> sys.stderr, self.hello_string 132 for m in msg: 133 print >> sys.stderr,'ganga:',m 134 sys.exit(1)
135 136 # parse the options 137
138 - def parseOptions(self):
139 from optparse import OptionParser 140 141 usage = self.hello_string+"""\nusage: %prog [options] [script] [args] ...""" 142 143 parser = OptionParser(usage,version=_gangaVersion) 144 145 parser.add_option("-i", dest="force_interactive", action="store_true", 146 help='enter interactive mode after running script') 147 148 parser.add_option("--webgui", dest="webgui", action="store_true", default='False', 149 help='starts web GUI monitoring server') 150 151 parser.add_option('--gui',dest="GUI",action='store_true',default=False,help='Run Ganga in the GUI mode.') 152 153 parser.add_option("--config", dest="config_file",action="store", metavar="FILE", 154 help='read user configuration from FILE, overrides the GANGA_CONFIG_FILE environment variable. Default: ~/.gangarc') 155 156 parser.add_option("--config-path",dest='config_path',action="store", default=None, 157 help='site/experiment config customization path, overrides the GANGA_CONFIG_PATH environment variable. The relative paths are resolved wrt to the release directory. To use a specific file you should specify the absolute path. Default: None') 158 159 parser.add_option("-g","--generate-config",dest='generate_config',action="store_const",const=1, 160 help='generate a default config file, backup the existing one') 161 162 parser.add_option("-o","--option",dest='cmdline_options',action="append", default=[],metavar='EXPR', 163 help='set configuration options, may be repeated mutiple times,' 164 'for example: -o[Logging]Ganga.Lib=DEBUG -oGangaLHCb=INFO -o[Configuration]TextShell = IPython ' 165 'The VALUE of *_PATH option is prepended. To reset it use :::VALUE') 166 167 parser.add_option("--quiet", dest="force_loglevel",action="store_const",const='ERROR', 168 help='only ERROR messages are printed') 169 170 parser.add_option("--very-quiet", dest="force_loglevel",action="store_const",const='CRITICAL', 171 help='only CRITICAL messages are printed') 172 173 parser.add_option("--debug",dest="force_loglevel",action="store_const",const='DEBUG', 174 help='all messages including DEBUG are printed') 175 176 parser.add_option("--no-mon",dest='monitoring',action="store_const",const=0, 177 help='disable the monitoring loop (useful if you run multiple Ganga sessions)') 178 179 parser.add_option("--no-prompt",dest='prompt',action="store_const",const=0, 180 help='never prompt interactively for anything except IPython (FIXME: this is not fully implemented)') 181 182 parser.add_option("--no-rexec", dest = "rexec", action="store_const",const=0, 183 help='rely on existing environment and do not re-exec ganga process' 184 'to setup runtime plugin modules (affects LD_LIBRARY_PATH)') 185 186 parser.add_option("--test",dest='TEST',action="store_true", default=False, 187 help='run Ganga test(s) using internal test-runner. It requires GangaTest package to be installed.' 188 'Usage example: *ganga --test Ganga/test/MyTestcase* .' 189 'Refer to [TestingFramework] section in Ganga config for more information on how to configure the test runner.') 190 191 parser.set_defaults(force_interactive=False, config_file=None, force_loglevel=None,rexec=1, monitoring=1, prompt=1, generate_config=None) 192 parser.disable_interspersed_args() 193 194 (self.options, self.args) = parser.parse_args(args=self.argv[1:]) 195 196 def file_opens(f,message): 197 try: 198 return file(f) 199 except IOError,x: 200 self.exit(message,x)
201 202 self.options.config_file_set_explicitly = not self.options.config_file is None 203 204 # use GANGA_CONFIG_FILE env var if it's set 205 if self.options.config_file is None: 206 self.options.config_file = os.environ.get('GANGA_CONFIG_FILE',None) 207 208 if self.options.config_file: 209 import Ganga.Utility.files 210 self.options.config_file = Ganga.Utility.files.expandfilename(self.options.config_file) 211 file_opens(self.options.config_file,'reading configuration file') 212 213 # we run in the batch mode if a script has been specified and other options (such as -i) do not force it 214 if len(self.args) > 0: 215 if not self.options.force_interactive: 216 self.interactive = False
217 # Can't check here if the file is readable, because the path isn't known 218 # file_opens(self.args[0],'reading script') 219 220 # this is an option method which runs an interactive wizard which helps new users to start with Ganga 221 # the interactive mode is not entered if -c option was used
222 - def new_user_wizard(self):
223 import os 224 225 def generate(where): 226 import shutil 227 228 flavour = Ganga.Utility.Config.Config.getFlavour() 229 print "Using flavour %s"%flavour 230 if flavour: 231 configtemplate = "CONFIG_TEMPLATE_%s.INI"%flavour 232 else: 233 configtemplate = "CONFIG_TEMPLATE.INI" 234 shutil.copy(os.path.join(os.path.dirname(_gangaPythonPath),'templates',configtemplate),where) 235 print >> sys.stderr, 'Created standard config file',where
236 237 gangadir = os.path.expanduser('~/gangadir') 238 if not os.path.exists(gangadir) \ 239 and not os.path.exists(self.default_config_file) \ 240 and not self.options.config_file_set_explicitly: 241 242 if self.options.prompt: 243 print >> sys.stderr, 'It seems that you run Ganga for the first time' 244 print >> sys.stderr, 'Ganga will send a udp packet each time you start it in order to help the development team understand how ganga is used. You can disable this in the config file by resetting [Configuration]UsageMonitoringURL= ' 245 if self.options.generate_config: 246 yes = 'Y' 247 else: 248 yes = raw_input('Would you like to create config file ~/.gangarc with standard settings ([y]/n) ?') 249 250 if yes == '' or yes[0:1].upper() == 'Y': 251 generate(self.default_config_file) 252 raw_input('Press <Enter> to continue.') 253 254 os.mkdir(gangadir) 255 256 else: 257 258 # FIXME: store_backup is quite badly implemented 259 def store_backup(f): 260 if os.path.exists(f): 261 i = 0 262 for i in range(100): 263 bn = "%s.%.2d"%(f,i) 264 if not os.path.exists(bn): 265 os.rename(self.default_config_file,bn) 266 return bn 267 raise ValueError('too many backup files') 268 269 if self.options.generate_config: 270 try: 271 backup_name = store_backup(self.default_config_file) 272 except Exception,x: 273 self.exit('Failed to create backup file %s'%backup_name) 274 else: 275 print >> sys.stderr, 'Copied current config file to',backup_name 276 generate(self.default_config_file) 277 sys.exit(0) # FIXME: should not sys.exit() 278 279 # configuration procedure: read the configuration files, configure and bootstrap logging subsystem
280 - def configure(self, logLevel = None ):
281 import os,os.path 282 283 import Ganga.Utility.Config 284 from Ganga.Utility.Config import ConfigError 285 286 def parse_cmdline_config_options(cmdline_options): 287 """ Parse a list of command line config options and return a list of triplets (section,option,value). 288 In case of parsing errors, raise ConfigError exception. 289 """ 290 import re 291 mpat = re.compile(r'(\[(?P<section>\S+)\]|)(?P<option>[a-zA-z0-9._/]+)=(?P<value>.+)') 292 section = None 293 294 opts = [] 295 for o in cmdline_options: 296 rpat = mpat.match(o) 297 if rpat is None: 298 raise ConfigError('syntax error: "%s"'%o) 299 else: 300 if rpat.group('section'): 301 section = rpat.group('section') 302 if section is None: 303 raise ConfigError('section not specified: %s' % o) 304 else: 305 opts.append((section,rpat.group('option'),rpat.group('value'))) 306 return opts
307 308 309 def set_cmdline_config_options(sects=None): 310 try: 311 opts = parse_cmdline_config_options(self.options.cmdline_options) 312 for section,option,val in opts: 313 should_set = True 314 if not sects is None and not section in sects: 315 should_set = False 316 if should_set: 317 config = Ganga.Utility.Config.setSessionValue(section,option,val) 318 except ConfigError,x: 319 self.exit('command line option error: %s'%str(x)) 320 321 # set logging options 322 set_cmdline_config_options(sects=['Logging']) 323 324 # we will be reexecutig the process so for the moment just shut up (unless DEBUG was forced with --debug) 325 if self.options.rexec and not os.environ.has_key('GANGA_INTERNAL_PROCREEXEC') and not self.options.generate_config and not os.environ.has_key('GANGA_NEVER_REEXEC'): 326 if self.options.force_loglevel != 'DEBUG': 327 self.options.force_loglevel = 'CRITICAL' 328 pass 329 else: # say hello 330 if logLevel: self.options.force_loglevel = logLevel 331 if self.options.force_loglevel in (None,'DEBUG'): 332 print >> sys.stderr, self.hello_string 333 # self.new_user_wizard() 334 335 if self.options.config_file is None: 336 self.options.config_file = self.default_config_file 337 338 # initialize logging for the initial phase of the bootstrap 339 # will use the default, hardcoded log level in the module until pre-configuration procedure is complete 340 import Ganga.Utility.logging 341 342 Ganga.Utility.logging.force_global_level(self.options.force_loglevel) 343 344 try: 345 cf = file(self.options.config_file) 346 first_line = cf.readline() 347 import re 348 r = re.compile(r'# Ganga configuration file \(\$[N]ame: (?P<version>\S+) \$\)').match(first_line) 349 if not r: 350 Ganga.Utility.logging.getLogger().error('file %s does not seem to be a Ganga config file',self.options.config_file) 351 Ganga.Utility.logging.getLogger().error('try -g option to create valid ~/.gangarc') 352 else: 353 cv = r.group('version').split('-') 354 if cv[1] == '4': 355 Ganga.Utility.logging.getLogger().error('file %s is old an Ganga 4 configuration file (%s)',self.options.config_file,r.group('version')) 356 Ganga.Utility.logging.getLogger().error('try -g option to create valid ~/.gangarc') 357 else: 358 if cv[1] != '5': 359 Ganga.Utility.logging.getLogger().error('file %s was created by a development release (%s)',self.options.config_file, r.group('version')) 360 Ganga.Utility.logging.getLogger().error('try -g option to create valid ~/.gangarc') 361 except IOError,x: 362 pass # ignore all I/O errors (e.g. file does not exist), this is just an advisory check 363 364 if self.options.config_path is None: 365 try: 366 self.options.config_path = os.environ['GANGA_CONFIG_PATH'] 367 except KeyError: 368 self.options.config_path = '' 369 370 import Ganga.Utility.files, Ganga.Utility.util 371 self.options.config_path = Ganga.Utility.files.expandfilename(self.options.config_path) 372 373 try: 374 hostname = Ganga.Utility.util.hostname() 375 except Exception,x: # fixme: use OSError instead? 376 hostname = 'localhost' 377 378 # the system variables (such as VERSION) are put to DEFAULTS section of the config module 379 # so you can refer to them in the config file 380 # additionally they will be visible in the (write protected) [System] config module 381 syscfg = Ganga.Utility.Config.makeConfig('System',"parameters of this ganga session (read-only)",cfile=False) 382 syscfg.addOption('GANGA_VERSION',_gangaVersion,'') 383 syscfg.addOption('GANGA_PYTHONPATH',_gangaPythonPath,'location of the ganga core packages') 384 syscfg.addOption('GANGA_CONFIG_PATH',self.options.config_path, 'site/group specific configuration files as specified by --config-path or GANGA_CONFIG_PATH variable') 385 syscfg.addOption('GANGA_CONFIG_FILE',self.options.config_file,'current user config file used') 386 syscfg.addOption('GANGA_HOSTNAME',hostname,'local hostname where ganga is running') 387 388 def deny_modification(name,x): 389 raise Ganga.Utility.Config.ConfigError('Cannot modify [System] settings (attempted %s=%s)'%(name,x)) 390 syscfg.attachUserHandler(deny_modification,None) 391 syscfg.attachSessionHandler(deny_modification,None) 392 393 import Ganga.Utility.Config 394 395 # the SCRIPTS_PATH must be initialized before the config files are loaded 396 # for the path to be correctly prepended 397 398 from Ganga.Utility.Config import Config, makeConfig 399 config = makeConfig( "Configuration", "global configuration parameters.\nthis is a catch all section." ) 400 config.addOption('SCRIPTS_PATH','Ganga/scripts',"""the search path to scripts directory. 401 When running a script from the system shell (e.g. ganga script) this path is used to search for script""") 402 403 config.addOption('LOAD_PATH', '', "the search path for the load() function") 404 config.addOption('RUNTIME_PATH','',"""path to runtime plugin packages where custom handlers may be added. 405 Normally you should not worry about it. 406 If an element of the path is just a name (like in the example below) 407 then the plugins will be loaded using current python path. This means that 408 some packages such as GangaTest may be taken from the release area.""", 409 examples="""RUNTIME_PATH = GangaGUI 410 RUNTIME_PATH = /my/SpecialExtensions:GangaTest """) 411 412 config.addOption('TextShell','IPython',""" The type of the interactive shell: IPython (cooler) or Console (limited)""") 413 config.addOption('StartupGPI','','block of GPI commands executed at startup') 414 config.addOption('gangadir',Ganga.Utility.Config.expandvars(None,'~/gangadir'),'Location of local job repositories and workspaces. Default is ~/gangadir but in somecases (such as LSF CNAF) this needs to be modified to point to the shared file system directory.',filter=Ganga.Utility.Config.expandvars) 415 config.addOption('repositorytype','LocalXML','Type of the repository.',examples='LocalXML') 416 config.addOption('workspacetype','LocalFilesystem','Type of workspace. Workspace is a place where input and output sandbox of jobs are stored. Currently the only supported type is LocalFilesystem.') 417 418 config.addOption('user','','User name. The same person may have different roles (user names) and still use the same gangadir. Unless explicitly set this option defaults to the real user name.') 419 # detect default user (equal to unix user name) 420 import getpass 421 try: 422 config.options['user'].default_value = getpass.getuser() 423 except Exception,x: 424 raise Ganga.Utility.Config.ConfigError('Cannot get default user name'+str(x)) 425 426 gpiconfig = Ganga.Utility.Config.makeConfig('GPI_Semantics','Customization of GPI behaviour. These options may affect the semantics of the Ganga GPI interface (what may result in a different behaviour of scripts and commands).') 427 428 gpiconfig.addOption('job_submit_keep_going', False, 'Keep on submitting as many subjobs as possible. Option to j.submit(), see Job class for details') 429 gpiconfig.addOption('job_submit_keep_on_fail', False,'Do not revert job to new status even if submission failed. Option to j.submit(), see Job class for details') 430 431 ipconfig = Ganga.Utility.Config.makeConfig('TextShell_IPython','''IPython shell configuration 432 See IPython manual for more details: 433 http://ipython.scipy.org/doc/manual''') 434 try: 435 from IPython import __version__ as ipver 436 except ImportError: 437 ipver="0.6.13" 438 if ipver == "0.6.13": #in older ipython version the option is -noautocall (this is the version shipped with Ganga in 06/2009) 439 noautocall = "'-noautocall'" 440 else: 441 noautocall = "'-autocall','0'" 442 443 ipconfig.addOption('args',"['-colors','LightBG', %s]"%noautocall,'FIXME') 444 445 # import configuration from spyware 446 import spyware 447 448 import Ganga.Utility.ColourText 449 450 disply_config = makeConfig('Display', """control the content and appearence of printing ganga objects: attributes,colours,etc. 451 If ANSI text colours are enabled, then individual colours may be specified like this: 452 fg.xxx - Foreground: %s 453 bg.xxx - Background: %s 454 fx.xxx - Effects: %s 455 """ % (Ganga.Utility.ColourText.Foreground.__doc__, Ganga.Utility.ColourText.Background.__doc__,Ganga.Utility.ColourText.Effects.__doc__ )) 456 457 #[Shell] section 458 shellconfig = makeConfig( "Shell", "configuration parameters for internal Shell utility." ) 459 shellconfig.addOption('IgnoredVars',['_','SHVL','PWD'],'list of env variables not inherited in Shell environment') 460 461 # all relative names in the path are resolved wrt the _gangaPythonPath 462 # the list order is reversed so that A:B maintains the typical path precedence: A overrides B 463 # because the user config file is put at the end it always may override everything else 464 config_files = Ganga.Utility.Config.expandConfigPath(self.options.config_path,_gangaPythonPath) 465 config_files.reverse() 466 config_files.append(self.options.config_file) 467 468 # read-in config files 469 470 #FIXME: need to construct a proper dictionary - cannot use the ConfigPackage directly 471 system_vars = {} 472 for opt in syscfg: 473 system_vars[opt]=syscfg[opt] 474 475 Ganga.Utility.Config.configure(config_files,system_vars) 476 477 # set the system variables to the [System] module 478 #syscfg.setDefaultOptions(system_vars,reset=1) 479 480 # activate the logging subsystem 481 Ganga.Utility.logging.bootstrap() # user defined log level takes effect NOW 482 483 if not self.options.monitoring: 484 self.options.cmdline_options.append('[PollThread]autostart=False') 485 self.logger = Ganga.Utility.logging.getLogger(modulename=True) 486 self.logger.debug('default user name is %s',config['user']) 487 self.logger.debug('user specified cmdline_options: %s',str(self.options.cmdline_options)) 488 489 # override the config options from the command line arguments 490 # the format is [section]option=value OR option=value 491 # in the second case last specified section from previous options is used 492 493 set_cmdline_config_options() 494 495 self.new_user_wizard() 496 497 if self.options.GUI: 498 ## FIXME: CONFIG CHECK 499 ## ??? config['RUNTIME_PATH'] = '' 500 config.setSessionValue('TextShell','GUI') 501 config.setSessionValue('RUNTIME_PATH','GangaGUI') 502 503 if self.options.TEST: 504 ## FIXME: CONFIG CHECK 505 ## ?? config['RUNTIME_PATH'] = '' 506 config.setSessionValue('RUNTIME_PATH','GangaTest') 507 508 # initialize environment: find all user-defined runtime modules and set their environments 509 # if option rexec=1 then initEnvironment restarts the current ganga process (needed for LD_LIBRARY_PATH on linux) 510 # set rexec=0 if you prepare your environment outside of Ganga and you do not want to rexec process
511 - def initEnvironment(self):
512 513 from Ganga.Core.InternalServices import ShutdownManager 514 ShutdownManager.install() 515 516 import os,os.path 517 import Ganga.Utility.Config 518 from Ganga.Utility.Runtime import RuntimePackage, allRuntimes 519 from Ganga.Core import GangaException 520 521 try: 522 # load Ganga system plugins... 523 import plugins 524 except Exception,x: 525 self.logger.critical('Ganga system plugins could not be loaded due to the following reason: %s',str(x)) 526 self.logger.exception(x) 527 raise GangaException(x) 528 529 # initialize runtime packages, they are registered in allRuntimes dictionary automatically 530 try: 531 import Ganga.Utility.files 532 config = Ganga.Utility.Config.getConfig('Configuration') 533 534 #runtime warnings issued by the interpreter may be suppresed 535 #config['IgnoreRuntimeWarnings'] = False 536 config.addOption('IgnoreRuntimeWarnings', False, "runtime warnings issued by the interpreter may be suppresed") 537 if config['IgnoreRuntimeWarnings']: 538 import warnings 539 warnings.filterwarnings(action="ignore", category=RuntimeWarning) 540 541 def transform(x): 542 return os.path.normpath(Ganga.Utility.files.expandfilename(x))
543 544 paths = map(transform,filter(lambda x:x, config['RUNTIME_PATH'].split(':'))) 545 546 for path in paths: 547 r = RuntimePackage(path) 548 except KeyError: 549 pass 550 551 # initialize the environment only if the current ganga process has not been rexeced 552 if not os.environ.has_key('GANGA_INTERNAL_PROCREEXEC') and not os.environ.has_key('GANGA_NEVER_REEXEC'): 553 self.logger.debug('initializing runtime environment') 554 # update environment of the current process 555 for r in allRuntimes.values(): 556 try: 557 _env = r.getEnvironment() 558 if _env: 559 os.environ.update(_env) 560 except Exception,x: 561 Ganga.Utility.logging.log_user_exception() 562 self.logger.error("can't get environment for %s, possible problem with the return value of getEvironment()",r.name,) 563 raise 564 565 566 # in some cases the reexecution of the process is needed for LD_LIBRARY_PATH to take effect 567 # re-exec the process if it is allowed in the options 568 if self.options.rexec: 569 self.logger.debug('re-executing the process for LD_LIBRARY_PATH changes to take effect') 570 os.environ['GANGA_INTERNAL_PROCREEXEC'] = '1' 571 prog = os.path.normpath(sys.argv[0]) 572 os.execv(prog,sys.argv) 573 574 else: 575 self.logger.debug('skipped the environment initialization -- the processed has been re-execed and setup was done already') 576 577 #bugfix 40110 578 if os.environ.has_key('GANGA_INTERNAL_PROCREEXEC'): 579 del os.environ['GANGA_INTERNAL_PROCREEXEC'] 580 581 # bootstrap all system and user-defined runtime modules
582 - def bootstrap(self):
583 import Ganga.Utility.Config 584 config = Ganga.Utility.Config.getConfig('Configuration') 585 586 # transition message from 5.4 -> 5.5 587 if not os.path.exists(os.path.join(config['gangadir'],'repository',config['user'],'LocalXML','6.0')): 588 print TRANSITION_MESSAGE_545 589 590 from Ganga.Core import GangaException 591 from Ganga.Utility.Runtime import allRuntimes 592 import Ganga.Utility.logging 593 594 # load user-defined plugins... 595 for r in allRuntimes.values(): 596 try: 597 r.loadPlugins() 598 except Exception,x: 599 Ganga.Utility.logging.log_user_exception() 600 self.logger.error("problems with loading plugins for %s -- ignored",r.name,) 601 602 from GPIexport import exportToGPI 603 604 from Ganga.Utility.Plugin import allPlugins 605 606 # make all plugins visible in GPI 607 for k in allPlugins.allCategories(): 608 for n in allPlugins.allClasses(k): 609 cls = allPlugins.find(k,n) 610 if not cls._declared_property('hidden'): 611 exportToGPI(n,cls._proxyClass,'Classes') 612 613 # set the default value for the plugins 614 615 default_plugins_cfg = Ganga.Utility.Config.makeConfig('Plugins','''General control of plugin mechanism. 616 Set the default plugin in a given category. 617 For example: 618 default_applications = DaVinci 619 default_backends = LCG 620 ''') 621 622 for opt in default_plugins_cfg: 623 try: 624 category,tag = opt.split('_') 625 except ValueError: 626 self.logger.warning("do not understand option %s in [Plugins]",opt) 627 else: 628 if tag == 'default': 629 try: 630 allPlugins.setDefault(category,default_plugins_cfg[opt]) 631 except Ganga.Utility.Plugin.PluginManagerError,x: 632 self.logger.warning('cannot set the default plugin "%s": %s',opt,x) 633 else: 634 self.logger.warning("do not understand option %s in [Plugins]",opt) 635 636 # set alias for default Batch plugin (it will not appear in the configuration) 637 638 batch_default_name = Ganga.Utility.Config.getConfig('Configuration').getEffectiveOption('Batch') 639 try: 640 batch_default = allPlugins.find('backends',batch_default_name) 641 except Exception,x: 642 raise Ganga.Utility.Config.ConfigError('Check configuration. Unable to set default Batch backend alias (%s)'%str(x)) 643 else: 644 allPlugins.add(batch_default,'backends','Batch') 645 exportToGPI('Batch',batch_default._proxyClass,'Classes') 646 647 from Ganga.GPIDev.Base import ProtectedAttributeError, ReadOnlyObjectError, GangaAttributeError 648 from Ganga.GPIDev.Lib.Job.Job import JobError 649 650 exportToGPI('GangaAttributeError',GangaAttributeError,'Exceptions') 651 exportToGPI('ProtectedAttributeError',ProtectedAttributeError,'Exceptions') 652 exportToGPI('ReadOnlyObjectError',ReadOnlyObjectError,'Exceptions') 653 exportToGPI('JobError',JobError,'Exceptions') 654 655 # initialize external monitoring services subsystem 656 import Ganga.GPIDev.MonitoringServices 657 658 def license(): 659 'Print the full license (GPL)' 660 print file(os.path.join(_gangaPythonPath,'..','LICENSE_GPL')).read()
661 662 exportToGPI('license',license,'Functions') 663 # bootstrap credentials 664 665 from Ganga.GPIDev.Base.Proxy import GPIProxyObjectFactory 666 from Ganga.GPIDev.Credentials import getCredential 667 668 # only the available credentials are exported 669 670 # At this point we expect to have the GridProxy already created 671 # by one of the Grid plugins (LCG/NG/etc) so we search for it in creds cache 672 credential = getCredential(name = 'GridProxy', create = False) 673 if credential: 674 exportToGPI('gridProxy',GPIProxyObjectFactory(credential),'Objects','Grid proxy management object.') 675 676 credential = getCredential('AfsToken') 677 if credential: 678 exportToGPI('afsToken',GPIProxyObjectFactory(credential),'Objects','AFS token management object.') 679 680 # add built-in functions 681 682 from Ganga.GPIDev.Persistency import export, load 683 exportToGPI('load',load,'Functions') 684 exportToGPI('export',export,'Functions') 685 686 def typename(obj): 687 'Return a name of Ganga object as a string, example: typename(j.application) -> "DaVinci"' 688 return obj._impl._name 689 690 def categoryname(obj): 691 'Return a category of Ganga object as a string, example: categoryname(j.application) -> "applications"' 692 return obj._impl._category 693 694 def plugins(category=None): 695 """List loaded plugins. 696 697 If no argument is given return a dictionary of all loaded plugins. 698 Keys are category name. Values are lists of plugin names in each 699 category. 700 701 If a category is specified (for example 'splitters') return a list 702 of all plugin names in this category. 703 """ 704 from Ganga.Utility.Plugin import allPlugins 705 if category: 706 return allPlugins.allClasses(category).keys() 707 else: 708 d = {} 709 for c in allPlugins.allCategories(): 710 d[c] = allPlugins.allCategories()[c].keys() 711 return d 712 713 ### FIXME: DEPRECATED 714 def list_plugins(category): 715 'List all plugins in a given category, OBSOLETE: use plugins(category)' 716 self.logger.warning('This function is deprecated, use plugins("%s") instead',category) 717 from Ganga.Utility.Plugin import allPlugins 718 return allPlugins.allClasses(category).keys() 719 720 def applications(): 721 'return a list of all available applications, OBSOLETE: use plugins("applications")' 722 return list_plugins('applications') 723 724 def backends(): 725 'return a list of all available backends, OBSOLETE: use plugins("backends")' 726 return list_plugins('backends') 727 728 exportToGPI('applications',applications,'Functions') 729 exportToGPI('backends',backends,'Functions') 730 exportToGPI('list_plugins',list_plugins,'Functions') 731 ### FIXME: END DEPRECATED 732 733 exportToGPI('typename',typename,'Functions') 734 exportToGPI('categoryname',categoryname,'Functions') 735 exportToGPI('plugins',plugins,'Functions') 736 737 738 def force_job_completed(j): 739 "obsoleted, use j.force_status('completed') instead" 740 raise GangaException("obsoleted, use j.force_status('completed') instead") 741 742 def force_job_failed(j): 743 "obsoleted, use j.force_status('failed') instead" 744 raise GangaException("obsoleted, use j.force_status('failed') instead") 745 746 exportToGPI('force_job_completed',force_job_completed,'Functions') 747 exportToGPI('force_job_failed',force_job_failed,'Functions') 748 749 # import default runtime modules 750 import Repository_runtime 751 import Ganga.Core 752 import associations 753 754 # bootstrap user-defined runtime modules 755 756 for n,r in zip(allRuntimes.keys(),allRuntimes.values()): 757 try: 758 r.bootstrap(Ganga.GPI.__dict__) 759 except Exception,x: 760 Ganga.Utility.logging.log_user_exception() 761 self.logger.error('problems with bootstrapping %s -- ignored',n) 762 763 # bootstrap runtime modules 764 import Ganga.GPIDev.Lib.Registry 765 from Ganga.GPIDev.Lib.JobTree import JobTree,TreeError 766 import Ganga.GPIDev.Lib.Tasks 767 768 # boostrap the repositories and connect to them 769 for n,k,d in Repository_runtime.bootstrap(): 770 # make all repository proxies visible in GPI 771 exportToGPI(n,k,'Objects',d) 772 773 # JobTree 774 from Ganga.Core.GangaRepository import getRegistry 775 jobtree = GPIProxyObjectFactory(getRegistry("jobs").getJobTree()) 776 exportToGPI('jobtree',jobtree,'Objects','Logical tree view of the jobs') 777 exportToGPI('TreeError',TreeError,'Exceptions') 778 779 # bootstrap the workspace 780 import Workspace_runtime 781 Workspace_runtime.bootstrap() 782 783 # migration repository 784 #from Ganga.Utility.migrate41to42 import JobCheckForV41, JobConvertToV42 785 #JobCheckForV41() 786 #exportToGPI('JobConvertToV42',JobConvertToV42,'Functions') 787 788 #export full_print 789 from Ganga.GPIDev.Base.VPrinter import full_print 790 exportToGPI('full_print',full_print,'Functions') 791 792 # bootstrap core modules 793 Ganga.Core.bootstrap(Ganga.GPI.jobs._impl,self.interactive) 794 795 import Ganga.GPIDev.Lib.Config 796 exportToGPI('config',Ganga.GPIDev.Lib.Config.config,'Objects','access to Ganga configuration') 797 exportToGPI('ConfigError',Ganga.GPIDev.Lib.Config.ConfigError,'Exceptions') 798 799 from Ganga.Utility.feedback_report import report 800 801 exportToGPI('report',report,'Functions') 802 803 # export all configuration items, new options should not be added after this point 804 Ganga.GPIDev.Lib.Config.bootstrap() 805 806 807 ########### 808 # run post bootstrap hooks 809 for r in allRuntimes.values(): 810 try: 811 r.postBootstrapHook() 812 except Exception,x: 813 Ganga.Utility.logging.log_user_exception() 814 self.logger.error("problems with post bootstrap hook for %s",r.name,) 815
816 - def startTestRunner(self):
817 """ 818 run the testing framework 819 """ 820 821 try: 822 from GangaTest.Framework import runner 823 from GangaTest.Framework import htmlizer 824 from GangaTest.Framework import xmldifferencer 825 826 tfconfig = Ganga.Utility.Config.getConfig('TestingFramework') 827 rc = 1 828 if tfconfig['EnableTestRunner']: 829 self.logger.info("Starting Ganga Test Runner") 830 831 if not self.args: 832 self.logger.warning("Please specify the tests to run ( i.e. ganga --test Ganga/test )") 833 return -1 834 835 rc = runner.start(test_selection=" ".join(self.args)) 836 else: 837 self.logger.info("Test Runner is disabled (set EnableTestRunner=True to enable it)") 838 839 if rc > 0 and tfconfig['EnableHTMLReporter']: 840 self.logger.info("Generating tests HTML reports") 841 rc = htmlizer.main(tfconfig) 842 elif rc > 0 and tfconfig['EnableXMLDifferencer']: 843 self.logger.info("Generating difference HTML reports") 844 rc = xmldifferencer.main(self.args) 845 return rc 846 except ImportError,e: 847 self.logger.error("You need GangaTest external package in order to invoke Ganga test-runner.") 848 print e 849 return -1
850 851 # run Ganga in the specified namespace, in principle the namespace should import all names from Ganga.GPI 852 # if namespace is not specified then run in __main__
853 - def run(self,local_ns=None):
854 855 if self.options.webgui == True: 856 from Ganga.Runtime.http_server import start_server 857 start_server() 858 859 def override_credits(): 860 credits._Printer__data += '\n\nGanga: The Ganga Developers (http://cern.ch/ganga)\n' 861 copyright._Printer__data += '\n\nCopyright (c) 2000-2008 The Ganga Developers (http://cern.ch/ganga)\n'
862 863 if local_ns is None: 864 import __main__ 865 local_ns = __main__.__dict__ 866 #save a reference to the Ganga namespace as an instance attribute 867 self.local_ns = local_ns 868 869 # load templates for user-defined runtime modules 870 from Ganga.Utility.Runtime import allRuntimes 871 for r in allRuntimes.values(): 872 r.loadTemplates( local_ns ) 873 874 # exec ~/.ganga.py file 875 fileName = fullpath('~/.ganga.py') 876 if os.path.exists(fileName): 877 try: 878 execfile( fileName, local_ns ) 879 except Exception, x: 880 self.logger.error('Failed to source %s (Error was "%s"). Check your file for syntax errors.', fileName, str(x)) 881 # exec StartupGPI code 882 from Ganga.Utility.Config import getConfig 883 config=getConfig('Configuration') 884 # exec StartupGPI code 885 from Ganga.Utility.Config import getConfig 886 config=getConfig('Configuration') 887 if config['StartupGPI']: 888 #ConfigParser trims the lines and escape the space chars 889 #so we have only one possibility to insert python code : 890 # using explicitly '\n' and '\t' chars 891 code = config['StartupGPI'].replace('\\t','\t').replace('\\n','\n') 892 exec code in local_ns 893 894 # monitor the ganga usage 895 import spyware 896 897 # this logic is a bit convoluted 898 runs_script = len(self.args)>0 899 session_type = config['TextShell'] 900 if runs_script: 901 if not self.interactive: 902 session_type = 'batch' 903 else: 904 session_type += 'startup_script' 905 906 spyware.ganga_started(session_type,interactive=self.interactive,GUI=self.options.GUI,webgui=self.options.webgui,script_file=runs_script, text_shell=config['TextShell'],test_framework=self.options.TEST) 907 908 if self.options.TEST: 909 sys.argv = self.args 910 try: 911 rc = self.startTestRunner() 912 except (KeyboardInterrupt, SystemExit): 913 self.logger.warning('Test Runner interrupted!') 914 sys.exit(1) 915 sys.exit(rc) 916 917 if len(self.args) > 0: 918 # run the script and make it believe it that it is running directly as an executable (sys.argv) 919 saved_argv = sys.argv 920 sys.argv = self.args 921 922 import Ganga.Utility.Runtime 923 path = Ganga.Utility.Runtime.getSearchPath() 924 script = Ganga.Utility.Runtime.getScriptPath( self.args[ 0 ], path ) 925 926 if script: 927 execfile( script, local_ns ) 928 else: 929 self.logger.error( "'%s' not found" % self.args[ 0 ] ) 930 self.logger.info( "Searched in path %s" % path ) 931 sys.exit(1) 932 sys.argv = saved_argv 933 934 # and exit unless -i was specified 935 if not self.interactive: 936 sys.exit(0) 937 938 # interactive python shell 939 940 # customized display hook -- take advantage of coloured text etc. if possible. 941 def _display(obj): 942 if isinstance(obj,type): 943 print 944 print obj 945 return 946 if hasattr(obj,'_display'): 947 print 948 print obj._display(1) 949 return 950 if hasattr(obj,'_impl') and hasattr(obj._impl,'_display'): 951 print 952 print obj._display(1) 953 return 954 print obj 955 956 shell = config['TextShell'] 957 958 import Ganga.Utility.Config.Config 959 #Ganga.Utility.Config.Config.sanityCheck() 960 961 if shell == 'IPython': 962 ipconfig = Ganga.Utility.Config.getConfig('TextShell_IPython') 963 # ipconfig = Ganga.Utility.Config.makeConfig('TextShell_IPython','IPython shell configuration') 964 # ipconfig.addOption('args',"['-colors','LightBG', '-noautocall']",'FIXME') 965 args = eval(ipconfig['args']) 966 967 try: 968 self.logger.warning('Environment variable IPYTHONDIR=%s exists and overrides the default history file for Ganga IPython commands',os.environ['IPYTHONDIR']) 969 except KeyError: 970 newpath = os.path.expanduser('~/.ipython-ganga') 971 oldpath = os.path.expanduser('~/.ipython') 972 os.environ['IPYTHONDIR'] = newpath 973 if not os.path.exists(newpath) and os.path.exists(oldpath): 974 self.logger.warning('Default location of IPython history files has changed.') 975 self.logger.warning('Ganga will now try to copy your old settings from %s to the new path %s. If you do not want that, quit Ganga and wipe off the content of new path: rm -rf %s/*',oldpath,newpath,newpath) 976 import shutil 977 shutil.copytree(oldpath,newpath) 978 979 980 # buffering of log messages from all threads called "GANGA_Update_Thread" 981 # the logs are displayed at the next IPython prompt 982 983 from Ganga.Utility.logging import enableCaching 984 985 import Ganga.Utility.logging 986 Ganga.Utility.logging.enableCaching() 987 988 def ganga_prompt(): 989 if Ganga.Utility.logging.cached_screen_handler: 990 Ganga.Utility.logging.cached_screen_handler.flush() 991 992 credentialsWarningPrompt = '' 993 #alter the prompt only when the internal services are disabled 994 from Ganga.Core.InternalServices import Coordinator 995 if not Coordinator.servicesEnabled: 996 invalidCreds = Coordinator.getMissingCredentials() 997 if invalidCreds: 998 credentialsWarningPrompt = '[%s required]' % ','.join(invalidCreds) 999 if credentialsWarningPrompt: # append newline 1000 credentialsWarningPrompt+='\n' 1001 1002 return credentialsWarningPrompt 1003 1004 from IPython.Shell import IPShellEmbed 1005 #override ipothonrc configuration 1006 ipopts = {'prompt_in1':'${ganga_prompt()}In [\#]:', 1007 'readline_omit__names':2 # disable automatic tab completion for attributes starting with _ or __ 1008 } 1009 ipshell = IPShellEmbed(argv=args,rc_override=ipopts) 1010 # setting displayhook like this is definitely undocumented sort of a hack 1011 ipshell.IP.outputcache.display = _display 1012 ipshell.IP.user_ns['ganga_prompt'] = ganga_prompt 1013 1014 # attach magic functions 1015 import IPythonMagic 1016 1017 #set a custom exception handler wich disables printing of errors' traceback for 1018 #all exceptions inheriting from GangaException 1019 def ganga_exc_handler(self,etype,value,tb): 1020 #print str(etype).split('.')[-1],':', # FIXME: sys.stderr ? 1021 print '\n',value, # FIXME: sys.stderr ? 1022 from Ganga.Core import GangaException 1023 ipshell.IP.set_custom_exc((GangaException,),ganga_exc_handler) 1024 override_credits() 1025 ret = ipshell(local_ns=local_ns,global_ns=local_ns) #global_ns: FIX required by ipython 0.8.4+ 1026 elif shell == 'GUI': 1027 override_credits() 1028 import GangaGUI.Ganga_GUI 1029 GangaGUI.Ganga_GUI.main() 1030 else: 1031 override_credits() 1032 import code 1033 sys.displayhook = _display 1034 c = code.InteractiveConsole(locals=local_ns) 1035 c.interact() 1036
1037 - def log(self,x):
1038 1039 import sys 1040 # FIXME: for some reason self.logger.critical does not print any messages here 1041 if self.options.force_loglevel == 'DEBUG': 1042 import traceback 1043 traceback.print_exc(file=sys.stderr) 1044 else: 1045 print >>sys.stderr, x 1046 print >>sys.stderr, '(consider --debug option for more information)'
1047 1048 # 1049 # 1050 # $Log: not supported by cvs2svn $ 1051 # Revision 1.11.4.1 2009/07/08 11:18:21 ebke 1052 # Initial commit of all - mostly small - modifications due to the new GangaRepository. 1053 # No interface visible to the user is changed 1054 # 1055 # Revision 1.11 2009/04/28 13:37:12 kubam 1056 # simplified handling of logging filters 1057 # 1058 # Revision 1.15 2009/07/20 14:13:44 moscicki 1059 # workaround for wierd OSX execv behaviour (from Ole Weidner) 1060 # 1061 # Revision 1.14 2009/06/10 14:53:05 moscicki 1062 # fixed bug #51592: Add self to logger 1063 # 1064 # Revision 1.13 2009/06/09 10:44:55 moscicki 1065 # removed obsolete variable 1066 # 1067 # Revision 1.12 2009/06/08 15:48:17 moscicki 1068 # fix Ganga to work with newer versions of ipython (-noautocall option was removed in newer ipython versions) 1069 # 1070 # Revision 1.11 2009/04/28 13:37:12 kubam 1071 # simplified handling of logging filters 1072 # 1073 # Revision 1.10 2009/02/02 13:43:26 moscicki 1074 # fixed: bug #44934: Didn't create .gangarc on first usage 1075 # 1076 # Revision 1.9 2008/11/27 15:49:03 moscicki 1077 # extra exception output if cannot load the plugins... 1078 # 1079 # Revision 1.8 2008/11/21 16:34:22 moscicki 1080 # bug #43917: Implement Batch backend as alias to default backend at a given site 1081 # 1082 # Revision 1.7 2008/10/23 15:24:04 moscicki 1083 # install the shutdown manager for atexit handlers before loading system plugins (e.g. LCG download thread registers the atexit handler using a tuple (priority,handler)) 1084 # 1085 # Revision 1.6 2008/09/05 15:55:51 moscicki 1086 # XML differenciater added (from Ulrik) 1087 # 1088 # Revision 1.5 2008/08/18 13:18:59 moscicki 1089 # added force_status() method to replace job.fail(), force_job_failed() and 1090 # force_job_completed() 1091 # 1092 # Revision 1.4 2008/08/18 10:02:15 moscicki 1093 # 1094 # bugfix 40110 1095 # 1096 # Revision 1.3 2008/08/01 15:25:30 moscicki 1097 # typo fix 1098 # 1099 # Revision 1.2 2008/07/31 17:25:02 moscicki 1100 # config templates are now in a separate directory at top level ("templates") 1101 # 1102 # *converted all tabs to spaces* 1103 # 1104 # Revision 1.1 2008/07/17 16:41:00 moscicki 1105 # migration of 5.0.2 to HEAD 1106 # 1107 # the doc and release/tools have been taken from HEAD 1108 # 1109 # Revision 1.71.4.23 2008/07/03 16:11:31 moscicki 1110 # bug #38000: Add check for old .gangarc file 1111 # 1112 # Revision 1.71.4.22 2008/04/03 12:55:45 kuba 1113 # importing core plugins before initEnvironment(), this fixes 1114 # bug #35146: GangaAtlas is not starting due to gridshell call in __init__.py 1115 # 1116 # Revision 1.71.4.21 2008/04/01 14:08:03 roma 1117 # automatic config file template generation (Vladimir) 1118 # 1119 # Revision 1.71.4.20 2008/03/31 15:32:46 kubam 1120 # use more flexible logic for hidden classes 1121 # 1122 # Revision 1.71.4.19 2008/03/12 17:33:32 moscicki 1123 # workaround for broken logging system: GangaProgram.log writes directly to stderr 1124 # 1125 # Revision 1.71.4.18 2008/03/11 15:24:51 moscicki 1126 # merge from Ganga-5-0-restructure-config-branch 1127 # 1128 # Revision 1.71.4.17.2.1 2008/03/07 13:34:38 moscicki 1129 # workspace component 1130 # 1131 # Revision 1.71.4.17 2008/03/06 14:14:55 moscicki 1132 # streamlined session options logic 1133 # moved sanityCheck to config.bootstrap() 1134 # 1135 # Revision 1.71.4.16 2008/03/06 11:26:52 amuraru 1136 # fixed .ganga.py sourcing file 1137 # 1138 # Revision 1.71.4.15 2008/03/05 14:53:33 amuraru 1139 # execute ~/.ganga.py file before executing StartupGPI code 1140 # 1141 # Revision 1.71.4.14 2008/02/28 10:08:32 amuraru 1142 # *** empty log message *** 1143 # 1144 # Revision 1.71.4.13 2008/02/21 12:11:02 amuraru 1145 # added [Shell] section to configure internal Shell utility 1146 # 1147 # Revision 1.71.4.12 2008/02/06 17:04:11 moscicki 1148 # initialize external monitoring services subsystem 1149 # 1150 # Revision 1.71.4.11 2007/12/18 16:51:28 moscicki 1151 # merged from XML repository branch 1152 # 1153 # Revision 1.71.4.10 2007/12/18 13:05:19 amuraru 1154 # removed coverage code from boostrap (moved in GangaTest/Framework/driver.py) 1155 # 1156 # Revision 1.71.4.9 2007/12/13 16:33:02 moscicki 1157 # export more GPI exceptions 1158 # 1159 # Revision 1.71.4.8 2007/12/10 18:55:55 amuraru 1160 # merged changes from Ganga 4.4.4 1161 # 1162 # Revision 1.71.4.7 2007/11/14 11:41:46 amuraru 1163 # 5.0 configuration updated 1164 # 1165 # Revision 1.71.4.6.2.1 2007/11/13 16:26:05 moscicki 1166 # removed obsolete migration GPI commands 1167 # 1168 # Revision 1.71.4.6 2007/11/08 13:21:00 amuraru 1169 # moved testconfig option defintion to GangaTest 1170 # 1171 # Revision 1.71.4.5 2007/11/07 15:10:04 moscicki 1172 # merged in pretty print and GangaList support from ganga-5-dev-branch-4-4-1-will-print branch 1173 # 1174 # 1175 # Revision 1.71.4.4 2007/11/02 15:20:32 moscicki 1176 # moved addOption() before config bootstrap 1177 # 1178 # Revision 1.71.4.3 2007/10/31 13:39:45 amuraru 1179 # update to the new config system 1180 # 1181 # Revision 1.71.4.2 2007/10/25 11:43:11 roma 1182 # Config update 1183 # 1184 # Revision 1.71.4.1 2007/10/12 13:56:26 moscicki 1185 # merged with the new configuration subsystem 1186 # 1187 # Revision 1.71.6.2 2007/10/09 07:31:56 roma 1188 # Migration to new Config 1189 # 1190 # Revision 1.71.6.1 2007/09/25 09:45:12 moscicki 1191 # merged from old config branch 1192 # 1193 # Revision 1.71.8.1 2007/10/30 12:12:08 wreece 1194 # First version of the new print_summary functionality. Lots of changes, but some known limitations. Will address in next version. 1195 # 1196 # Revision 1.76 2007/11/26 12:13:27 amuraru 1197 # decode tab and newline characters in StartupGPI option 1198 # 1199 # Revision 1.75 2007/11/05 12:33:54 amuraru 1200 # fix bug #30891 1201 # 1202 # Revision 1.74 2007/10/29 14:04:08 amuraru 1203 # - added free disk space checking in [PollThread] configuration template 1204 # - added an extra check not to attempt the shutdown of the repository if this has already been stopped 1205 # - save the Ganga namespace as an attribute in Ganga.Runtime._prog 1206 # 1207 # Revision 1.73 2007/10/10 14:47:46 moscicki 1208 # updated doc-strings 1209 # 1210 # Revision 1.72 2007/09/25 15:12:04 amuraru 1211 # 1212 # usa GANGA_CONFIG_FILE environment variable to set the user config file 1213 # 1214 # Revision 1.71 2007/09/11 16:54:52 amuraru 1215 # catch the TestRunner KeyboardInterrupt 1216 # 1217 # Revision 1.70 2007/09/11 14:28:29 amuraru 1218 # implemented FR #28406 to allow definition of GPI statements to be executed at 1219 # startup 1220 # 1221 # Revision 1.69 2007/08/27 10:47:30 moscicki 1222 # overriden credits() and copyright() (request #21906) 1223 # 1224 # Revision 1.68 2007/08/22 15:58:55 amuraru 1225 # Runtime/bootstrap.py 1226 # 1227 # Revision 1.67 2007/08/14 14:47:01 amuraru 1228 # automatically add GangaTest RT package when --test is used 1229 # 1230 # Revision 1.66 2007/08/13 17:22:27 amuraru 1231 # - testing framework small fix 1232 # 1233 # Revision 1.65 2007/08/13 13:19:48 amuraru 1234 # -added EnableTestRunner and EnableHTMLReported to control the testing framework in a more flexible way 1235 # -added GANGA_CONFIG_FILE in [System] config 1236 # 1237 # Revision 1.64 2007/08/13 12:50:18 amuraru 1238 # added EnableTestRunner and EnableHTMLReported to control the testing framework in a more flexible way 1239 # 1240 # Revision 1.63 2007/07/30 12:57:51 moscicki 1241 # removing IPython autocall option (obsoletion of jobs[] syntax and putting jobs() as a replacement) 1242 # 1243 # Revision 1.62 2007/07/27 14:31:55 moscicki 1244 # credential and clean shutdown updates from Adrian (from Ganga-4-4-0-dev-branch) 1245 # 1246 # Revision 1.61 2007/07/10 13:08:32 moscicki 1247 # docstring updates (ganga devdays) 1248 # 1249 # Revision 1.60 2007/06/07 10:25:02 amuraru 1250 # bug-fix: guard against environment update for RuntimePackages exposing null environment dictionary 1251 # 1252 # Revision 1.59 2007/06/04 14:31:22 amuraru 1253 # record start-time of ganga session 1254 # 1255 # Revision 1.58 2007/06/01 08:49:08 amuraru 1256 # Disable the autocompletion of private attributes and methods starting with _ or __ 1257 # 1258 # Revision 1.57 2007/05/21 16:07:57 amuraru 1259 # integrated TestingFramework into ganga itsefl (ganga --test). [TestingFramework] section in Ganga config is used to control it. 1260 # changed Ganga.Runtime.bootstrap default log level to INFO 1261 # 1262 # Revision 1.56 2007/05/11 13:21:24 moscicki 1263 # temporary functions to help getting jobs out of completing and submitting states 1264 # force_job_completed(j): may be applied to completing jobs 1265 # force_job_failed(j): may be applied to submitting or completing jobs 1266 # 1267 # Revision 1.55 2007/05/08 10:32:42 moscicki 1268 # added short GPL license summary at startup and license() command in GPI for full print 1269 # 1270 # Revision 1.54.6.1 2007/06/18 07:44:57 moscicki 1271 # config prototype 1272 # 1273 # Revision 1.54 2007/02/28 18:24:53 moscicki 1274 # moved GangaException to Ganga.Core 1275 # 1276 # Revision 1.53 2007/02/22 13:43:19 moscicki 1277 # pass interactive flag to Core.bootstrap 1278 # 1279 # Revision 1.52 2007/01/25 15:52:39 moscicki 1280 # mergefrom_Ganga-4-2-2-bugfix-branch_25Jan07 (GangaBase-4-14) 1281 # 1282 # Revision 1.51.2.3 2006/12/15 17:12:37 kuba 1283 # added spyware at startup 1284 # 1285 # Revision 1.51.2.2 2006/11/24 14:52:56 amuraru 1286 # only available credentials (afs/gridproxy) are exported 1287 # 1288 # Revision 1.51.2.1 2006/11/24 14:22:05 amuraru 1289 # added support for peek() function 1290 # 1291 # Revision 1.51 2006/10/23 10:59:41 moscicki 1292 # initialize [Configuration]LOAD_PATH 1293 # 1294 # Revision 1.50 2006/10/16 12:53:13 moscicki 1295 # fix the SCRIPTS_PATH mechanism: the . is always in the path and the session level updates are prepending to the default value... fix for bug #20332 overview: Ganga/scripts not included in SCRIPTS_PATH in Atlas.ini 1296 # 1297 # Revision 1.49 2006/10/04 18:16:48 moscicki 1298 # fixed bug #20333 overview: hostname function of Ganga/Utility/util.py sometimes fails 1299 # 1300 # Revision 1.48 2006/09/27 16:38:31 moscicki 1301 # changed AfsToken -> afsToken, GridProxy -> gridProxy and made them real GPI proxy objects 1302 # 1303 # Revision 1.47 2006/09/15 14:23:31 moscicki 1304 # Greeting message goes to stderr (requested by UNOSAT to use Ganga in CGI scripts). 1305 # 1306 # Revision 1.46 2006/08/29 15:11:10 moscicki 1307 # fixed #18084 Additonal global objects for splitters, mergers etc 1308 # 1309 # Revision 1.45 2006/08/29 12:51:57 moscicki 1310 # exported GridProxy and AfsToken singleton objects to GPI 1311 # 1312 # Revision 1.44 2006/08/11 13:13:06 adim 1313 # Added: GangaException as a markup base class for all exception that need to be printed in a usable way in IPython shell 1314 # 1315 # Revision 1.43 2006/08/09 09:07:34 moscicki 1316 # added magic functions ('ganga') 1317 # 1318 # Revision 1.42 2006/07/31 12:13:43 moscicki 1319 # depend on monitoring thread names "GANGA_Update_Thread" to do message buffering in IPython 1320 # 1321 # Revision 1.41 2006/07/27 20:21:24 moscicki 1322 # - fixed option parsing 1323 # - pretty formatting of known exceptions in IPython (A.Muraru) 1324 # 1325 # Revision 1.40 2006/06/21 11:43:00 moscicki 1326 # minor fix 1327 # 1328 # Revision 1.39 2006/03/14 14:53:14 moscicki 1329 # updated comments 1330 # 1331 # Revision 1.38 2006/03/09 08:41:52 moscicki 1332 # --gui option and GUI integration 1333 # 1334 # Revision 1.37 2006/02/13 15:21:25 moscicki 1335 # support for cached logging messages at interactive prompt (messages from monitoring thread are cached in IPython environment and printed at the next prompt) 1336 # 1337 # Revision 1.36 2006/02/10 14:16:00 moscicki 1338 # fixed bugs: 1339 # #13912 Cannot use tilde to give location of INI file 1340 # #14436 problem with -o option at the command line and setting config default for properties 1341 # 1342 # exported ConfigError to GPI 1343 # docstring updates 1344 # 1345 # Revision 1.35 2005/11/25 09:57:37 moscicki 1346 # exported TreeError exception 1347 # 1348 # Revision 1.34 2005/11/14 14:47:38 moscicki 1349 # jobtree added 1350 # 1351 # Revision 1.33 2005/11/14 10:29:10 moscicki 1352 # support for default plugins 1353 # temporary hack for GUI-specific monitoring 1354 # 1355 # Revision 1.32 2005/11/01 11:21:37 moscicki 1356 # support for export/load (KH) 1357 # 1358 # Revision 1.31 2005/10/14 12:54:38 moscicki 1359 # ignore I/O exceptions while checking for ganga3 config file 1360 # 1361 # Revision 1.30 2005/10/12 13:35:23 moscicki 1362 # renamed _gangadir into gangadir 1363 # 1364 # Revision 1.29 2005/10/07 15:08:45 moscicki 1365 # renamed __Ganga4__ into _gangadirm .ganga4 into .gangarc 1366 # added sanity checks to detect old (Ganga3) config files 1367 # added config-path mechanism 1368 # 1369 # Revision 1.28 2005/10/07 08:27:00 moscicki 1370 # all configuration items have default values 1371 # 1372 # Revision 1.27 2005/09/22 12:48:14 moscicki 1373 # import fix 1374 # 1375 # Revision 1.26 2005/09/21 09:12:50 moscicki 1376 # added interactive displayhooks based on obj._display (if exists) 1377 # 1378 # Revision 1.25 2005/08/26 10:12:06 moscicki 1379 # added [System] section (write-protected) with GANGA_VERSION and GANGA_PYTHONPATH (new) 1380 # 1381 # Revision 1.24 2005/08/24 15:24:11 moscicki 1382 # added docstrings for GPI objects and an interactive ganga help system based on pydoc 1383 # 1384 # 1385 # 1386