summaryrefslogtreecommitdiff
path: root/kpov_judge/util.py
blob: 6d9e085ec21ddc7286a92169570c86121cd57fcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import yaml

def write_default_config(disk, global_params):
    home = '/home/test'
    params_file = os.path.join(home, '.kpov_params.yaml')
    default_params = {}
    for k in [
            'task_name',
            'username',
            'task_url']:
        if k in global_params:
            default_params[k] = global_params[k]
    disk.write(params_file, yaml.dump(default_params))
    disk.chown(1001, 1001, params_file)

    mydir = os.path.dirname(os.path.abspath(__file__))
    # write testing script and helper
    for f in ['test_task.py', 'kpov_util.py']:
        src = os.path.join(mydir, f)
        dst = os.path.join('/home/test', f)
        disk.write(dst, open(src).read())
        disk.chmod(0o755, dst)
    disk.copy_in(os.path.join(mydir, 'random_data'), '/home/test')