<s> import os <EOL> import sys <EOL> from tempfile import mkdtemp <EOL> from cement . core import foundation <EOL> from cement . core import exc as cement_exc <EOL> from cement . utils import fs , misc <EOL> from boss . cli . controllers . base import BossBaseController <EOL> from boss . core import exc as boss_exc <EOL> if sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> : <EOL> from imp import reload <EOL> defaults = misc . init_defaults ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> defaults [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> class BossApp ( foundation . CementApp ) : <EOL> class Meta : <EOL> label = '<STR_LIT>' <EOL> bootstrap = '<STR_LIT>' <EOL> base_controller = BossBaseController <EOL> config_defaults = defaults <EOL> config_files = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def validate_config ( self ) : <EOL> self . config . set ( '<STR_LIT>' , '<STR_LIT>' , <EOL> fs . abspath ( self . config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> if not os . path . exists ( self . config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> os . makedirs ( self . config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> pth = os . path . join ( self . config . get ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> if not os . path . exists ( fs . abspath ( pth ) ) : <EOL> os . makedirs ( fs . abspath ( pth ) ) <EOL> self . config . set ( '<STR_LIT>' , '<STR_LIT>' , pth ) <EOL> pth = os . path . join ( self . config . get ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . config . set ( '<STR_LIT>' , '<STR_LIT>' , pth ) <EOL> class BossTestApp ( BossApp ) : <EOL> def close ( self , * args , ** kw ) : <EOL> try : <EOL> super ( BossTestApp , self ) . close ( * args , ** kw ) <EOL> except SystemExit as e : <EOL> pass <EOL> def main ( argv = None ) : <EOL> if argv is None : <EOL> argv = sys . argv [ <NUM_LIT:1> : ] <EOL> with BossApp ( argv = argv ) as app : <EOL> try : <EOL> app . run ( ) <EOL> except boss_exc . BossTemplateError as e : <EOL> print ( "<STR_LIT>" % e . msg ) <EOL> app . exit_code = <NUM_LIT:1> <EOL> except boss_exc . BossArgumentError as e : <EOL> print ( "<STR_LIT>" % e . msg ) <EOL> app . exit_code = <NUM_LIT:1> <EOL> except cement_exc . CaughtSignal as e : <EOL> print ( e ) <EOL> except cement_exc . FrameworkError as e : <EOL> print ( e ) <EOL> app . exit_code = <NUM_LIT:1> <EOL> test_tmpdir = mkdtemp ( ) <EOL> def get_test_app ( ** kw ) : <EOL> test_defaults = defaults <EOL> test_defaults [ '<STR_LIT>' ] [ '<STR_LIT>' ] = test_tmpdir <EOL> kw [ '<STR_LIT>' ] = kw . get ( '<STR_LIT>' , test_defaults ) <EOL> kw [ '<STR_LIT>' ] = kw . get ( '<STR_LIT>' , [ ] ) <EOL> app = BossTestApp ( ** kw ) <EOL> return app <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
