original_docstring: Compiles a submission in the isolate directory.
  
      :param isolate_dir: The location of the isolate sandbox.
      :param code_filename: The name of the code file (with extension).
      :param code_type: The language that the code is written in.
      :return: A tuple with 2 values. The 1st is a boolean representing whether or not the compilation was
          successful. The 2nd is either the compiled filename (main class for Java) if the compilation was
          successful, or an explanation as to why the compilation was not successful.
      
docstring: Compiles a submission in the isolate directory.
docstring_tokens: Compiles a submission in the isolate directory .
code: def compile_source_code(isolate_dir: str, code_filename: str, code_type: str) -> (bool, str):
      """Compiles a submission in the isolate directory.
  
      :param isolate_dir: The location of the isolate sandbox.
      :param code_filename: The name of the code file (with extension).
      :param code_type: The language that the code is written in.
      :return: A tuple with 2 values. The 1st is a boolean representing whether or not the compilation was
          successful. The 2nd is either the compiled filename (main class for Java) if the compilation was
          successful, or an explanation as to why the compilation was not successful.
      """
      compile_args = None
      # Remove extension from the filename to determine compiled filename
      compiled_filename, _ = os.path.splitext(code_filename)
      if code_type == 'java':
          compile_args = ['/usr/lib/jvm/java-14-openjdk-amd64/bin/javac', code_filename]
      elif code_type == 'cpp':
          if code_filename == 'checker.cpp':
              compiled_filename = 'checker'
          else:
              compiled_filename = 'code'
          compile_args = ['/usr/bin/g++', '-B', '/usr/bin', '-std=c++17', '-O2', '-o', compiled_filename, code_filename]
      elif code_type == 'python':
          # Add two lines at the beginning to allow for deep recursion
          if code_filename == 'checker.py':
              compiled_filename = 'checker.new.py'
          else:
              compiled_filename = 'code.new.py'
          fcode_old = open(isolate_dir + '/' + code_filename, 'r')
          fcode_new = open(isolate_dir + '/' + compiled_filename, 'w')
          fcode_new.write('import sys\n')
          fcode_new.write('sys.setrecursionlimit(99999999)\n')
          fcode_new.write(fcode_old.read())
          fcode_old.close()
          fcode_new.close()
          compile_args = ['/bin/python3', '-m', 'pylint', '--errors-only', compiled_filename]
  
      isolate_args = ['misc/isolate', '--run', '--cg', '--processes=50', '--silent',
                      '--time=' + str(COMPILE_TIME_LIMIT), '--wall-time=' + str(COMPILE_TIME_LIMIT),
                      '--cg-mem=' + str(COMPILE_MEMORY_LIMIT * 1024), '--chdir=/box', '--stdout=error.err.txt',
                      '--stderr-to-stdout', '--fsize=' + str(MAX_COMPILE_SIZE * 1024), '--']
      if DEBUG_LOWEST:
          log('$' + ' '.join(isolate_args + compile_args))
  
      # Run isolate
      process = subprocess.run(isolate_args + compile_args)
  
      if process.returncode != 0:
          # Compile error of some kind
          ferror = open(isolate_dir + '/error.err.txt', 'r')
          error = ferror.read(COMPILE_ERROR_OUTPUT + 20)
          # Cleanup error log by replacing placeholder filenames / removing module
          if code_type == 'python':
              error = error.replace('************* Module code.new\n', '')
              error = error.replace('code.new.py', code_filename)
          error = error[:COMPILE_ERROR_OUTPUT]
          # Notify user if output was truncated
          stderr_size = os.path.getsize(ferror.name)
          if stderr_size > COMPILE_ERROR_OUTPUT:
              error += '\n...[output truncated]'
          elif stderr_size == 0:
              error = '[Empty error log... maybe the compiler ran for too long, or ran out of memory?]'
          return False, error
  
      # Compiled successfully
      return True, compiled_filename
code_tokens: def compile_source_code ( isolate_dir : str , code_filename : str , code_type : str ) -> ( bool , str ) : compile_args = None compiled_filename , _ = os . path . splitext ( code_filename ) if code_type == 'java' : compile_args = [ '/usr/lib/jvm/java-14-openjdk-amd64/bin/javac' , code_filename ] elif code_type == 'cpp' : if code_filename == 'checker.cpp' : compiled_filename = 'checker' else : compiled_filename = 'code' compile_args = [ '/usr/bin/g++' , '-B' , '/usr/bin' , '-std=c++17' , '-O2' , '-o' , compiled_filename , code_filename ] elif code_type == 'python' : if code_filename == 'checker.py' : compiled_filename = 'checker.new.py' else : compiled_filename = 'code.new.py' fcode_old = open ( isolate_dir + '/' + code_filename , 'r' ) fcode_new = open ( isolate_dir + '/' + compiled_filename , 'w' ) fcode_new . write ( 'import sys\n' ) fcode_new . write ( 'sys.setrecursionlimit(99999999)\n' ) fcode_new . write ( fcode_old . read ( ) ) fcode_old . close ( ) fcode_new . close ( ) compile_args = [ '/bin/python3' , '-m' , 'pylint' , '--errors-only' , compiled_filename ] isolate_args = [ 'misc/isolate' , '--run' , '--cg' , '--processes=50' , '--silent' , '--time=' + str ( COMPILE_TIME_LIMIT ) , '--wall-time=' + str ( COMPILE_TIME_LIMIT ) , '--cg-mem=' + str ( COMPILE_MEMORY_LIMIT * 1024 ) , '--chdir=/box' , '--stdout=error.err.txt' , '--stderr-to-stdout' , '--fsize=' + str ( MAX_COMPILE_SIZE * 1024 ) , '--' ] if DEBUG_LOWEST : log ( '$' + ' ' . join ( isolate_args + compile_args ) ) process = subprocess . run ( isolate_args + compile_args ) if process . returncode != 0 : ferror = open ( isolate_dir + '/error.err.txt' , 'r' ) error = ferror . read ( COMPILE_ERROR_OUTPUT + 20 ) if code_type == 'python' : error = error . replace ( '************* Module code.new\n' , '' ) error = error . replace ( 'code.new.py' , code_filename ) error = error [ : COMPILE_ERROR_OUTPUT ] stderr_size = os . path . getsize ( ferror . name ) if stderr_size > COMPILE_ERROR_OUTPUT : error += '\n...[output truncated]' elif stderr_size == 0 : error = '[Empty error log... maybe the compiler ran for too long, or ran out of memory?]' return False , error return True , compiled_filename
short_docstring: Compiles a submission in the isolate directory.
short_docstring_tokens: Compiles a submission in the isolate directory .
comment: """Compiles a submission in the isolate directory.
  
      :param isolate_dir: The location of the isolate sandbox.
      :param code_filename: The name of the code file (with extension).
      :param code_type: The language that the code is written in.
      :return: A tuple with 2 values. The 1st is a boolean representing whether or not the compilation was
          successful. The 2nd is either the compiled filename (main class for Java) if the compilation was
          successful, or an explanation as to why the compilation was not successful.
      """$SEP$# Remove extension from the filename to determine compiled filename$SEP$# Add two lines at the beginning to allow for deep recursion$SEP$# Run isolate$SEP$# Compile error of some kind$SEP$# Cleanup error log by replacing placeholder filenames / removing module$SEP$# Notify user if output was truncated$SEP$# Compiled successfully