def build_and_run_file(filename):
    ''' Builds and runs the filename specified
        according to the extension
        PARAM filename: name of file to build and run
    '''
    (directory, name, extension) = get_file_tuple(filename)
    if extension == 'c':
        print(" = = = = = = ", YELLOW, "GCC: Compiling " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.compile()
        if out != 0:
            print('Error while compiling. Code:', out, 'Please retry.')
            return out
        print("")

        out = compiler.run()
        return out

    elif extension == 'cpp':
        print(" = = = = = = ", YELLOW, "GPP: Compiling " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.compile()
        if out != 0:
            print('Error while compiling. Code:', out, 'Please retry.')
            return out
        print("")

        out = compiler.run()
        return out

    elif extension == 'py':
        print(" = = = = = = ", YELLOW, "PYTHON: Executing " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.run()
        return out
    elif extension == 'java':
        command = EXECUTABLE_JAVAC + ' ' + filename
        perform_system_command(command)
        command_run = EXECUTABLE_JAVA + ' ' + name
        test_file = directory + "/" + name + ".input"
        if os.path.exists(test_file):
            command_run += " < " + test_file
        return perform_system_command(command_run)
    else:
        print("Language yet not supported")
        return -1
def build_and_run_file ( filename ) : ( directory , name , extension ) = get_file_tuple ( filename ) if extension == 'c' : print ( " = = = = = = " , YELLOW , "GCC: Compiling " + filename + " file" , RESET , " = = = = = =\n" ) compiler = Compiler ( filename ) out = compiler . compile ( ) if out != 0 : print ( 'Error while compiling. Code:' , out , 'Please retry.' ) return out print ( "" ) out = compiler . run ( ) return out elif extension == 'cpp' : print ( " = = = = = = " , YELLOW , "GPP: Compiling " + filename + " file" , RESET , " = = = = = =\n" ) compiler = Compiler ( filename ) out = compiler . compile ( ) if out != 0 : print ( 'Error while compiling. Code:' , out , 'Please retry.' ) return out print ( "" ) out = compiler . run ( ) return out elif extension == 'py' : print ( " = = = = = = " , YELLOW , "PYTHON: Executing " + filename + " file" , RESET , " = = = = = =\n" ) compiler = Compiler ( filename ) out = compiler . run ( ) return out elif extension == 'java' : command = EXECUTABLE_JAVAC + ' ' + filename perform_system_command ( command ) command_run = EXECUTABLE_JAVA + ' ' + name test_file = directory + "/" + name + ".input" if os . path . exists ( test_file ) : command_run += " < " + test_file return perform_system_command ( command_run ) else : print ( "Language yet not supported" ) return - 1
Builds and runs the filename specified
        according to the extension
        PARAM filename: name of file to build and run