Changeset 993 for trunk/common


Ignore:
Timestamp:
01/22/09 01:32:19 (3 years ago)
Author:
strat.cristian@…
Message:

Experimental Python Support

This is highly experimental, potentially unsafe. I only enabled it for admins until it's stable.

  • Bash script to compile and link static binaries from Python scripts.
  • Additional unit tests for jrun. (Added several Python test cases.)
  • UI changes for admins only.
Location:
trunk/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/job.php

    r991 r993  
    1010//      round_id: Round to submit for. Optional, if missing the job is sent 
    1111//              to all parent rounds. 
    12 //      compiler_id: c, cpp or fpc. 
     12//      compiler_id: c, cpp, fpc, or py. 
    1313//      solution: A string with the file to submit. 
    1414// 
     
    3838 
    3939    // Validate compiler id 
    40     $valid_compilers = array('c', 'cpp', 'fpc'); 
     40    $valid_compilers = array('c', 'cpp', 'fpc', 'py'); 
    4141    if (!array_key_exists('compiler_id', $args)) { 
    4242        $errors['compiler_id'] = "Lipseste compilatorul."; 
    4343    } else if (array_search($args['compiler_id'], $valid_compilers) === false) { 
    4444        $errors['compiler_id'] = "Compilator invalid."; 
     45    } 
     46    // HACK: For the moment, only admin`s are allowed to submit Python jobs. 
     47    // TODO: Remove this once Python support is stable. 
     48    if ('py' == $args['compiler_id'] && !user_is_admin($user)) { 
     49        $errors['compiler_id'] = 'Deocamdata, numai administratorii pot ' 
     50                .'trimite surse Python.'; 
    4551    } 
    4652 
     
    5662 
    5763    // Check task submit security 
    58     if (!security_query($user, 'task-submit', $task)) { 
     64    if ($task && !security_query($user, 'task-submit', $task)) { 
    5965        $errors[] = "Nu ai voie sa trimiti la acest task."; 
    6066    } 
    61     if ($round != null && !security_query($round, 'task-submit', $round)) { 
     67    if ($round && !security_query($round, 'task-submit', $round)) { 
    6268        $errors[] = "Nu poti sa trimiti la aceasta runda."; 
    6369    } 
  • trunk/common/user.php

    r852 r993  
    107107} 
    108108 
     109function user_is_admin($user) { 
     110    if (!$user) { 
     111        return false; 
     112    } 
     113    log_assert_valid(user_validate($user)); 
     114    return $user['security_level'] === 'admin'; 
     115} 
     116 
    109117?> 
Note: See TracChangeset for help on using the changeset viewer.