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