#NEWLINE# def run( self , args = None ) : #NEWLINE# #INDENT# def adjust_logging( arg ) : #NEWLINE# #INDENT# 'tune the logging before executing commands' #NEWLINE# self . tune_arg_namespace ( arg ) #NEWLINE# if ( arg . time_log and os . path . exists ( arg . time_log ) ) : #NEWLINE# #INDENT# self . task_times . load ( arg . time_log ) #NEWLINE# #UNINDENT# if arg . debug : #NEWLINE# #INDENT# logging . getLogger ( ) . setLevel ( logging . DEBUG ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# paramiko_logger = logging . getLogger ( 'paramiko.transport' ) #NEWLINE# paramiko_logger . setLevel ( logging . CRITICAL ) #NEWLINE# boto_logger = logging . getLogger ( 'boto' ) #NEWLINE# boto_logger . setLevel ( logging . CRITICAL ) #NEWLINE# #UNINDENT# #UNINDENT# args = ( args or sys . argv [ 1 : ] ) #NEWLINE# namespace = argparse . Namespace ( ) #NEWLINE# try : #NEWLINE# #INDENT# extra_loc = args . index ( '--' ) #NEWLINE# namespace . extras = args [ ( extra_loc + 1 ) : ] #NEWLINE# args = args [ : extra_loc ] #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# namespace . extras = [ ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# start = time . time ( ) #NEWLINE# exit_code = self . parser . dispatch ( argv = args , pre_call = adjust_logging , raw_output = True , namespace = namespace ) #NEWLINE# stop = time . time ( ) #NEWLINE# if namespace . time_op : #NEWLINE# #INDENT# op_name = ( namespace . time_op if ( namespace . time_op != '-' ) else ' ' . join ( args ) ) #NEWLINE# self . task_times . add_task ( 'C' , op_name , self , stop , args = args ) #NEWLINE# #UNINDENT# #UNINDENT# except KeyboardInterrupt : #NEWLINE# #INDENT# self . log . error ( '*** terminated by keyboard ***' ) #NEWLINE# if namespace . pass_thru_exceptions : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# return ( - 1 ) #NEWLINE# #UNINDENT# except errors . Error as error : #NEWLINE# #INDENT# self . log . error ( '%s: %s' , error . __class__ . __name__ , error ) #NEWLINE# if namespace . pass_thru_exceptions : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# return ( - 1 ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if namespace . time_log : #NEWLINE# #INDENT# self . task_times . save ( namespace . time_log ) #NEWLINE# #UNINDENT# rcontrol_all . manager . cleanup ( ) #NEWLINE# #UNINDENT# return exit_code