plom.solutions module

Plom tools associated with uploading/downloading solutions

plom.solutions.checkStatus(*, msgr)[source]

Checks the status of solutions on a server.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

each entry is a list of triples [q, v, md5sum] or [q, v, ""]. TODO: explain more.

Return type:

list

plom.solutions.clear_manager_login(server=None, password=None)[source]

Force clear the “manager” authorisation, e.g., after a crash.

Parameters:
  • server (str) – in the form “example.com” or “example.com:41984”.

  • password (str) – if not specified, prompt on the command line.

plom.solutions.deleteSolutionImage(question, version, *, msgr)[source]

Delete one of the solution images on the server.

Parameters:
  • question (int) – which question.

  • version (int) – which version.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

None

Raises:

PlomNoSolutionException – the question/version asked for does not have a solution image on the server. This is also raised if the values are out of range.

plom.solutions.extractSolutionImages(solution_spec_filename=None, *, msgr)[source]

Extract solution images from PDF files in special location.

The PDF files need to be in a special place and have special names. TODO: doc better. Maybe the location could at least be a kwarg with a default value.

Parameters:

solution_spec_filename (str/pathlib.Path/None) – the spec of the solution. If None, it tries to autoconstruct from the server’s exam spec.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

the bitmap of the solution.

Return type:

bytes

plom.solutions.getSolutionImage(question, version, *, msgr)[source]

Get a solution image from the server.

Parameters:
  • question (int) – which question.

  • version (int) – which version.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

the bitmap of the solution or None if there was no solution. If you wish to know what sort of image it is, consider using imghdr in the Python standard library.

Return type:

bytes

Raises:

PlomNoSolutionException – the question/version asked for does not have a solution image on the server. This is also returned if the values are out of range.

plom.solutions.putExtractedSolutionImages(*, msgr)[source]

Push all extract solution images to a server.

This is a more automatic version of putSolutionImage(): instead of just one image, we push all of them for all questions and versions. This means a particular directory structure is expected.

TODO: kwarg for that directory, with default.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

None

plom.solutions.putSolutionImage(question, version, imageName, *, msgr)[source]

Push a solution image to a server.

Parameters:
  • question (int) –

  • version (int) –

  • imageName (str/pathlib.Path) –

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

[True, msg] or [False, msg] where msg is either an error message (on failure) or a diagnostic message (on success).