import json import logging import os import sys LOG = logging.getLogger(__name__) def readline_setup(): import atexit import readline readline.parse_and_bind('tab:complete') histfile = os.path.join(os.environ['HOME'], '.pythonhistory') try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) def logging_setup(loglevel=logging.INFO): logging.basicConfig( format='%(asctime)s %(levelname)-5s %(name)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S', stream=sys.stderr, level=loglevel) def interactive_setup(readline=True, loglevel=logging.INFO): logging_setup() if readline: readline_setup() config = sys.argv[1] LOG.info("Loading configuraition file: %s", config) with open(config, 'r') as f: return json.load(f)