Maintenance - Mise à jour mensuelle Lundi 6 Avril 2020 entre 7h00 et 9h00

Commit 9a69e3bc authored by Jerome Mariette's avatar Jerome Mariette

add storage_size field and update this one after a sync

parent 599fcb76
......@@ -892,6 +892,7 @@ CREATE TABLE IF NOT EXISTS `tx_nG6_analyze` (
`version` varchar(255) NOT NULL DEFAULT '',
`params` text NOT NULL,
`is_editable` boolean NOT NULL DEFAULT FALSE,
`storage_size` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`),
KEY `parent` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......@@ -974,6 +975,7 @@ CREATE TABLE IF NOT EXISTS `tx_nG6_run` (
`full_seq_size` varchar(255) NOT NULL DEFAULT '0',
`description` varchar(255) NOT NULL DEFAULT '',
`sequencer` varchar(255) NOT NULL DEFAULT '',
`storage_size` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`),
KEY `parent` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
......@@ -209,6 +209,9 @@ class Analysis (Component):
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) + ")")
# update the storage size
t3mysql = t3MySQLdb()
t3mysql.update_analysis_field(self.id, "storage_size", Utils.get_storage_size(self.__get_save_directory()))
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.")
except Exception, err:
......
......@@ -246,6 +246,9 @@ class Run(object):
try: os.rmdir(self.__get_work_directory())
except: pass
logging.getLogger("Run.sync").debug("Synchronization done for run id=" + str(self.id) + "(retcode=" + str(retcode) + ")")
# update the storage size
t3mysql = t3MySQLdb()
t3mysql.update_run_info(self.id, storage_size=Utils.get_storage_size(self.__get_save_directory()))
except Exception, err:
raise Exception(str(err))
......@@ -420,4 +423,4 @@ class Run(object):
return my_run
except :
pass
\ No newline at end of file
......@@ -328,7 +328,7 @@ class t3MySQLdb(object):
conn.close()
return res[0]
def update_run_info(self, run_id, name=None, date=None, directory=None, species=None, data_nature=None, type=None, nb_sequences=None, full_seq_size=None, description=None, sequencer=None, hidden=None):
def update_run_info(self, run_id, name=None, date=None, directory=None, species=None, data_nature=None, type=None, nb_sequences=None, full_seq_size=None, description=None, sequencer=None, hidden=None, storage_size=None):
"""
Add to the database a new Analyze done on a run
@param project_id : the project_id the run belong to
......@@ -344,6 +344,7 @@ class t3MySQLdb(object):
@param description : the run description
@param sequencer : the sequencer used
@param hidden : is the analysis hidden
@param storage_size : the size of the run
"""
conn = connect(self.host, self.user, self.passwd, self.db)
curs = conn.cursor()
......@@ -370,7 +371,9 @@ class t3MySQLdb(object):
if hidden:
req += "hidden=" + str(hidden) + ","
if sequencer:
req += "sequencer='" + sequencer.replace("'", "\'") + "', "
req += "sequencer='" + sequencer.replace("'", "\'") + "',"
if storage_size:
req += "storage_size='" + str(storage_size) + "',"
req = req[:-1] #remove last comma for WHERE
req += " WHERE uid = '"+ str(run_id) + "'"
curs.execute(req)
......@@ -614,4 +617,4 @@ class t3MySQLdb(object):
conn.close()
logging.getLogger("t3MySQLdb.select_analysis").debug("Returning [" + str([res[0], res[1], res[2], res[3], res[4], res[5]]) + "]")
return [res[0], res[1], res[2], res[3], res[4], res[5]]
\ No newline at end of file
......@@ -88,6 +88,14 @@ class Utils(object):
f_in.close()
return f_out_name
@staticmethod
def get_storage_size(start_path):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
@staticmethod
def bz2(file, out_dir, delete=False):
......@@ -386,4 +394,4 @@ class Utils(object):
else:
undetermined_read2_files.append(casava_directory + "/" + current_sample['subdir'] + "/" + file)
return mids_desc_array, sorted(read1_files), sorted(read2_files), sorted(undetermined_read1_files), sorted(undetermined_read2_files)
\ No newline at end of file
return mids_desc_array, sorted(read1_files), sorted(read2_files), sorted(undetermined_read1_files), sorted(undetermined_read2_files)
......@@ -107,13 +107,26 @@ class tx_nG6_upgrade {
ADD tx_nG6_location VARCHAR( 50 ) NOT NULL AFTER tx_nG6_organism
" ;
// Alter tx_nG6_analyze and add is_editable
$queryAlterTxNG6Analayze = "
ALTER TABLE tx_nG6_analyze
ADD is_editable boolean NOT NULL DEFAULT FALSE AFTER params
";
// Alter tx_nG6_analyze and add storage_size
$queryAlterTxNG6AnalayzeSsize = "
ALTER TABLE tx_nG6_analyze
ADD storage_size int(11) NOT NULL DEFAULT '0' AFTER is_editable
";
// Alter tx_nG6_run and add storage_size
$queryAlterTxNG6Run = "
ALTER TABLE tx_nG6_run
ADD storage_size int(11) NOT NULL DEFAULT '0' AFTER sequencer
";
// TODO: process the update of these fields
/*
* Execute all queries
*/
......@@ -123,6 +136,8 @@ class tx_nG6_upgrade {
$GLOBALS['TYPO3_DB']->sql_query($queryUpdateCruseridAnalysisProject);
$GLOBALS['TYPO3_DB']->sql_query($queryAlterFeGroups);
$GLOBALS['TYPO3_DB']->sql_query($queryAlterTxNG6Analayze);
$GLOBALS['TYPO3_DB']->sql_query($queryAlterTxNG6AnalayzeSsize);
$GLOBALS['TYPO3_DB']->sql_query($queryAlterTxNG6Run);
}
/*
......
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