[IMP]Odoo database scripts : now require action and add restore from -d only
This commit is contained in:
parent
a1f0529a25
commit
f5895631bd
@ -32,17 +32,17 @@ def restore(odoo, args):
|
|||||||
else:
|
else:
|
||||||
connection = odoo
|
connection = odoo
|
||||||
password = args.password
|
password = args.password
|
||||||
connection.db.restore(password, args.database_target, dump_file,
|
connection.db.restore(password, args.database_target or args.database,
|
||||||
args.restore_copy)
|
dump_file, args.restore_copy)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Main function with argument parsing """
|
""" Main function with argument parsing """
|
||||||
parser = argparse.ArgumentParser(description='Odoo database creation '
|
parser = argparse.ArgumentParser(description='Odoo database creation '
|
||||||
'according to their names')
|
'according to their names')
|
||||||
parser = common.parser(parser)
|
parser = common.parser(parser)
|
||||||
parser.add_argument('-a', '--action', type=str, default='create',
|
parser.add_argument('-a', '--action', type=str, required=True,
|
||||||
help='action for the database,' +
|
help=('action for the database : create, drop, '
|
||||||
'default to create (others are drop, duplicate, dump)')
|
'duplicate, dump or restore'))
|
||||||
parser.add_argument('-d', '--database', type=str, required=True,
|
parser.add_argument('-d', '--database', type=str, required=True,
|
||||||
help='the targetted database')
|
help='the targetted database')
|
||||||
parser.add_argument('-pw', '--password', type=str, required=True,
|
parser.add_argument('-pw', '--password', type=str, required=True,
|
||||||
@ -78,12 +78,15 @@ def main():
|
|||||||
|
|
||||||
# Databases actions
|
# Databases actions
|
||||||
dblist = odoo.db.list()
|
dblist = odoo.db.list()
|
||||||
if args.action == 'create':
|
if args.action == 'create' or args.action == 'restore':
|
||||||
if args.database in dblist:
|
if args.database in dblist:
|
||||||
print 'database already exists'
|
print 'database already exists'
|
||||||
else:
|
else:
|
||||||
|
if args.action == 'create':
|
||||||
odoo.db.create(args.password, args.database, str2bool(args.demo),
|
odoo.db.create(args.password, args.database, str2bool(args.demo),
|
||||||
args.lang, args.database_password)
|
args.lang, args.database_password)
|
||||||
|
elif args.action == 'restore':
|
||||||
|
restore(odoo, args)
|
||||||
else:
|
else:
|
||||||
if args.database not in dblist:
|
if args.database not in dblist:
|
||||||
print 'database not found'
|
print 'database not found'
|
||||||
@ -98,8 +101,6 @@ def main():
|
|||||||
odoo.db.duplicate(args.password, args.database, name)
|
odoo.db.duplicate(args.password, args.database, name)
|
||||||
elif args.action == 'dump':
|
elif args.action == 'dump':
|
||||||
dump(odoo, args)
|
dump(odoo, args)
|
||||||
elif args.action == 'restore':
|
|
||||||
restore(odoo, args)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user