multigp_toolkit.fpvscoresapi
============================

.. py:module:: multigp_toolkit.fpvscoresapi

.. autoapi-nested-parse::

   FPVScores Connections



Attributes
----------

.. autoapisummary::

   multigp_toolkit.fpvscoresapi.logger
   multigp_toolkit.fpvscoresapi.BASE_API_URL
   multigp_toolkit.fpvscoresapi.FPVS_API_VERSION
   multigp_toolkit.fpvscoresapi.LEGACY_HEADERS
   multigp_toolkit.fpvscoresapi.P
   multigp_toolkit.fpvscoresapi.R


Classes
-------

.. autoapisummary::

   multigp_toolkit.fpvscoresapi.FPVScoresAPI
   multigp_toolkit.fpvscoresapi.AlchemyEncoder


Functions
---------

.. autoapisummary::

   multigp_toolkit.fpvscoresapi.standard_plugin_not_installed
   multigp_toolkit.fpvscoresapi._assemble_pilots_complete
   multigp_toolkit.fpvscoresapi._assemble_heatnodes_complete
   multigp_toolkit.fpvscoresapi.register_handlers


Module Contents
---------------

.. py:data:: logger

   Module logger


.. py:data:: BASE_API_URL
   :value: 'https://api.fpvscores.com'


   FPVScores API base URL


.. py:data:: FPVS_API_VERSION
   :value: '0.1.0'


   FPVScores Sync API version


.. py:data:: LEGACY_HEADERS

   Headers for FPVScores MultiGP requests


.. py:data:: P

   Generic for typing


.. py:data:: R

   Generic for typing


.. py:function:: standard_plugin_not_installed()

   Check if the full FPVScores plugin is not installed

   :return: status of the install


.. py:class:: FPVScoresAPI(rhapi)

   Bases: :py:obj:`multigp_toolkit.abstracts._APIManager`


   The primary class used to interact with the FPVScores API

   .. seealso::

       https://github.com/FPVScores/FPVScores-Sync/tree/main


   .. py:attribute:: _linked_org
      :type:  Union[bool, None]
      :value: None


      Whether the current MultiGP chapter is linked to FPVScores or not



   .. py:attribute:: sync_ran
      :type:  bool
      :value: False


      Status if a full sync was ran or not



   .. py:attribute:: _rhapi

      A stored instance of RHAPI



   .. py:attribute:: sync_guard


   .. py:method:: _register_listeners()

      Registers the FPVScores event listeners



   .. py:method:: connection_check()

      Checks for a connection to FPVScores

      :return: The connection status



   .. py:method:: generate_fpvsconditions()

      Lazy loads and runs checks for fpvscores api actions

      :yield: Check statuses



   .. py:method:: _generate_listener_conditions()

      Lazy loads and runs checks for event listeners

      :yield: Check statuses



   .. py:method:: _check_listener_conditions()

      Decorator to run a series of checks before running event callback



   .. py:method:: _parse_server_response(data)

      Attempts to parse the incoming data from the FPVScores server.

      :param data: The returned FPVScores data



   .. py:method:: _process_response(greenlet)

      Wait for the response greenlet to finish. Attempt to
      parse the incoming data when completed.

      :param greenlet: The greenlet to wait for



   .. py:method:: _class_listener_request(payload)

      Submits a request to the class update enpoint asynchronously
      using gevent

      :param payload: The payload to send



   .. py:method:: add_raceclass_listener(args)

      Sync the individual race class creation data to FPVScores

      :param args: Default callback arguments



   .. py:method:: alter_raceclass_listener(args)

      Sync the individual race class modification data to FPVScores

      :param args: Default callback arguments



   .. py:method:: get_race_channels()

      Gets the channel list in the FPVScores format

      :return: The list of channels



   .. py:method:: class_delete(args)

      Deletes a single race class from FPVScores.

      :param args: Default callback arguments



   .. py:method:: heat_listener(args)

      Sync the individual heat data to FPVScores

      :param args: Default callback arguments



   .. py:method:: heat_delete(args)

      Deletes a single heat from FPVScores.

      :param args: Default callback arguments



   .. py:method:: pilot_listener(args)

      Sync the individual pilot data to FPVScores

      :param args: Default callback arguments



   .. py:method:: generate_rank_payload(raceclass)

      Generate the rankings payload for FPVScores

      :param raceclass: The raceclass to generate the payload from
      :return: A generated list of pilot data



   .. py:method:: generate_results_payload(raceclass)

      Generate the results payload for FPVScores

      :param raceclass: The raceclass to generate the payload from
      :return: A generated list of pilot data



   .. py:method:: results_listener(args)

      Sync the individual class results to FPVScores

      :param args: Default callback arguments



   .. py:method:: run_full_sync(_args = None)

      Syncs the FPVScores event to the current RotorHazard state

      :param _args: Default callback arguments



   .. py:method:: get_event_url()

      Get the FPVScores event url for the active race

      :return: The event url



   .. py:method:: check_linked_org()

      Checks if the MultiGP API timer key in the system is linked to
      an FPVScores organization

      :return: Whether the key is linked or not



.. py:function:: _assemble_pilots_complete(rhapi)

   Gets the database pilots and adds their MultiGP id
   to the upload data.

   :return: The list of pilots


.. py:function:: _assemble_heatnodes_complete(rhapi)

   Assembles heatnode data for FPVScores push

   :param rhapi: An instance of RHAPI
   :return: The formated payload


.. py:function:: register_handlers(args)

   Register export handlers

   :param args: Default callback arguments


.. py:class:: AlchemyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

   Bases: :py:obj:`json.JSONEncoder`


   JSON encoder for SQLAlchemy objects


   .. py:method:: default(o)

      Implement this method in a subclass such that it returns
      a serializable object for ``o``, or calls the base implementation
      (to raise a ``TypeError``).

      For example, to support arbitrary iterators, you could
      implement default like this::

          def default(self, o):
              try:
                  iterable = iter(o)
              except TypeError:
                  pass
              else:
                  return list(iterable)
              # Let the base class default method raise the TypeError
              return super().default(o)




