1 ##############################################################################
2 # Copyright (c) 2016 ZTE Corporation
3 # feng.xiaowei@zte.com.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
14 def get_abspath(path):
15 assert os.path.isdir(path), 'Path %s can\'t be found.' % path
16 return os.path.abspath(path)
20 url = urlparse.urlparse(url)
21 assert url.scheme == 'mongodb', 'URL must be a MongoDB URL'
23 return url.username, url.password, url.hostname, url.port
26 def execute(cmd, args):
27 (username, password, hostname, port) = url_parse(args.url)
28 cmd.extend(['--host', '%s' % hostname, '--port', '%s' % port])
31 cmd.extend(['--db', '%s' % db])
32 if username is not None:
33 cmd.extend(['-u', '%s' % username, '-p', '%s' % password])
34 print('execute: %s' % cmd)
35 execute_output = subprocess.check_output(cmd)
39 def main(method, parser):
40 args = parser.parse_args()
43 except AssertionError, msg: