Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
pipelet
Pipelet
Commits
1b6d56b9
Commit
1b6d56b9
authored
Sep 12, 2013
by
Maude Le Jeune
Browse files
Merge branch 'master' of gitorious.org:pipelet/pipelet
parents
ded7b844
0ee7c10a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
33 deletions
+35
-33
pipelet/db_utils.py
pipelet/db_utils.py
+35
-33
No files found.
pipelet/db_utils.py
View file @
1b6d56b9
...
...
@@ -52,41 +52,43 @@ def deltask(db_file, lst_task, report_only=False):
import
shutil
# remove everyboby
conn
=
sqlite3
.
connect
(
db_file
,
check_same_thread
=
True
)
taskid
=
lst_task
[
0
]
with
conn
:
print
"removing task %s from db"
%
taskid
str_input
=
conn
.
execute
(
'select str_input from tasks where task_id = ?'
,(
int
(
taskid
),)).
fetchone
()[
0
]
while
lst_task
:
taskid
=
lst_task
[
0
]
with
conn
:
print
"removing task %s from db"
%
taskid
str_input
=
conn
.
execute
(
'select str_input from tasks where task_id = ?'
,(
int
(
taskid
),)).
fetchone
()[
0
]
lst_task
.
remove
(
taskid
)
# delete from tasks_relations
if
not
report_only
:
l
=
conn
.
execute
(
'delete from task_relations where child_id = ? '
,(
int
(
taskid
),))
# mark child tasks for deletion
children
=
conn
.
execute
(
'select child_id from task_relations where father_id = ? '
,(
int
(
taskid
),)).
fetchall
()
# delete from tasks
if
not
report_only
:
l
=
conn
.
execute
(
'delete from tasks where task_id = ?'
,(
int
(
taskid
),))
print
'Task %s removed from db'
%
taskid
else
:
print
'Task %s would be removed from db'
%
taskid
lst_task
.
remove
(
taskid
)
# delete from tasks_relations
if
not
report_only
:
l
=
conn
.
execute
(
'delete from task_relations where child_id = ? '
,(
int
(
taskid
),))
# mark child tasks for deletion
children
=
conn
.
execute
(
'select child_id from task_relations where father_id = ? '
,(
int
(
taskid
),)).
fetchall
()
# delete from tasks
if
not
report_only
:
l
=
conn
.
execute
(
'delete from tasks where task_id = ?'
,(
int
(
taskid
),))
print
'Task %s removed from db'
%
taskid
else
:
print
'Task %s would be removed from db'
%
taskid
#conn.close()
try
:
print
"Removing directory %s"
%
str_input
if
not
report_only
:
shutil
.
rmtree
(
str_input
)
print
"%s removed"
%
str_input
else
:
print
"%s would be removed"
%
str_input
except
OSError
:
print
"Failed to remove %s"
%
str_input
if
children
:
print
"Adding children of %s"
%
taskid
lst_task
+=
[
c
[
0
]
for
c
in
children
]
lst_task
=
list
(
set
(
lst_task
))
lst_task
.
sort
()
conn
.
close
()
try
:
print
"Removing directory %s"
%
str_input
if
not
report_only
:
shutil
.
rmtree
(
str_input
)
print
"%s removed"
%
str_input
else
:
print
"%s would be removed"
%
str_input
except
OSError
:
print
"Failed to remove %s"
%
str_input
if
children
:
print
"Adding children of %s"
%
taskid
lst_task
+=
[
c
[
0
]
for
c
in
children
]
lst_task
=
list
(
set
(
lst_task
))
lst_task
.
sort
()
if
lst_task
:
deltask
(
db_file
,
lst_task
,
report_only
=
report_only
)
#if lst_task:
# deltask(db_file, lst_task, report_only=report_only)
def
get_lst_tag
(
db_file
):
""" Return the list of existing tags
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment