Commit 80a24f41 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

No commit message

No commit message
parent a5656b8e
......@@ -194,28 +194,29 @@ class Analysis (Component):
"""
Synchronize data related to the Analysis between temporary folder and long term storage folder.
"""
if not os.path.isdir(self.__get_save_directory()) and len(os.listdir(self.__get_work_directory())):
logging.getLogger("Analysis.sync").debug("Synchronizing analysis id=" + str(self.id) + " from " + self.__get_work_directory() + " to " + self.__get_save_directory())
try :
# First make the save directory
os.makedirs(self.__get_save_directory(), 0751)
if os.path.exists(self.__get_work_directory()) and self.__get_work_directory() != self.__get_save_directory():
cmd = "rsync -avh --remove-sent-files "+ self.__get_work_directory() + "/ " + self.__get_save_directory()
logging.getLogger("Analysis.sync").debug(cmd)
retcode = call(["rsync", "-avh", "--remove-sent-files",self.__get_work_directory() + "/", self.__get_save_directory()], shell=False)
if retcode < 0:
logging.getLogger("Analysis.sync").error("Error when synchronizing analysis id=" + str(self.id) + "(retcode=" + str(retcode) + ")")
if os.path.isdir(self.__get_work_directory()):
if not os.path.isdir(self.__get_save_directory()) and len(os.listdir(self.__get_work_directory())):
logging.getLogger("Analysis.sync").debug("Synchronizing analysis id=" + str(self.id) + " from " + self.__get_work_directory() + " to " + self.__get_save_directory())
try :
# First make the save directory
os.makedirs(self.__get_save_directory(), 0751)
if os.path.exists(self.__get_work_directory()) and self.__get_work_directory() != self.__get_save_directory():
cmd = "rsync -avh --remove-sent-files "+ self.__get_work_directory() + "/ " + self.__get_save_directory()
logging.getLogger("Analysis.sync").debug(cmd)
retcode = call(["rsync", "-avh", "--remove-sent-files",self.__get_work_directory() + "/", self.__get_save_directory()], shell=False)
if retcode < 0:
logging.getLogger("Analysis.sync").error("Error when synchronizing analysis id=" + str(self.id) + "(retcode=" + str(retcode) + ")")
else:
try: os.rmdir(self.__get_work_directory())
except: pass
logging.getLogger("Analysis.sync").debug("Synchronization done for analysis id=" + str(self.id) + "(retcode=" + str(retcode) + ")")
else:
try: os.rmdir(self.__get_work_directory())
except: pass
logging.getLogger("Analysis.sync").debug("Synchronization done for analysis id=" + str(self.id) + "(retcode=" + str(retcode) + ")")
else:
logging.getLogger("Analysis.sync").info("The synchronisation has not been performed, either because " + self.__get_work_directory() + " does not exists or because the source and destination folders are the same.")
# update the storage size
t3mysql = t3MySQLdb()
t3mysql.update_analysis_field(self.id, "storage_size", Utils.get_storage_size(self.__get_save_directory()))
except Exception, err:
raise Exception(str(err))
logging.getLogger("Analysis.sync").info("The synchronisation has not been performed, either because " + self.__get_work_directory() + " does not exists or because the source and destination folders are the same.")
# update the storage size
t3mysql = t3MySQLdb()
t3mysql.update_analysis_field(self.id, "storage_size", Utils.get_storage_size(self.__get_save_directory()))
except Exception, err:
raise Exception(str(err))
def list_or_copy_analysis_files(self, outputdir, pattern):
"""
......
......@@ -227,8 +227,7 @@ class Run(object):
try :
for my_analysis in self.get_analysis():
my_analysis.sync()
except Exception, err:
logging.getLogger("Run.sync").error("Error when synchronizing analysis that belongs to run id=" + str(self.id))
except Exception, err: pass
# If a sync is required
if not os.path.isdir(self.__get_save_directory()) and len(os.listdir(self.__get_work_directory())):
# Finally the Run itself
......
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