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

Merge branch 'issue#129' into 'dev'

Merge branch issue#129 with dev

See merge request !106
parents d16c5cf1 eb9dd0cb
......@@ -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_web_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,16 @@ class Analysis (Component):
t3mysql = t3MySQLdb()
t3mysql.update_fields('tx_nG6_analyze', str(self.id), ['directory','retention_date'], [str("/"+new_relative_path),new_retention] )
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_web_filepath(filename)
t3mysql.update_fields('tx_nG6_result', str(result_file['uid']), ['rvalue'], [str(new_filepath)] )
return [retcode, str_cmd]
def get_web_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,15 @@ 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)+"%'"
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()
......@@ -65,7 +64,7 @@ def migrate_project (project_id, new_space_id, output):
log_to_output_files(str_log, output)
analyzes = project.get_analysis()
for analysis in analyzes :
for analysis in analyzes :
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