Example #1
0
def get_evaluation_result(contest_id, submission_id, timeout=30):
    browser = mechanize.Browser()
    browser.set_handle_robots(False)
    base_url = "http://localhost:8889/"

    WAITING_STATUSES = re.compile(r"Compiling\.\.\.|Evaluating\.\.\.|Evaluated")
    COMPLETED_STATUS = re.compile(r"Compilation failed|Evaluated \(")

    num_tries = timeout
    while num_tries > 0:
        num_tries -= 1

        sr = AWSSubmissionViewRequest(browser, submission_id, base_url=base_url)
        sr.prepare()
        sr.execute()

        result = sr.get_submission_info()
        status = result["status"]

        if COMPLETED_STATUS.search(status):
            return result

        if WAITING_STATUSES.search(status):
            time.sleep(1)
            continue

        raise FrameworkException("Unknown submission status: %s" % status)

    raise FrameworkException("Waited too long for result.")
Example #2
0
def get_evaluation_result(contest_id, submission_id, timeout=60):
    global aws_browser
    if aws_browser is None:
        aws_browser = mechanize.Browser()
        aws_browser.set_handle_robots(False)
    base_url = 'http://localhost:8889/'

    WAITING_STATUSES = re.compile(
        r'Compiling\.\.\.|Evaluating\.\.\.|Scoring\.\.\.|Evaluated')
    COMPLETED_STATUS = re.compile(
        r'Compilation failed|Evaluated \(|Scored \(')

    sleep_interval = 0.1
    while timeout > 0:
        timeout -= sleep_interval

        sr = AWSSubmissionViewRequest(aws_browser,
                                      submission_id,
                                      base_url=base_url)
        sr.execute()

        result = sr.get_submission_info()
        status = result['status']

        if COMPLETED_STATUS.search(status):
            return result

        if WAITING_STATUSES.search(status):
            time.sleep(sleep_interval)
            continue

        raise FrameworkException("Unknown submission status: %s" % status)

    raise FrameworkException("Waited too long for result.")
Example #3
0
def get_evaluation_result(contest_id, submission_id, timeout=60):
    WAITING_STATUSES = re.compile(
        r'Compiling\.\.\.|Evaluating\.\.\.|Scoring\.\.\.|Evaluated')
    COMPLETED_STATUS = re.compile(
        r'Compilation failed|Evaluated \(|Scored \(')

    browser = get_aws_browser()
    sleep_interval = 0.1
    while timeout > 0:
        timeout -= sleep_interval

        sr = AWSSubmissionViewRequest(browser,
                                      submission_id,
                                      base_url=AWS_BASE_URL)
        sr.execute()

        result = sr.get_submission_info()
        status = result['status']

        if COMPLETED_STATUS.search(status):
            return result

        if WAITING_STATUSES.search(status):
            time.sleep(sleep_interval)
            continue

        raise FrameworkException("Unknown submission status: %s" % status)

    raise FrameworkException("Waited too long for submission result.")
Example #4
0
def get_evaluation_result(contest_id, submission_id, timeout=60):
    WAITING_STATUSES = re.compile(
        r'Compiling\.\.\.|Evaluating\.\.\.|Scoring\.\.\.|Evaluated')
    COMPLETED_STATUS = re.compile(r'Compilation failed|Evaluated \(|Scored \(')

    browser = get_aws_browser()
    sleep_interval = 0.1
    while timeout > 0:
        timeout -= sleep_interval

        sr = AWSSubmissionViewRequest(browser,
                                      submission_id,
                                      base_url=AWS_BASE_URL)
        sr.execute()

        result = sr.get_submission_info()
        status = result['status']

        if COMPLETED_STATUS.search(status):
            return result

        if WAITING_STATUSES.search(status):
            time.sleep(sleep_interval)
            continue

        raise FrameworkException("Unknown submission status: %s" % status)

    raise FrameworkException("Waited too long for result.")
Example #5
0
def get_evaluation_result(contest_id, submission_id, timeout=30):
    browser = mechanize.Browser()
    browser.set_handle_robots(False)
    base_url = 'http://localhost:8889/'

    WAITING_STATUSES = re.compile(
        r'Compiling\.\.\.|Evaluating\.\.\.|Evaluated')
    COMPLETED_STATUS = re.compile(
        r'Compilation failed|Evaluated \(')

    num_tries = timeout
    while num_tries > 0:
        num_tries -= 1

        sr = AWSSubmissionViewRequest(browser, submission_id,
                                      base_url=base_url)
        sr.prepare()
        sr.execute()

        result = sr.get_submission_info()
        status = result['status']

        if COMPLETED_STATUS.search(status):
            return result

        if WAITING_STATUSES.search(status):
            time.sleep(1)
            continue

        raise FrameworkException("Unknown submission status: %s" % status)

    raise FrameworkException("Waited too long for result.")
Example #6
0
def get_evaluation_result(contest_id, submission_id, timeout=60):
    global aws_browser
    if aws_browser is None:
        aws_browser = mechanize.Browser()
        aws_browser.set_handle_robots(False)
    base_url = 'http://localhost:8889/'

    WAITING_STATUSES = re.compile(
        r'Compiling\.\.\.|Evaluating\.\.\.|Scoring\.\.\.|Evaluated')
    COMPLETED_STATUS = re.compile(r'Compilation failed|Evaluated \(|Scored \(')

    sleep_interval = 0.1
    while timeout > 0:
        timeout -= sleep_interval

        sr = AWSSubmissionViewRequest(aws_browser,
                                      submission_id,
                                      base_url=base_url)
        sr.execute()

        result = sr.get_submission_info()
        status = result['status']

        if COMPLETED_STATUS.search(status):
            return result

        if WAITING_STATUSES.search(status):
            time.sleep(sleep_interval)
            continue

        raise FrameworkException("Unknown submission status: %s" % status)

    raise FrameworkException("Waited too long for result.")
Example #7
0
    def get_evaluation_result(self, contest_id, submission_id, timeout=60):
        browser = self.get_aws_browser()
        sleep_interval = 0.1
        while timeout > 0:
            timeout -= sleep_interval

            sr = AWSSubmissionViewRequest(browser,
                                          submission_id,
                                          base_url=self.AWS_BASE_URL)
            sr.execute()

            result = sr.get_submission_info()
            status = result['status']

            if self.COMPLETED_STATUSES.search(status):
                return result

            if self.WAITING_STATUSES.search(status):
                time.sleep(sleep_interval)
                continue

            raise TestException("Unknown submission status: %s" % status)

        raise TestException("Waited too long for submission result.")