예제 #1
0
def compile():
    print 'Compiling ' + globals.getsrc()
    lang = settings.langexts[globals.getext()]
    print 'Language detected: ' + lang
    if not helper.copy(os.path.join(globals.working, globals.getsrc()),
                       globals.sandboxdir):
        print 'Source file not found in working directory'
        return False
    compcommand = settings.compcommands[lang]
    if compcommand is None:
        print 'No compilation necessary'
        return True
    else:
        compcommand = pattern.convert(compcommand)
        print 'Compilation command: ' + compcommand
        compresult = helper.runproc(compcommand,
                                    globals.sandboxdir,
                                    timelim=settings.compilelimit)
        if compresult[0] is None:  # Time limit exceeded
            print 'Compile time limit exceeded ({:.2f} seconds)'.format(
                settings.compilelimit)
            return False
        message = compresult[3].strip()
        if compresult[0] != 0:  # Runtime error
            helper.printdesc(message, 'Compile errors', settings.smalldivider,
                             False)
            return False
        print 'Successful compile ({:.2f} seconds)'.format(compresult[1])
        if len(message) > 0:  # Check for warnings
            helper.printdesc(message, 'Compile warnings',
                             settings.smalldivider, False)
        return True
예제 #2
0
파일: compile.py 프로젝트: ertemplin/pcu
def compile ():
    print 'Compiling ' + globals.getsrc()
    lang = settings.langexts[globals.getext()]
    print 'Language detected: ' + lang
    if not helper.copy(os.path.join(globals.working, globals.getsrc()), globals.sandboxdir):
        print 'Source file not found in working directory'
        return False
    compcommand = settings.compcommands[lang]
    if compcommand is None:
        print 'No compilation necessary'
        return True
    else:
        compcommand = pattern.convert(compcommand)
        print 'Compilation command: ' + compcommand
        compresult = helper.runproc(compcommand, globals.sandboxdir, timelim=settings.compilelimit)
        if compresult[0] is None: # Time limit exceeded
            print 'Compile time limit exceeded ({:.2f} seconds)'.format(settings.compilelimit)
            return False
        message = compresult[3].strip()
        if compresult[0] != 0: # Runtime error
            helper.printdesc(message, 'Compile errors', settings.smalldivider, False)
            return False
        print 'Successful compile ({:.2f} seconds)'.format(compresult[1])
        if len(message) > 0: # Check for warnings
            helper.printdesc(message, 'Compile warnings', settings.smalldivider, False)
        return True
예제 #3
0
파일: make.py 프로젝트: ertemplin/pcu
def make ():
    print 'Creating {} source file for problem {}'.format(settings.langexts[globals.getext()], globals.getprob())
    template = helper.read(os.path.join(globals.templatedir, globals.getmode() + '.' + globals.getext()))
    if template is None:
        print '{}.{} template file not found (add it to templates folder)'.format(globals.getmode(), globals.getext())
        return False
    helper.write(os.path.join(globals.working, globals.getsrc()), pattern.convert(template))
    print 'Source file created: ' + globals.getsrc()
    return True
예제 #4
0
파일: make.py 프로젝트: jtk-purdue/pcu
def make():
    print 'Creating {} source file for problem {}'.format(
        settings.langexts[globals.getext()], globals.getprob())
    template = helper.read(
        os.path.join(globals.templatedir,
                     globals.getmode() + '.' + globals.getext()))
    if template is None:
        print '{}.{} template file not found (add it to templates folder)'.format(
            globals.getmode(), globals.getext())
        return False
    helper.write(os.path.join(globals.working, globals.getsrc()),
                 pattern.convert(template))
    print 'Source file created: ' + globals.getsrc()
    log.addmsg('Creating {} source file for problem {}'.format(
        settings.langexts[globals.getext()], globals.getprob()))
    return True
예제 #5
0
파일: pattern.py 프로젝트: jma127/pcu
import re

import globals
import settings

# Formatting Rules

rules = [
    lambda str: re.sub("\$INFILE", settings.inputfile, str),
    lambda str: re.sub("\$OUTFILE", settings.outputfile, str),
    lambda str: re.sub("\$SRCFILE", globals.getsrc(), str),
    lambda str: re.sub("\$PROB", globals.getprob(), str),
    lambda str: re.sub("\$EXT", globals.getext(), str),
    lambda str: re.sub("\$USER", settings.username, str),
]

# String Formatter


def convert(str):
    for rule in rules:
        str = rule(str)
    return str
예제 #6
0
import re

import globals
import settings

# Formatting Rules

rules = [
    lambda str: re.sub('\$INFILE', settings.inputfile, str),
    lambda str: re.sub('\$OUTFILE', settings.outputfile, str),
    lambda str: re.sub('\$SRCFILE', globals.getsrc(), str),
    lambda str: re.sub('\$PROB', globals.getprob(), str),
    lambda str: re.sub('\$EXT', globals.getext(), str),
    lambda str: re.sub('\$USER', settings.username, str)
]

# String Formatter


def convert(str):
    for rule in rules:
        str = rule(str)
    return str