multigp_toolkit.rsexporter#

Import Data from RaceSync

Attributes#

Classes#

RaceSyncExporter

Actions for exporting data to RaceSync

Module Contents#

multigp_toolkit.rsexporter.T#
multigp_toolkit.rsexporter.logger#
class multigp_toolkit.rsexporter.RaceSyncExporter(rhapi, multigp, verification)#

Actions for exporting data to RaceSync

Parameters:
_rhapi#

A stored instace of the RHAPI module

_multigp#

A stored instace of the MultiGPAPI module

_verification#

A stored instace of the SystemVerification module

_fpvscores#

An instance of FPVScoresAPI

active_sync#

Variable for checking if a results sync is active

get_mgp_pilot_id(pilot_id)#

Gets the MultiGP id for a pilot

Parameters:

pilot_id (int) – The database id for the pilot

Returns:

The

Return type:

Union[str, None]

generate_formated_race_data(race_info, selected_race, round_num, heat_num, event_url)#

Generates a slot and score package for each pilot for the provided race

Parameters:
  • race_info (Database.SavedRaceMeta) – Data for the completed race

  • event_url (Union[str, None]) – The FPVScores event url

  • selected_race (int)

  • round_num (int)

  • heat_num (int)

Yield:

Formated race data

slot_score(collection)#

Push generated data to MultiGP. Uses a gevent connection pool for parallel connections.

Parameters:
  • data_generators – Generators for formating data.

  • collection (collections.abc.Iterable[collections.abc.Generator])

Returns:

Status of the push

Return type:

bool

_generate_fpvscores_conditions()#

Lazily generate the conditions for pushing to FPVScores

Yield:

Check statuses

Return type:

collections.abc.Generator[bool, None, None]

_bundle_by_group(races)#

Group saved race meta by heat groups and then sorts each heat groups based on heat id.

Parameters:

races (list[Database.SavedRaceMeta]) – The saved race meta to organize

Returns:

The sorted heat groups

Return type:

dict[int, list[Database.SavedRaceMeta]]

_bundle_by_heat(races)#

Group saved race meta by heat id.

Parameters:

races (list[Database.SavedRaceMeta]) – A list of the saved race data

Returns:

An organized group of race data

Return type:

dict[int, list[Database.SavedRaceMeta]]

_parse_heat_group_data(selected_mgp_race, event_url, races)#

Parses class data in the Generate Heat Groups format to be compatible with MultiGP predefined heats.

Round number is set to the internal group id + 1 and the heat number is set set to the index of the heat within the heat group

Race data may be lost if a pilot participates in more than one heat per round. This is due to a limitation with MultiGP limiting pilots to one heat per round.

Parameters:
  • selected_mgp_race (int) – The selected MultiGP race

  • event_url (Union[str, None]) – The FPVScores event url

  • races (list[Database.SavedRaceMeta]) – The race data

Yield:

The formated data

Return type:

collections.abc.Generator[collections.abc.Generator[tuple, None, None], None, None]

_parse_heat_data(selected_mgp_race, event_url, races)#

Parses class data in the Count Races per Heat format to be compatible with MultiGP predefined heats.

Uses the internal round number and the index of the heat within the raceclass.

Race data may be lost if a pilot participates in more than one heat per round. This is due to a limitation with MultiGP limiting pilots to one heat per round.

Parameters:
  • selected_mgp_race (int) – The selected MultiGP race

  • event_url (Union[str, None]) – The FPVScores event url

  • races (list[Database.SavedRaceMeta]) – The race data

Yield:

The formated data

Return type:

collections.abc.Generator[collections.abc.Generator[tuple, None, None], None, None]

_parse_zippyq_data(selected_mgp_race, event_url, races)#

Parses class data to be compatible with ZippyQ.

The zippyq round number is read from the heat metadata

Parameters:
  • selected_mgp_race (int) – The selected MultiGP race

  • event_url (Union[str, None]) – The FPVScores event url

  • races (list[Database.SavedRaceMeta]) – The race data

Yield:

The formated data

Return type:

collections.abc.Generator[collections.abc.Generator[tuple, None, None], None, None]

_parse_incremental_round_data(selected_mgp_race, event_url, races)#

Parses class data to be compatible with brackets or ladders.

Each race increments the round number and the heat number is always set to 1.

Parameters:
  • selected_mgp_race (int) – The selected MultiGP race

  • event_url (Union[str, None]) – The FPVScores event url

  • races (list[Database.SavedRaceMeta]) – The race data

Yield:

The formated data

Return type:

collections.abc.Generator[collections.abc.Generator[tuple, None, None], None, None]

raceclass_slot_score(selected_mgp_race, selected_rh_class, event_url)#

Pushes race results for a selected RotorHazard class to a specific MultiGP race. Typically trigger by a manual button press in the user interface.

Parameters:
  • selected_mgp_race (int) – The MultiGP race to push to.

  • selected_rh_class (int) – The selected RotorHazard class id

  • event_url (Union[str, None]) – The FPVScores

_rankings_from_leaderboard_data(data)#

Generates formated pilot rankings from leaderboard data

Parameters:

data (dict) – The input leaderboard data

Returns:

Formated ranking data

Return type:

list[dict]

push_bracketed_rankings(selected_mgp_race, selected_rh_class)#

Pushes the overall rankings of the selected RotorHazard race class to the MultiGP race.

Parameters:
  • selected_mgp_race (str) – The set MultiGP race

  • selected_rh_class (int) – The selected RotorHazard race class

Returns:

Status

Return type:

bool

raceclass_rankings_push()#

Trigger a rankings push to all imported MultiGP races

Returns:

Push status

Return type:

bool

raceclass_results_push(event_url=None)#

Trigger a results push to all imported MultiGP races

Parameters:

event_url (Union[str, None])

Return type:

bool

_gq_push_checks()#

System checks before pushing global qualifier data

Returns:

The status of the checks

Return type:

bool

_run_fpvscores_sync(gq_active)#

Manage the data push to FPVScores

Parameters:

gq_active (bool) – Configure the push for a global qualifier

Returns:

The status and event url

Return type:

tuple[bool, Union[str, None]]

zippyq_slot_score(args)#

Push results of a saved ZippyQ race to MultiGP

Parameters:

args (dict[str, int]) – Callback args

Return type:

None

manual_push_results(args=None)#

Wrapper for _manual_push_results. Prevents multiple pushes from being active at once

Parameters:
  • _args – Callback args, defaults to None

  • args (Union[dict, None])

Return type:

None

_manual_push_results(_args=None)#

Pushes the results of a RotorHazard class to MultiGP

Parameters:

_args (Union[dict, None]) – Callback args, defaults to None

Return type:

None