fulgens module¶
- class fulgens.ChallengeHelper(addresses: List[str], secret: str, local_challenge_dir: str | Path, remote_challenge_dir: str | Path = None, compose_filename: str = 'docker-compose.yml', ssh_conn: Connection | None = None)¶
Bases:
object
Helper for checker to get and interact with the service.
- Attributes:
- addresses: List[str]
List of service addresses that exposed.
- secret: str
Team secret key.
- local_challenge_dir: pathlib.Path
Local challenge directory.
- remote_challenge_dir: pathlib.Path
Remote challenge directory.
- compose_filename: str
Compose filename. The default value is
docker-compose.yml
.- ssh_conn: fabric.Connection or None
SSH connection to the server that runs the services. If
None
, it will assume that the service is in the same server as the checker, alsoremote_challenge_dir
andlocal_challenge_dir
will have the same value.
Methods
fetch
(service_name, source, dest)Fetch file/folder from the remote service container to the local filesystem.
run
(service_name, cmd)Run shell commands inside the service container.
- fetch(service_name: str, source: str | Path, dest: str | Path)¶
Fetch file/folder from the remote service container to the local filesystem.
- Parameters:
- service_name: str
Service name.
- source: str | pathlib.Path
Service container path file.
- dest: str | pathlib.Path
Local filesystem path.
- Returns:
- bool
Whether fetch is successful or not.
- Raises:
- ValueError
If the service name requested cannot be found.
- IOError
If there is something wrong with the file transfer or modification.
- run(service_name: str, cmd: List[str] | str)¶
Run shell commands inside the service container.
- Parameters:
- service_name: str
Service name.
- cmd: List[str] or str
Command to be executed.
- Returns:
- bytes
Standard output.
- bytes
Standard error.
- int
exit code
- Raises:
- ValueError
If the service name requested cannot be found.
- class fulgens.Verdict(status: str, message: str)¶
Bases:
object
Define checker verdict.
- Attributes:
- status: str
Verdict status.
OK
is given if the service passed all the testcases,FAIL
if the service fail on some testcases (e.g.: give invalid response or take too long to respond), orERROR
if the checker cannot execute the testcase properly.- message: str
Additional information related to the verdict given.
Methods
ERROR
(message)Create ERROR verdict object.
FAIL
(message)Create FAIL verdict object.
OK
([message])Create OK verdict object.
is_ok
()Check is the verdict is
OK
or not.- classmethod ERROR(message)¶
Create ERROR verdict object.
- Parameters:
- message: str
See the
message
attribute.
- Returns:
- fulgens.Verdict
Verdict object with
ERROR
status.
- classmethod FAIL(message)¶
Create FAIL verdict object.
- Parameters:
- message: str
See the
message
attribute.
- Returns:
- fulgens.Verdict
Verdict object with
FAIL
status.
- classmethod OK(message='')¶
Create OK verdict object.
- Parameters:
- message: str
See the
message
attribute.
- Returns:
- fulgens.Verdict
Verdict object with
OK
status.
- is_ok()¶
Check is the verdict is
OK
or not.- Returns:
- bool
Whether the verdict is
OK
or not.