Commit db51d9e5 authored by Audrey Gibert's avatar Audrey Gibert
Browse files

Adding some logging in src/ng/analysis.py et /src/ng6/t3MySQL.py

parent 992a5b3b
......@@ -50,33 +50,53 @@ def add_analysis(parent_id, analysis_cfg, *input_files):
from ng6.project import Project
from ng6.run import Run
import pickle
import logging
logging.getLogger("Analysis").debug("Start. Imports went good.")
# get inputs from parameters
analysis_serialized_path = input_files[0]
try: parent_analysis_cfg = input_files[1]
except: parent_analysis_cfg = None
logging.getLogger("Analysis").debug("Start. parent_analysis_cfg is initialised.")
# load the analysis object
analysis_dump = open(analysis_serialized_path, "rb")
analysis = pickle.load(analysis_dump)
analysis_dump.close()
logging.getLogger("Analysis").debug("Dump. analysis_dump is closed and analysis is loaded.")
# add the parent information
logging.getLogger("Analysis").debug("parent_analysis_cfg. Starting")
if parent_analysis_cfg:
if os.path.isfile(parent_analysis_cfg):
logging.getLogger("Analysis").debug("parent_analysis_cfg. Analysis.get_from_file(parent_analysis_cfg) is about to start")
parent = Analysis.get_from_file(parent_analysis_cfg)
logging.getLogger("Analysis").debug("parent_analysis_cfg. Analysis.get_from_file(parent_analysis_cfg) is done")
analysis.parent = parent
elif parent_id != 'none' :
logging.getLogger("Analysis").debug("parent_analysis_cfg. Analysis.get_from_file(parent_analysis_cfg) is about to start")
parent = Analysis.get_from_id(int(parent_id))
analysis.parent = parent
logging.getLogger("Analysis").debug("parent_analysis_cfg. Analysis.get_from_file(parent_analysis_cfg) is done")
# process the parsing of the analysis
logging.getLogger("Analysis").debug("analysis.post_process. Starting")
analysis.post_process()
logging.getLogger("Analysis").debug("analysis.post_process. Done")
# add the analysis to the right run/project object
if analysis.project: analysis.project.add_analysis(analysis)
elif analysis.run: analysis.run.add_analysis(analysis)
logging.getLogger("Analysis").debug("analysis.project. Starting add_analysis(analysis)")
if analysis.project:
logging.getLogger("Analysis").debug("analysis.project. Starting analysis.project.add_analysis(analysis)")
analysis.project.add_analysis(analysis)
logging.getLogger("Analysis").debug("analysis.project. Finishing analysis.project.add_analysis(analysis)")
elif analysis.run:
logging.getLogger("Analysis").debug("analysis.project. Starting analysis.run.add_analysis(analysis)")
analysis.run.add_analysis(analysis)
logging.getLogger("Analysis").debug("analysis.project. Finishing analysis.run.add_analysis(analysis)")
logging.getLogger("Analysis").debug("Config File. Starting the writing of config file")
analysis.write_config_file()
logging.getLogger("Analysis").debug("Config File. Is written")
class Analysis (Component):
"""
......@@ -115,12 +135,16 @@ class Analysis (Component):
# Set the temp folder to the ng6 temp folder
ng6conf = NG6ConfigReader()
logging.getLogger("Analysis.__init__").debug("ng6conf est chargé")
tempfile.tempdir = ng6conf.get_tmp_directory()
logging.getLogger("Analysis.__init__").debug("tempfile.tempdir = " + tempfile.tempdir)
if not os.path.isdir(tempfile.tempdir):
os.makedirs(tempfile.tempdir, 0o751)
if id != None : # If not a new analysis
logging.getLogger("Analysis.__init__").debug("Connexion à la BD")
t3mysql = t3MySQLdb()
logging.getLogger("Analysis.__init__").debug("Connexion effectuée")
self.run = Run.get_from_id(self.__get_run_id())
from ng6.project import Project
self.project = Project.get_from_id(self.__get_project_id())
......@@ -133,7 +157,9 @@ class Analysis (Component):
directory_name = uuid.uuid4().hex[:9]
while True:
save_dir = os.path.join(ng6conf.get_save_directory()+self.DIRECTORIES_STRUCTURE, directory_name)
logging.getLogger("Analysis.__init__").debug("Building analysis save_dir=" + save_dir)
work_dir = os.path.join(ng6conf.get_work_directory()+self.DIRECTORIES_STRUCTURE, directory_name)
logging.getLogger("Analysis.__init__").debug("Building analysis work_dir=" + save_dir)
if not os.path.isdir(save_dir) and not os.path.isdir(work_dir):
break
directory_name = uuid.uuid4().hex[:9]
......@@ -280,13 +306,16 @@ class Analysis (Component):
update the database info
"""
# First add the run into the database
logging.getLogger("Analysis.save").debug("Connexion try")
t3mysql = t3MySQLdb()
logging.getLogger("Analysis.save").debug("Connexion done")
if self.parent: parent_uid = self.parent.id
else: parent_uid = 0
logging.getLogger("Analysis.save").debug("Doing the add analysis")
self.id = t3mysql.add_analysis(self.get_template(), self.name, self.description, self.admin_login,
datetime.date.today(), self.directory, self.software, self.version,
self.options, self.is_editable, parent_uid=parent_uid)
logging.getLogger("Analysis.save").debug("add_analysis done")
# Then add all results link to this analysis
for file in self.results:
for result in self.results[file]:
......
......@@ -736,7 +736,9 @@ class t3MySQLdb(object):
sql = "INSERT INTO tx_nG6_result (pid, tstamp, crdate, analyze_id, file, rkey, rvalue, rgroup) \
VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate,
analysis_id, file, key, value, group )
logging.getLogger("t3MySQL").debug("add_result. sql created : " + sql)
self.execute(sql, commit = True )
logging.getLogger("t3MySQL").debug("add_result. executed")
def update_analysis_field(self, analysis_id, field, value):
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment