Commit b412ffa6 authored by Romain Therville's avatar Romain Therville 🐭

The switchspaceid workflow has been made to update the paths to the

migrated analysis files (broken links and missing files).

Issue#129
parent f632d6aa
......@@ -622,7 +622,7 @@ class Analysis (Component):
file_name = os.path.basename(file)
else :
copyfile(file, os.path.join(self.__get_work_directory(), file_name))
return 'fileadmin' + os.path.join(self.directory, file_name)
return self.get_full_filepath(file_name, 'fileadmin')
def _save_files(self, files, gzip=False):
"""
......@@ -722,6 +722,8 @@ class Analysis (Component):
return t3mysql.select_analysis_directory(str(self.id))
def change_space (self, space_id ):
import os
from ng6.project import Project
ng6conf = NG6ConfigReader()
old_path = ng6conf.get_save_directory() + self.directory
......@@ -749,6 +751,21 @@ class Analysis (Component):
t3mysql = t3MySQLdb()
t3mysql.update_fields('tx_nG6_analyze', str(self.id), ['directory','retention_date'], [str("/"+new_relative_path),new_retention] )
old_dir_name = self.__get_save_directory()
new_dir_name = ng6conf.get_space_directory(space_id)
result_files = t3mysql.get_analysis_result_files(str(self.id), 'fileadmin')
for result_file in result_files :
filename = os.path.basename(result_file['rvalue'])
new_filepath = self.get_full_filepath(filename)
print("new_filepath = " + str(new_filepath))
print("result uid = " + str(result_file['uid']))
t3mysql.update_fields('tx_nG6_result', str(result_file['uid']), ['rvalue'], [str(new_filepath)] )
return [retcode, str_cmd]
def get_full_filepath(self, file_name, base_filepath='fileadmin' ):
return base_filepath + os.path.join(self.directory, file_name)
\ No newline at end of file
......@@ -1066,4 +1066,16 @@ class t3MySQLdb(object):
qresult = self.execute(sql)
return [ r[0] for r in qresult.rows ]
def get_analysis_result_files(self, analysis_id, base_filepath = 'fileadmin'):
sql = "SELECT uid, rvalue FROM tx_nG6_result WHERE analyze_id='"+str(analysis_id)+"' AND rvalue LIKE '"+str(base_filepath)+"%'"
print(sql)
qresult = self.execute(sql)
results = []
for result in qresult.rows:
results.append({
'uid' : result[0],
'rvalue' : result[1],
})
return results
\ No newline at end of file
......@@ -35,7 +35,6 @@ def migrate_project (project_id, new_space_id, output):
fh.write(log_text)
fh.close()
logging.getLogger("move_project.py").debug(log_text)
print( "os.path.exists("+log_file+")=" + str(os.path.exists(log_file)))
ng6conf = NG6ConfigReader()
base_path = ng6conf.get_save_directory()
......@@ -47,6 +46,7 @@ def migrate_project (project_id, new_space_id, output):
log_to_output_files(str_log, output)
runs = project.get_runs()
#print(runs)
for run in runs :
str_log="\t - ##RUN '" + run.name + "' (" + str(run.id) + ") - " + run.directory + "\n"
log_to_output_files(str_log, output)
......@@ -66,6 +66,8 @@ def migrate_project (project_id, new_space_id, output):
analyzes = project.get_analysis()
for analysis in analyzes :
print(analysis.results)
str_log="\t - ##ANALYSE PROJECT '" + analysis.name + "' (" + str(analysis.id) + ") - " + analysis.directory + "\n"
log_to_output_files(str_log, output)
......
Markdown is supported
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