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

Add a tool to ease the move of pipelines

parent f7252166
......@@ -22,3 +22,10 @@ def old_to_new (old_file, new_file):
conn2.execute('insert into tasks (seg_id, status, input, output, str_prod) values (?, ?, ?, ?, ?)',(seg_id,)+t)
def change_root(sql_file,old_prefix, new_prefix):
""" Update the data root path in the database."""
conn1 = sqlite3.connect(sql_file)
with conn1:
conn1.execute('update segments set curr_dir = replace(curr_dir, ?,?)', (old_prefix, new_prefix))
conn1.execute('update tasks set str_input = replace(str_input, ?,?)', (old_prefix, new_prefix))
......@@ -2,7 +2,7 @@
def main():
import optparse
parser = optparse.OptionParser(usage="\nTo create a new pipeline:\n %prog -c <pipename> [-p <prefix>]\nTo activate acl and setup a new user:\n %prog -a <username> [-l <access_level>] <sql_file>\nTo suppress an existing user:\n %prog -d <username> ")
parser = optparse.OptionParser(usage="\nTo create a new pipeline:\n %prog -c <pipename> [-p <prefix>]\nTo activate acl and setup a new user:\n %prog -a <username> [-l <access_level>] <sql_file>\nTo suppress an existing user:\n %prog -d <username>\nTo change the data root directory : %prod -r old_dir new_dir <sql_file>")
parser.add_option('-c', '--create-pipeline',
help='Create a new pipeline',)
parser.add_option('-p', '--prefix',
......@@ -11,6 +11,8 @@ def main():
help='Setup acl, add a new user',)
parser.add_option('-d', '--del-user',
help='Delete an existing user')
parser.add_option('-r', '--change-prefix',
help='Modify the prefix directory',nargs=2)
parser.add_option('-l', '--access-level',
help='When creating a new user give him this level', default=1, type='int')
......@@ -37,7 +39,9 @@ def main():
elif options.create_pipeline:
from pipelet import utils
utils.create_pipe(options.create_pipeline, prefix=options.prefix)
elif options.change_prefix:
from pipelet import db_utils
db_utils.change_root (args[0], options.change_prefix[0], options.change_prefix[1])
if __name__ == "__main__":
main()
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