~olivier-mattelaer/madanalysis5/ma5_py3_19

« back to all changes in this revision

Viewing changes to madanalysis/core/launcher.py

  • Committer: Eric Conte
  • Date: 2016-12-27 18:35:46 UTC
  • Revision ID: eric.conte@cern.ch-20161227183546-daazajwkbsk0y4xc
fix bug related to zlib detection + restart is allowed in script ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
 
25
25
# Setting global variables of MadAnalysis main
26
 
from madanalysis.core.main import Main
27
 
from string_tools import StringTools
 
26
from madanalysis.core.script_stack import ScriptStack
 
27
from madanalysis.core.main         import Main
 
28
from string_tools                  import StringTools
 
29
 
 
30
# Python import
28
31
import os
29
32
import sys
30
33
import logging
31
 
            
 
34
 
 
35
 
32
36
class MA5mode():
33
37
    
34
38
   def __init__(self):
268
272
        if not expert.Copy(dirname):
269
273
            sys.exit()
270
274
        expert.GiveAdvice()
271
 
        return False
 
275
 
 
276
        return False # Exit with no repeation
272
277
 
273
278
    # Normal mode
274
279
    else:
277
282
        from madanalysis.interpreter.interpreter import Interpreter
278
283
        interpreter = Interpreter(main)
279
284
 
280
 
        # List of ma5script to load
281
 
        myscripts=[]
282
 
        for arg in arglist:
283
 
            filename=os.path.expanduser(arg)
284
 
            filename=os.path.abspath(filename)
285
 
            if not os.path.isfile(filename):
286
 
               logging.getLogger('MA5').warning("The file called '"+filename+"' is not found and will be skipped.")
287
 
            else:
288
 
               myscripts.append(filename)
289
 
    
290
285
        # Executing the ma5 scripts
291
 
        for myscript in myscripts:
292
 
            interpreter.load(myscript)
293
 
    
294
 
        # Exit if script mode activated
295
 
        if len(arglist)!=0 and main.script:
296
 
            interpreter.run_cmd("quit")
297
 
            return False
298
 
    
299
 
        # Interpreter loop
300
 
        else:
301
 
            interpreter.cmdloop()
 
286
        if not ScriptStack.IsEmpty() and not ScriptStack.IsFinished():
 
287
            interpreter.load()
 
288
 
 
289
            # Must be restarted?
302
290
            if main.repeatSession==True:
303
291
                return True
304
 
            else:
305
 
                return False
 
292
             
 
293
            # Exit if script mode activated
 
294
            if main.script:
 
295
                interpreter.run_cmd("quit")
 
296
                return False # Exit with no repeation
 
297
    
 
298
        # Interpreter loop
 
299
        interpreter.cmdloop()
 
300
        if main.repeatSession==True:
 
301
            return True
 
302
        else:
 
303
            return False
306
304
        
307
305
       
308
306
################################################################################
383
381
    # Read arguments
384
382
    mode,arglist = DecodeArguments(version, date)
385
383
 
 
384
    # Deal with the scripts in normal mode
 
385
    if not mode.expertmode:
 
386
        for arg in arglist:
 
387
            ScriptStack.AddScript(arg)
386
388
 
387
389
    # Loop over MA5 sessions
388
390
    # Goal: allowing to restart