Commit 8302a3c1 authored by Gerald Salin's avatar Gerald Salin
Browse files

Merge branch 'run_date' into 'master'

#89 : rundate and analysis date are set one day before the real date

See merge request !22
parents 58459b80 5ca5e424
...@@ -22,7 +22,7 @@ __version__ = '1.0' ...@@ -22,7 +22,7 @@ __version__ = '1.0'
__email__ = 'support.bioinfo.genotoul@inra.fr' __email__ = 'support.bioinfo.genotoul@inra.fr'
__status__ = 'beta' __status__ = 'beta'
import datetime, time, logging import datetime, time, calendar, logging
import pymysql import pymysql
import pymysql.cursors import pymysql.cursors
import collections import collections
...@@ -191,7 +191,7 @@ class t3MySQLdb(object): ...@@ -191,7 +191,7 @@ class t3MySQLdb(object):
if self.project_exists(name) : if self.project_exists(name) :
raise ValueError("Impossible to create project %s, this name is already used!"%name) raise ValueError("Impossible to create project %s, this name is already used!"%name)
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
if cruser_login: # If the administrator login is specified if cruser_login: # If the administrator login is specified
admin_id = self.get_user_id(cruser_login) admin_id = self.get_user_id(cruser_login)
...@@ -311,13 +311,14 @@ class t3MySQLdb(object): ...@@ -311,13 +311,14 @@ class t3MySQLdb(object):
@param cruser_login : the create user login @param cruser_login : the create user login
@param hidden : is the analysis hidden @param hidden : is the analysis hidden
""" """
logging.getLogger("t3MySQLdb.add_run").debug("Inserting run with date of run =" + str(date))
cruser_id = self.get_user_id(cruser_login) cruser_id = self.get_user_id(cruser_login)
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
retention_date = time.mktime((datetime.date.today() + datetime.timedelta(days=365*int(self.cfg_reader.get_retention_time()))).timetuple()) retention_date = time.mktime((datetime.date.today() + datetime.timedelta(days=365*int(self.cfg_reader.get_retention_time()))).timetuple())
sql = "INSERT INTO tx_nG6_run (pid, tstamp, crdate, cruser_id, name, date, directory, species, data_nature,\ sql = "INSERT INTO tx_nG6_run (pid, tstamp, crdate, cruser_id, name, date, directory, species, data_nature,\
type, nb_sequences, full_seq_size, description, hidden, sequencer, retention_date, data_state, purged_date, purged_size, mail_sent_date) VALUES ('%s', '%s', '%s', %s, '%s', '%s','%s',\ type, nb_sequences, full_seq_size, description, hidden, sequencer, retention_date, data_state, purged_date, purged_size, mail_sent_date) VALUES ('%s', '%s', '%s', %s, '%s', '%s','%s',\
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, cruser_id, self.esc_q(name), '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, cruser_id, self.esc_q(name),
time.mktime(date.timetuple()), directory, self.esc_q(species), calendar.timegm(date.timetuple()), directory, self.esc_q(species),
self.esc_q(data_nature), self.esc_q(type), nb_sequences, self.esc_q(data_nature), self.esc_q(type), nb_sequences,
full_seq_size, self.esc_q(description), hidden, self.esc_q(sequencer),retention_date, "stored","0","0","0") full_seq_size, self.esc_q(description), hidden, self.esc_q(sequencer),retention_date, "stored","0","0","0")
qresult = self.execute(sql, commit = True) qresult = self.execute(sql, commit = True)
...@@ -337,7 +338,7 @@ class t3MySQLdb(object): ...@@ -337,7 +338,7 @@ class t3MySQLdb(object):
@param project_id : the project_id the run belong to @param project_id : the project_id the run belong to
@param run_id : the run to add @param run_id : the run to add
""" """
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
sql = "INSERT INTO tx_nG6_project_run (pid, tstamp, crdate, project_id, run_id) \ sql = "INSERT INTO tx_nG6_project_run (pid, tstamp, crdate, project_id, run_id) \
VALUES('%s', '%s', '%s', '%s','%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, project_id, run_id) VALUES('%s', '%s', '%s', '%s','%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, project_id, run_id)
self.execute(sql, commit = True) self.execute(sql, commit = True)
...@@ -594,7 +595,7 @@ class t3MySQLdb(object): ...@@ -594,7 +595,7 @@ class t3MySQLdb(object):
@param name : the sample name @param name : the sample name
@return sample id @return sample id
""" """
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
column_names = [ 'pid', 'tstamp', 'run_id', 'sample_id', 'reads1' ] column_names = [ 'pid', 'tstamp', 'run_id', 'sample_id', 'reads1' ]
column_vals = [ "'%s'" % self.cfg_reader.get_pid(), column_vals = [ "'%s'" % self.cfg_reader.get_pid(),
"'%s'" % crdate, "'%s'" % crdate,
...@@ -689,7 +690,7 @@ class t3MySQLdb(object): ...@@ -689,7 +690,7 @@ class t3MySQLdb(object):
@param is_editable : True if analysis has been added by an user @param is_editable : True if analysis has been added by an user
""" """
cruser_id = self.get_user_id(cruser_login) cruser_id = self.get_user_id(cruser_login)
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
retention_date = time.mktime((datetime.date.today() + datetime.timedelta(days=365*int(self.cfg_reader.get_retention_time()))).timetuple()) retention_date = time.mktime((datetime.date.today() + datetime.timedelta(days=365*int(self.cfg_reader.get_retention_time()))).timetuple())
if is_editable : analysis_is_editable = 1 if is_editable : analysis_is_editable = 1
...@@ -720,7 +721,7 @@ class t3MySQLdb(object): ...@@ -720,7 +721,7 @@ class t3MySQLdb(object):
@param project_id : the project_id the analysis has been done on @param project_id : the project_id the analysis has been done on
@param analysis_id : the analysis id @param analysis_id : the analysis id
""" """
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
sql = "INSERT INTO tx_nG6_project_analyze (pid, tstamp, crdate, project_id,\ sql = "INSERT INTO tx_nG6_project_analyze (pid, tstamp, crdate, project_id,\
analyze_id) VALUES('%s','%s','%s','%s','%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, project_id, analysis_id ) analyze_id) VALUES('%s','%s','%s','%s','%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, project_id, analysis_id )
self.execute(sql, commit = True) self.execute(sql, commit = True)
...@@ -731,7 +732,7 @@ class t3MySQLdb(object): ...@@ -731,7 +732,7 @@ class t3MySQLdb(object):
@param run_id : the run_id the analysis has been done on @param run_id : the run_id the analysis has been done on
@param analysis_id : the analysis id @param analysis_id : the analysis id
""" """
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
sql = "INSERT INTO tx_nG6_run_analyze (pid, tstamp, crdate, run_id, analyze_id) \ sql = "INSERT INTO tx_nG6_run_analyze (pid, tstamp, crdate, run_id, analyze_id) \
VALUES('%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, run_id, analysis_id) VALUES('%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, run_id, analysis_id)
self.execute(sql, commit = True ) self.execute(sql, commit = True )
...@@ -745,7 +746,7 @@ class t3MySQLdb(object): ...@@ -745,7 +746,7 @@ class t3MySQLdb(object):
@param value : the result value @param value : the result value
@param group : the group value @param group : the group value
""" """
crdate = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] crdate = str(time.time()).split(".")[0]
sql = "INSERT INTO tx_nG6_result (pid, tstamp, crdate, analyze_id, file, rkey, rvalue, rgroup) \ sql = "INSERT INTO tx_nG6_result (pid, tstamp, crdate, analyze_id, file, rkey, rvalue, rgroup) \
VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate, VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % ( self.cfg_reader.get_pid(), crdate, crdate,
analysis_id, file, key, value, group ) analysis_id, file, key, value, group )
...@@ -1006,7 +1007,7 @@ class t3MySQLdb(object): ...@@ -1006,7 +1007,7 @@ class t3MySQLdb(object):
return(qresult) return(qresult)
def set_purge_demand_deleted(self, demand_ids): def set_purge_demand_deleted(self, demand_ids):
date = str(time.mktime(datetime.date.today().timetuple())).split(".")[0] date = str(time.time()).split(".")[0]
parts = [ parts = [
'SELECT', 'SELECT',
'tx_nG6_purge_demand.uid AS demand_id,', 'tx_nG6_purge_demand.uid AS demand_id,',
......
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