def go(cmd_name, cmd_dir, base_dir, description, standalone, directory, verbose, libpath, *args): """ Run tool after tweaking the Python library path to find voltcli libraries. Optionally change to a relative or absolute directory provided by the caller. The base directory is this file's parent directory and serves as the default working directory. :param cmd_name: :param cmd_dir: :param base_dir: :param description: :param standalone: :param directory: :param verbose: :param libpath: :param args: """ G.verbose = verbose # Append libpath to module loading path. if libpath: sys.path.extend(libpath.split(':')) start_logging() try: version = None try: # noinspection PyUnresolvedReferences version = open(os.path.join(base_dir, 'version.txt')).read().strip() except (IOError, OSError), e: abort('Unable to read version.txt.', e) if os.path.isdir('/opt/lib/voltdb/python'): sys.path.insert(0, '/opt/lib/voltdb/python') if os.path.isdir('/usr/share/lib/voltdb/python'): sys.path.insert(0, '/usr/share/lib/voltdb/python') if os.path.isdir('/usr/lib/voltdb/python'): sys.path.insert(0, '/usr/lib/voltdb/python') # Library location relative to script. sys.path.insert(0, os.path.join(base_dir, 'lib', 'python')) if directory: os.chdir(directory) runner = None try: # noinspection PyUnresolvedReferences from voltcli import runner except ImportError: abort('Unable to import voltcli.runner using the following path:', sys.path) runner.main(cmd_name, cmd_dir, version, description, standalone=to_boolean(standalone), *args)
def go(cmd_name, cmd_dir, base_dir, description, standalone, directory, verbose, libpath, *args): """ Run tool after tweaking the Python library path to find voltcli libraries. Optionally change to a relative or absolute directory provided by the caller. The base directory is this file's parent directory and serves as the default working directory. :param cmd_name: :param cmd_dir: :param base_dir: :param description: :param standalone: :param directory: :param verbose: :param libpath: :param args: """ G.verbose = verbose # Append libpath to module loading path. if libpath: sys.path.extend(libpath.split(':')) start_logging() try: version = get_version(base_dir) if os.path.isdir('/opt/lib/voltdb/python'): sys.path.insert(0, '/opt/lib/voltdb/python') if os.path.isdir('/usr/share/lib/voltdb/python'): sys.path.insert(0, '/usr/share/lib/voltdb/python') if os.path.isdir('/usr/lib/voltdb/python'): sys.path.insert(0, '/usr/lib/voltdb/python') # Library location relative to script. sys.path.insert(0, os.path.join(base_dir, 'lib', 'python')) if directory: os.chdir(directory) runner = None try: # noinspection PyUnresolvedReferences from voltcli import runner except ImportError: abort('Unable to import voltcli.runner using the following path:', sys.path) runner.main(cmd_name, cmd_dir, version, description, standalone=to_boolean(standalone), *args) finally: stop_logging()