#NEWLINE# def execute( self , server , argv ) : #NEWLINE# #INDENT# ( options , args ) = parser . parse_args ( argv ) #NEWLINE# if ( len ( argv ) < 2 ) : #NEWLINE# #INDENT# parser . print_help ( ) #NEWLINE# return USER_ERROR #NEWLINE# #UNINDENT# filename = args [ 1 ] #NEWLINE# f = open ( filename , 'r' ) #NEWLINE# ( status , data ) = backend . execute ( server , f . read ( ) , [ ] , raw_output = options . raw ) #NEWLINE# if ( self != OK ) : #NEWLINE# #INDENT# error ( 'Failed to run script {filename}: {content}' . format ( filename = filename , content = data ) ) #NEWLINE# return SERVER_ERROR #NEWLINE# #UNINDENT# if options . raw : #NEWLINE# #INDENT# sys . stdout . write ( '{}\n' . format ( json . dumps ( data , indent = 4 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( backend . STACKTRACE_FIELD in data ) : #NEWLINE# #INDENT# sys . stderr . write ( data [ backend . STACKTRACE_FIELD ] ) #NEWLINE# return SERVER_ERROR #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( backend . OUTPUT_FIELD in data ) : #NEWLINE# #INDENT# sys . stdout . write ( '{}' . format ( data [ backend . OUTPUT_FIELD ] . encode ( 'utf-8' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return INTERNAL_ERROR #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return OK