#NEWLINE# def run( args ) : #NEWLINE# #INDENT# 'Starts the execution after args have been parsed and logging has been setup.\n    ' #NEWLINE# LOG . debug ( 'CLI arguments are:' ) #NEWLINE# utils . log_object ( args , logger = LOG , level = logging . DEBUG , item_max_len = 128 ) #NEWLINE# saved_args = dict ( args ) #NEWLINE# action = args . pop ( 'action' , '' ) . strip ( ) . lower ( ) #NEWLINE# if re . match ( '^moo[o]*$' , action ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# runner_cls = actions . class_for ( action ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# raise excp . OptionException ( str ( ex ) ) #NEWLINE# #UNINDENT# if runner_cls . needs_sudo : #NEWLINE# #INDENT# ensure_perms ( ) #NEWLINE# #UNINDENT# persona_fn = args . pop ( 'persona_fn' ) #NEWLINE# if ( not persona_fn ) : #NEWLINE# #INDENT# raise excp . OptionException ( 'No persona file name specified!' ) #NEWLINE# #UNINDENT# if ( not sh . isfile ( persona_fn ) ) : #NEWLINE# #INDENT# raise excp . OptionException ( ( 'Invalid persona file %r specified!' % persona_fn ) ) #NEWLINE# #UNINDENT# origins_fn = args . pop ( 'origins_fn' ) #NEWLINE# if ( not origins_fn ) : #NEWLINE# #INDENT# raise excp . OptionException ( 'No origin file name specified!' ) #NEWLINE# #UNINDENT# if ( not sh . isfile ( origins_fn ) ) : #NEWLINE# #INDENT# raise excp . OptionException ( ( 'Invalid origin file %r specified!' % origins_fn ) ) #NEWLINE# #UNINDENT# args [ 'origins_fn' ] = sh . abspth ( origins_fn ) #NEWLINE# root_dir = sh . abspth ( args . pop ( 'dir' ) ) #NEWLINE# ( repeat_string , line_max_len ) = utils . welcome ( ) #NEWLINE# print ( pprint . center_text ( 'Action Runner' , repeat_string , line_max_len ) ) #NEWLINE# if ( not sh . isdir ( root_dir ) ) : #NEWLINE# #INDENT# LOG . info ( 'Creating anvil root directory at path: %s' , root_dir ) #NEWLINE# sh . mkdir ( root_dir ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# for d in ANVIL_DIRS : #NEWLINE# #INDENT# if sh . isdir ( d ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# LOG . info ( 'Creating anvil auxiliary directory at path: %s' , d ) #NEWLINE# sh . mkdir ( d ) #NEWLINE# #UNINDENT# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# LOG . warn ( 'Failed ensuring auxiliary directories due to %s' , e ) #NEWLINE# #UNINDENT# origins = _origins . load ( args [ 'origins_fn' ] , patch_file = args . get ( 'origins_patch' ) ) #NEWLINE# possible_distros = distro . load ( settings . DISTRO_DIR , distros_patch = args . get ( 'distros_patch' ) ) #NEWLINE# try : #NEWLINE# #INDENT# persona_obj = persona . load ( persona_fn ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# raise excp . OptionException ( ( 'Error loading persona file: %s due to %s' % ( persona_fn , e ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dist = persona_obj . match ( possible_distros , origins ) #NEWLINE# LOG . info ( 'Persona selected distro: %s from %s possible distros' , colorizer . quote ( dist . name ) , len ( possible_distros ) ) #NEWLINE# #UNINDENT# dist . inject_platform_overrides ( persona_obj . distro_updates , source = persona_fn ) #NEWLINE# dist . inject_platform_overrides ( origins , source = origins_fn ) #NEWLINE# LOG . debug ( 'Distro settings are:' ) #NEWLINE# for line in dist . pformat ( item_max_len = 128 ) . splitlines ( ) : #NEWLINE# #INDENT# LOG . debug ( line ) #NEWLINE# #UNINDENT# runner = runner_cls ( distro = dist , root_dir = root_dir , name = action , cli_opts = args ) #NEWLINE# store_current_settings ( saved_args ) #NEWLINE# LOG . info ( 'Starting action %s on %s for distro: %s' , colorizer . quote ( action ) , colorizer . quote ( utils . iso8601 ( ) ) , colorizer . quote ( dist . name ) ) #NEWLINE# LOG . info ( 'Using persona: %s' , colorizer . quote ( persona_fn ) ) #NEWLINE# LOG . info ( 'Using origins: %s' , colorizer . quote ( origins_fn ) ) #NEWLINE# LOG . info ( 'In root directory: %s' , colorizer . quote ( root_dir ) ) #NEWLINE# start_time = time . time ( ) #NEWLINE# runner . run ( persona_obj ) #NEWLINE# end_time = time . time ( ) #NEWLINE# pretty_time = utils . format_time ( ( end_time - start_time ) ) #NEWLINE# LOG . info ( 'It took %s seconds or %s minutes to complete action %s.' , colorizer . quote ( pretty_time [ 'seconds' ] ) , colorizer . quote ( pretty_time [ 'minutes' ] ) , colorizer . quote ( action ) )