Commit d3677879 authored by Betoule Marc's avatar Betoule Marc
Browse files

add a del-tag to pipeutil and fix a bug in deltag

parent 3055d7cf
......@@ -204,10 +204,12 @@ def del_tag (db_file, tag):
"""
conn = sqlite3.connect(db_file,check_same_thread=True)
conn.text_factory=str
print tag
with conn:
l = conn.execute('select seg_id, tag, curr_dir from segments where tag like ?',("%"+tag+"%",)).fetchall()
l = conn.execute('select seg_id, tag, curr_dir from segments where tag == ?',(tag,)).fetchall()
for s in l:
lst_tag = s[1].split(";")
print lst_tag
lst_tag.remove(tag)
str_tag = ";".join(lst_tag)
conn.execute('update segments set tag=? where seg_id=?',(str_tag,s[0]))
......
......@@ -15,6 +15,8 @@ To delete a selection of task per id:
%prog -t <sql_file> [-f] task_id1 [task_id2 ...]
To tag the last computed segment:
%prog --tag-last <sql_file> tag
To remove a tag
%prog --del-tag <sql_file> tag
""")
parser.add_option('-c', '--create-pipeline',
help='Create a new pipeline',)
......@@ -22,6 +24,8 @@ To tag the last computed segment:
help='Delete the given tasks (and their children if any)',)
parser.add_option('--tag-last',
help='tag the last computed segment',)
parser.add_option('--del-tag',
help='remove the tag',)
parser.add_option('-f', '--force', action='store_true', default=False,
help='Actually perform dangerous actions (such as delete-task)',)
parser.add_option('-p', '--prefix',
......@@ -80,6 +84,14 @@ To tag the last computed segment:
print 'tag segment %d as %s'%(seg_id, args[0])
db_utils.add_tag(options.tag_last, "%d"%seg_id, args[0])
#db_utils.deltask(options.delete_task, args, report_only=not options.force)
elif options.del_tag:
if not args:
parser.print_usage()
exit(-1)
from pipelet import db_utils
seg_id = db_utils.del_tag(options.del_tag, args[0])
#print 'tag segment %d as %s'%(seg_id, args[0])
#db_utils.add_tag(options.tag_last, "%d"%seg_id, args[0])
else:
if len(args) < 0:
......
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