<s> import logging <EOL> import os <EOL> import sys <EOL> from cliff . app import App <EOL> from cliff . commandmanager import CommandManager <EOL> import pkg_resources <EOL> from sqlalchemy . orm import sessionmaker <EOL> from aeromancer . db import connect , migrations <EOL> class Aeromancer ( App ) : <EOL> log = logging . getLogger ( __name__ ) <EOL> def __init__ ( self ) : <EOL> dist = pkg_resources . get_distribution ( '<STR_LIT>' ) <EOL> super ( Aeromancer , self ) . __init__ ( <EOL> description = '<STR_LIT>' , <EOL> version = dist . version , <EOL> command_manager = CommandManager ( '<STR_LIT>' ) , <EOL> ) <EOL> def build_option_parser ( self , description , version , <EOL> argparse_kwargs = None ) : <EOL> parser = super ( Aeromancer , self ) . build_option_parser ( <EOL> description , <EOL> version , <EOL> argparse_kwargs , <EOL> ) <EOL> default_repo_root = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = os . path . expanduser ( default_repo_root ) , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ) <EOL> return parser <EOL> def configure_logging ( self ) : <EOL> super ( Aeromancer , self ) . configure_logging ( ) <EOL> if self . options . verbose_level < <NUM_LIT:2> : <EOL> alembic_logger = logging . getLogger ( '<STR_LIT>' ) <EOL> alembic_logger . setLevel ( logging . WARN ) <EOL> return <EOL> def initialize_app ( self , argv ) : <EOL> self . app_dir = os . path . expanduser ( '<STR_LIT>' ) <EOL> if not os . path . exists ( self . app_dir ) : <EOL> os . mkdir ( self . app_dir ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> migrations . run_migrations ( ) <EOL> self . engine = connect . connect ( ) <EOL> self . _session_maker = sessionmaker ( bind = self . engine ) <EOL> def get_db_session ( self ) : <EOL> return self . _session_maker ( ) <EOL> def main ( argv = sys . argv [ <NUM_LIT:1> : ] ) : <EOL> myapp = Aeromancer ( ) <EOL> return myapp . run ( argv ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( main ( sys . argv [ <NUM_LIT:1> : ] ) ) </s>
