Commit a398dbee authored by Romain Therville's avatar Romain Therville 🐭
Browse files

Update to analysis.py

get_web_filepath() function fixed.
Compatible with change_space() and save_file() functions.

Issues #129, #187
parent 52146a94
...@@ -622,8 +622,7 @@ class Analysis (Component): ...@@ -622,8 +622,7 @@ class Analysis (Component):
file_name = os.path.basename(file) file_name = os.path.basename(file)
else : else :
copyfile(file, os.path.join(self.__get_work_directory(), file_name)) 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')
#return self.get_web_filepath(file_name, 'fileadmin')
def _save_files(self, files, gzip=False): def _save_files(self, files, gzip=False):
""" """
...@@ -714,19 +713,7 @@ class Analysis (Component): ...@@ -714,19 +713,7 @@ class Analysis (Component):
result = t3mysql.get_analysis_creation_date(str(self.id)) result = t3mysql.get_analysis_creation_date(str(self.id))
return next(iter(result)) return next(iter(result))
def get_directory(self):
"""
Returns an analysis's directory
"""
if self.id != None :
t3mysql = t3MySQLdb()
return t3mysql.select_analysis_directory(str(self.id))
def change_space (self, space_id ): def change_space (self, space_id ):
"""
Migrate an analysis to another space
@param space_id : the new space id
"""
import os import os
from ng6.project import Project from ng6.project import Project
ng6conf = NG6ConfigReader() ng6conf = NG6ConfigReader()
...@@ -766,12 +753,11 @@ class Analysis (Component): ...@@ -766,12 +753,11 @@ class Analysis (Component):
return [retcode, str_cmd] return [retcode, str_cmd]
def get_web_filepath(self, file_name, base_filepath='fileadmin' ): def get_web_filepath(self, file_name, base_filepath='fileadmin' ):
""" curr_dir=self.directory
returns the full web filepath from a given filename #If analysis already exists, retrieve directory from db (need for migration step, to get the real destination directory)
@param file_name : the path to the file to link if self.id != None :
@param base_filepath : the first directory in the path (depends on the server's directory structure) t3mysql = t3MySQLdb()
@return : the full web filepath curr_dir= t3mysql.select_analysis_directory(str(self.id))
""" return base_filepath + os.path.join(curr_dir, file_name)
return base_filepath + os.path.join(self.get_directory(), file_name)
\ No newline at end of file
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