StdChal module

Standard challenge module.

class StdChal.IORedirJudge(container_path, build_relpath)[source]

Bases: object

I/O redirect spcial judge.

container_path

Container path.

Type

string

build_relpath

Relative build path.

Type

string

build_path

Build path.

Type

string

build(build_ugid, res_path, callback=None)[source]

Build environment.

Parameters
  • build_ugid ((int, int)) – Build UID/GID.

  • res_path (string) – Resource path.

  • callback (function) – Callback of return_future.

Returns

None

judge(src_path, exe_relpath, argv, envp, check_ugid, test_ugid, test_relpath, test_param, metadata, callback=None)[source]

I/O redirect special judge.

Parameters
  • src_path (string) – Executable source path.

  • exe_relpath (string) – Executable or interpreter path in the sandbox.

  • argv ([string]) – List of arguments.

  • envp ([string]) – List of environment variables.

  • check_ugid (int, int) – Check UID/GID.

  • test_ugid (int, int) – Test UID/GID.

  • test_relpath (string) – Test relative path.

  • test_param (dict) – Test parameters.

  • metadata (dict) – Metadata.

  • callback (function) – Callback of return_future.

Returns

None

class StdChal.StdChal(chal_id, code_path, comp_typ, judge_typ, res_path, test_list, metadata)[source]

Bases: object

Standard challenge.

Static attributes:

last_uniqid (int): Last ID. last_standard_uid (int): Last UID for standard tasks. last_restrict_uid (int): Last UID for restricted tasks. null_fd (int): File descriptor of /dev/null. build_cache (dict): Cache information of builds. build_cache_refcount (dict): Refcount of build caches.

uniqid

Unique ID.

Type

int

code_path

Code path.

Type

string

res_path

Resource path.

Type

string

comp_typ

Type of compile.

Type

string

judge_typ

Type of judge.

Type

string

test_list

Test parameter lists.

Type

[dict]

metadata

Metadata for judge.

Type

dict

chal_id

Challenge ID.

Type

int

chal_path

Challenge path.

Type

string

static build_cache_decref(cache_hash)[source]

Decrement the refcount of the build cache.

Delete the build cache if the refcount = 0.

Parameters

cache_hash (int) – Cache hash.

Returns

None

static build_cache_find(res_path)[source]

Get build cache.

Parameters

res_path (string) – Resource path.

Returns

(cache hash, GID) or None if not found.

Return type

(string, int)

static build_cache_incref(cache_hash)[source]

Increment the refcount of the build cache.

Parameters

cache_hash (int) – Cache hash.

Returns

None

static build_cache_update(res_path, cache_hash, gid)[source]

Update build cache.

Parameters
  • res_path (string) – Resource path.

  • cache_hash (int) – Cache hash.

  • gid (int) – GID.

Returns

None

comp_cxx(callback=None)[source]

GCC, Clang compile.

Parameters

callback (function) – Callback of return_future.

Returns

None

comp_make(callback=None)[source]

Makefile compile.

Parameters

callback (function) – Callback of return_future.

Returns

None

comp_python(callback=None)[source]

Python3.4 compile.

Parameters

callback (function) – Callback of return_future.

Returns

None

static get_restrict_ugid()[source]

Generate restrict UID/GID.

Returns

Restrict UID/GID

Return type

(int, int)

static get_standard_ugid()[source]

Generate standard UID/GID.

Returns

Standard UID/GID

Return type

(int, int)

static init()[source]

Initialize the module.

judge_diff(src_path, exe_path, argv, envp, in_path, ans_path, timelimit, memlimit, callback=None)[source]

Diff judge.

Parameters
  • src_path (string) – Executable source path.

  • exe_path (string) – Executable or interpreter path in the sandbox.

  • argv ([string]) – List of arguments.

  • envp ([string]) – List of environment variables.

  • in_path (string) – Input file path.

  • ans_path (string) – Answer file path.

  • timelimit (int) – Timelimit.

  • memlimit (int) – Memlimit.

  • callback (function) – Callback of return_future.

Returns

None

last_restrict_uid = 1073741824
last_standard_uid = 16777232
last_uniqid = 0
null_fd = None
prefetch()[source]

Prefetch files.

start()[source]

Start the challenge.

Returns

Challenge result.

Return type

dict