Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 8c3236fb authored by Maude Le Jeune's avatar Maude Le Jeune
Browse files

delete segment up to date (using new db)

parent e427abfa
......@@ -30,10 +30,10 @@ function navigation(url) {
// remove checked segments
function del_seg (){
lst = document.getElementsByName('checkbox');
var url="delseg?segid=";
var url="del_lst_seg?seglist=";
for (var i=0;i<lst.length;i++){
if(lst[i].checked){
url = url+lst[i].id+"--";
url = url+lst[i].id+";";
}
}
self.location.href=url;
......
......@@ -174,12 +174,12 @@ class Web:
for s in l:
lst_tag = s[1].split(";")
if tag in lst_tag:
lstseg+=self._get_highlight(s[0])
lstseg+=self._get_fathers(s[0])
if date is not None:
l = conn.execute('select seg_id from tasks where queued_on = ?',(date,)).fetchall()
for s in l:
lstseg+=self._get_highlight(s[0])
lstseg+=self._get_fathers(s[0])
html = self.index(highlight=lstseg)
return html
......@@ -280,7 +280,7 @@ class Web:
if diff == 1:
html += '<ul> <li id=%d ><a href="code?segid=%d">%s</a> : %s\n'%(s[2],s[2],s[0],ss)
elif diff == 0:
html += '</li><li id=%d ><a href="code?segid=%d">%s</a> : %s\n'%(s[2],s[3],s[0],ss)
html += '</li><li id=%d ><a href="code?segid=%d">%s</a> : %s\n'%(s[2],s[2],s[0],ss)
elif diff > 1:
html += '<li id=%d ><a href="code?segid=%d">%s</a> : %s\n'%(s[2],s[2],s[0],ss)
else:
......@@ -320,7 +320,7 @@ class Web:
html += '</ul></div></body></html>'
return html
def _get_highlight(self, segid):
def _get_fathers(self, segid):
""" Append upstream pipeline instance paths to the current path.
Return a list which contains all upstream segment instances
......@@ -335,7 +335,7 @@ class Web:
-------
list of segid, for the upstream segment instances.
"""
lstid = [segid]
lstid = [int(segid)]
conn = sqlite3.connect(self.db_file,check_same_thread=True)
with conn:
fids = conn.execute(
......@@ -344,9 +344,37 @@ class Web:
conn.close()
if fids:
for l in fids:
lstid += self._get_highlight(l[0])
lstid += self._get_fathers(l[0])
return lstid
def _get_children(self, segid):
""" Append dowmstream pipeline instance paths to the current path.
Return a list which contains all downstream segment instances
id for a given segment instance. This is used to delete all dependencies.
Parameters
----------
segid: id of the segment.
Returns
-------
list of segid, for the downstream segment instances.
"""
lstid = [int(segid)]
conn = sqlite3.connect(self.db_file,check_same_thread=True)
with conn:
fids = conn.execute(
'select child_id from segment_relations where father_id = ?'
,(segid,)).fetchall()
conn.close()
if fids:
for l in fids:
lstid += self._get_children(l[0])
return lstid
@cherrypy.expose
@read_access
def code(self, segid=None):
......@@ -358,7 +386,7 @@ class Web:
----------
currdir: string, pipeline instance path.
"""
highlight = self._get_highlight(segid)
highlight = self._get_fathers(segid)
conn = sqlite3.connect(self.db_file,check_same_thread=True)
with conn:
seg, currdir = conn.execute(
......@@ -372,15 +400,43 @@ class Web:
html += '</ul></div></body></html>'
return html
def del_from_checkbox ():
"""
"""
def _delseg(self, lst_seg):
""" Delete a pipeline instance.
Delete all segments and products directories of a pipeline instance.
Parameters
----------
segid: string, list of pipe id ';' separated
"""
## remove everyboby
conn = sqlite3.connect(self.db_file,check_same_thread=True)
segid = lst_seg[0]
with conn:
currdir = conn.execute('select curr_dir from segments where seg_id = ?',(int(segid),)).fetchone()[0]
l = conn.execute('select seg_id from segments where curr_dir like ?',(currdir+'%',))
for e in l:
lst_seg.remove(e[0])
## delete from tasks_relations
l = conn.execute('delete from task_relations where child_id in (select task_id from tasks where seg_id in (select seg_id from segments where segments.curr_dir like ?))',(currdir+'%',))
## delete from tasks
l = conn.execute('delete from tasks where seg_id in (select seg_id from segments where segments.curr_dir like ?)',(currdir+'%',))
## delete from segments_relations
l = conn.execute('delete from segment_relations where child_id in (select seg_id from segments where segments.curr_dir like ?)',(currdir+'%',))
## delete from segments
l = conn.execute('delete from segments where curr_dir like ?',(currdir+'%',))
conn.close()
shutil.rmtree(currdir)
if lst_seg:
self._delseg(lst_seg)
@cherrypy.expose
@write_access
def delseg(self, segid=None):
def del_lst_seg(self, seglist):
""" Delete a pipeline instance.
Delete all segments and products directories of a given pipeline instance.
......@@ -390,21 +446,17 @@ class Web:
segid: string, list of pipe id ';' separated
"""
cherrypy.log.error_log.warning('called ONCE')
if segid is not None:
seglist = segid.split(";")
for segid in seglist:
if segid:
conn = sqlite3.connect(self.db_file,check_same_thread=True)
with conn:
currdir = conn.execute('select curr_dir from segments where seg_id = ?',(int(segid),)).fetchone()[0]
l = conn.execute('delete from tasks where seg_id in (select seg_id from segments where segments.curr_dir like ?)',(currdir+'%',))
conn.close()
try:
shutil.rmtree(currdir)
except:
pass
seglist = seglist.split(";")
## build list including dependencies
final_list = []
for segid in seglist:
if segid:
final_list= final_list+self._get_children(segid)
final_list.sort()
## empty the list
self._delseg(final_list)
raise cherrypy.HTTPRedirect('/'+self.name+'/',303)
@cherrypy.expose
......
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