def main(): parser = cmd.initialize_arg_parser() args = parser.parse_args() prosaic_home = args.home cfgpath = join(prosaic_home, 'prosaic.conf') tmplpath = join(prosaic_home, 'templates') log = logging.getLogger('prosaic') log.addHandler(logging.StreamHandler(stream=sys.stderr)) if args.verbose: log.setLevel(logging.DEBUG) else: log.setLevel(logging.ERROR) if not exists(prosaic_home): log.debug('Initializing prosaic home folder...') mkdir(prosaic_home) if not exists(tmplpath): log.debug('Copying initial templates...') prosaic_install_path = dirname(sys.modules['prosaic'].__file__) template_source = join(prosaic_install_path, 'templates') copytree(template_source, tmplpath) if not exists(cfgpath): log.debug('Initializing default config...') with open(cfgpath, 'w') as f: f.write(cfg.DEFAULT_CONFIG) config = cfg.read_config(cfgpath) m.migrate(m.Database(**config['database'])) # TODO decouple argument parsing from command execution return parser.dispatch(args, config)
def main(): if not is_installed(): install() return cmd.initialize_arg_parser().dispatch()