~ma5dev/madanalysis5/v1.5beta

« back to all changes in this revision

Viewing changes to madanalysis/core/expert_mode.py

  • Committer: Eric Conte
  • Date: 2016-12-08 10:28:55 UTC
  • Revision ID: eric.conte@cern.ch-20161208102855-thahw9h2be839yu6
update all-file with MA5banner + logging.getLogger(MA5)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        
44
44
    def CreateDirectory(self,name):
45
45
        if name=="":
46
 
          logging.info("\nWelcome to the expert mode of MadAnalysis")
47
 
          logging.info("Please enter a folder name for creating an empty SampleAnalyzer job")
 
46
          logging.getLogger('MA5').info("\nWelcome to the expert mode of MadAnalysis")
 
47
          logging.getLogger('MA5').info("Please enter a folder name for creating an empty SampleAnalyzer job")
48
48
          answer=raw_input("Answer: ")
49
49
          answer=answer.replace(' ','_');
50
50
          name  =answer.replace('-','_');
55
55
 
56
56
        # Checking folder
57
57
        if self.path in self.forbiddenpaths:
58
 
            logging.error("the folder '"+anwser+"' is a MadAnalysis folder. " + \
 
58
            logging.getLogger('MA5').error("the folder '"+anwser+"' is a MadAnalysis folder. " + \
59
59
                         "You cannot overwrite it. Please choose another folder.")
60
60
            return False
61
61
 
62
62
        # Checking if the job folder exists
63
63
        if os.path.isdir(self.path):
64
 
            logging.warning("A directory called '"+self.path+"' is already "+ \
 
64
            logging.getLogger('MA5').warning("A directory called '"+self.path+"' is already "+ \
65
65
                            "defined.\nWould you like to remove it ? (Y/N)")
66
66
            allowed_answers=['n','no','y','yes']
67
67
            answer=""
82
82
        jobber = JobWriter(self.main,self.path,False)
83
83
        
84
84
        # Writing process
85
 
        logging.info("   Creating folder '"+self.path+"'...")
 
85
        logging.getLogger('MA5').info("   Creating folder '"+self.path+"'...")
86
86
        if not jobber.Open():
87
 
            logging.error("job submission aborted.")
 
87
            logging.getLogger('MA5').error("job submission aborted.")
88
88
            return False
89
89
 
90
90
        # Copying SampleAnalyzer
91
 
        logging.info("   Copying required 'SampleAnalyzer' source files...")
 
91
        logging.getLogger('MA5').info("   Copying required 'SampleAnalyzer' source files...")
92
92
        if not jobber.CopyLHEAnalysis():
93
 
            logging.error("   job submission aborted.")
 
93
            logging.getLogger('MA5').error("   job submission aborted.")
94
94
            return False
95
95
 
96
96
        # Writing an empty analysis
97
97
        if name=="":
98
 
          logging.info("Please enter a name for your analysis")
 
98
          logging.getLogger('MA5').info("Please enter a name for your analysis")
99
99
          title=raw_input("Answer: ")
100
100
          if title=="":
101
101
              title="user"
102
102
          title=title.replace(' ', '_');
103
103
          name=title.replace('-', '_');
104
 
        logging.info("   Writing an empty analysis...")
 
104
        logging.getLogger('MA5').info("   Writing an empty analysis...")
105
105
        os.system("cd "+self.path+"/Build/SampleAnalyzer; python newAnalyzer.py " + name + " 1")
106
106
 
107
107
        # Extracting analysis name
117
117
        file.close()
118
118
 
119
119
        # Writing a Makefile
120
 
        logging.info("   Writing a 'Makefile'...")
 
120
        logging.getLogger('MA5').info("   Writing a 'Makefile'...")
121
121
        if not jobber.WriteMakefiles():
122
 
            logging.error("job submission aborted.")
 
122
            logging.getLogger('MA5').error("job submission aborted.")
123
123
            return False
124
124
 
125
125
        # Writing Main
126
126
        if not jobber.CreateBldDir(analysisName=title,outputName="user.saf"):
127
 
            logging.error("   job submission aborted.")
 
127
            logging.getLogger('MA5').error("   job submission aborted.")
128
128
            return False
129
129
 
130
130
        # adding the CLs script if available
133
133
 
134
134
 
135
135
    def GiveAdvice(self):
136
 
        logging.info("\nGuidelines for writing an analysis in expert mode\n")
137
 
        logging.info(" 1. Entering the directory '"+self.path+"/Build'\n")
138
 
        logging.info(" 2. Setting the environment variables by loading setup.sh or setup.csh according to your SHELL\n")
139
 
        logging.info(" 3. Entering the directory '"+self.path+"/Build/SampleAnalyzer/User/Analyzer'\n")
140
 
        logging.info(" 4. Editing Analysis 'user.h' and 'user.cpp' files\n")
141
 
        logging.info(" 5. Entering the directory '"+self.path+"/Build'\n")
142
 
        logging.info(" 6. Compiling with the command 'make'\n")
143
 
        logging.info(" 7. Writing a list of datasets\n")
144
 
        logging.info(" 8. Launching SampleAnalyzer with the list of datasets\n")
 
136
        logging.getLogger('MA5').info("\nGuidelines for writing an analysis in expert mode\n")
 
137
        logging.getLogger('MA5').info(" 1. Entering the directory '"+self.path+"/Build'\n")
 
138
        logging.getLogger('MA5').info(" 2. Setting the environment variables by loading setup.sh or setup.csh according to your SHELL\n")
 
139
        logging.getLogger('MA5').info(" 3. Entering the directory '"+self.path+"/Build/SampleAnalyzer/User/Analyzer'\n")
 
140
        logging.getLogger('MA5').info(" 4. Editing Analysis 'user.h' and 'user.cpp' files\n")
 
141
        logging.getLogger('MA5').info(" 5. Entering the directory '"+self.path+"/Build'\n")
 
142
        logging.getLogger('MA5').info(" 6. Compiling with the command 'make'\n")
 
143
        logging.getLogger('MA5').info(" 7. Writing a list of datasets\n")
 
144
        logging.getLogger('MA5').info(" 8. Launching SampleAnalyzer with the list of datasets\n")