getscript

The getscript contains the relevant code to load the upcoming activities from Koala and extract the relevant information, for display on the zuil.

The getscript can be run independently, by using the command zuil-get, which calls main().

infozuild.getscript.INFO_LINES = [' Welkom bij Sticky:', ' Uw bron voor koekjes, koffie en', ' hulp bij practica', '', 'Dagelijks geopend van 9-17 uur.', '', 'Laatste update:', ' +++ OUT OF CHEESE ERROR +++']

The template for the first page, as used in make_rotation().

infozuild.getscript.build_when(event, today=None)[source]
Parameters:
  • event (dict) – a dict as returned by Koala’s API.
  • today (datetime.datetime) – an optional ‘now-moment’ for testing consistency of date collapsing.
Returns:

A string that contains just enough information to inform the viewer when an event will take place.

infozuild.getscript.get_activities()[source]

Retrieve upcoming activities and parse the received data into the format to be used on the display.

Returns:A list of (name, date) tuples and an optional string containing an error code. The list of events will be empty if events could not be retrieved.
infozuild.getscript.main()[source]

zuil-get entrypoint.

zuil-get retrieves the current activities, and outputs them in a JSON format parsable by infozuild.sendscript.Rotation.from_json().

infozuild.getscript.make_rotation(activities=None, motd=None, limit_activities=None)[source]

Retrieve activities and return a Rotation that can be passed to the sendscript.

Parameters:
  • activities (list) – a list of events retrieved from Koala, to bypass automatic retrieval in the function itself.
  • motd (str) – A status message to be shown on the first page, in the fifth and sixth lines. Will use default if None.
  • limit_activities (int) – the maximum number of events that may be shown. A negative value will remove that many values from the end. This value is only applied to automatically retrieved events, manually passed activities via the argument will always be used as-is.
Returns:

A Rotation containing three events per Page, and a title page containting the generation time and date.

infozuild.getscript.make_rotation_json(max_activities=None)[source]

Convert the Rotation returned by make_rotation() to a json string.

infozuild.getscript.no_secs(time)[source]

Force a datetime.datetime to a string, with the seconds removed.

Behaviour of build_when

Because it’s unnecessary and annoying to show more information than needed, build_when() will check the date information of the events against a number of scenarios in order to determine what actually needs to be shown.

The following assumptions can be made (as they are enforced by Koala):

  • start_date will always be present.
  • end_time will never be present without start_time.

The following scenarios are likely:

  1. end_date absent: legacy event, just show start_date.

end_date same as start_date:

  1. No times: new(er) all-day event, just show start_date

  2. start_time set, end_time absent:

    Event without known end, show start_time and start_date if not today

  3. Both times set:

    Show start_date (if not today), start_time and end_time.

end_date NOT the same as start_date (“multi-day event”):

  1. No times: multi-day all-day event, start_date~end_date
  2. Start_time: start_date start_time~end_date
  3. Both times: start_date start_time~end_date end_time