(self)
Read DVB-S2 frontend stats

        Returns:

            (dict): Dictionary with the frontend status in case the reading is
            successful. None on the following error conditions: 1) if the
            Sat-IP server does not return any frontend info; 2) if the frontend
            serving this client is not active in the Sat-IP server; and 3) if
            the frontend status parsing fails.
Read DVB-S2 frontend stats
Read DVB - S2 frontend stats
def fe_stats(self):
        """Read DVB-S2 frontend stats

        Returns:

            (dict): Dictionary with the frontend status in case the reading is
            successful. None on the following error conditions: 1) if the
            Sat-IP server does not return any frontend info; 2) if the frontend
            serving this client is not active in the Sat-IP server; and 3) if
            the frontend status parsing fails.

        """
        self._assert_addr()
        url = self.base_url + "/cgi-bin/index.cgi"

        try:
            rv = self.session.get(url, params={'cmd': 'frontend_info'})
        except requests.exceptions.ConnectionError as errc:
            logger.error("Connection Error: {}".format(errc))
            logger.info("Reconnecting")
            self.login()
            return
        except requests.exceptions.HTTPError as errh:
            logger.error("HTTP Error: {}".format(errh))
            logger.info("Reconnecting")
            self.login()
            return
        except requests.exceptions.RequestException as err:
            logger.error("Error: {}".format(err))
            logger.info("Reconnecting")
            self.login()
            return

        try:
            info = rv.json()
        except ValueError:
            if ("/cgi-bin/login.cgi" in rv.text and rv.status_code == 200):
                logger.warning("Sat-IP server has closed the session. "
                               "Reconnecting.")
                self.login()
            return

        if 'frontends' not in info:
            return

        # Select the active frontends:
        active_frontends = []
        for fe in info['frontends']:
            if fe['frontend']['ip'] != 'none' and fe['frontend']['ip'] != 'NA':
                active_frontends.append(fe['frontend'])

        if len(active_frontends) == 0:
            logger.warning("Could not find any active frontend")
            return

        logger.debug("Active frontends: {}".format(active_frontends))

        # Define the active frontend serving this client
        if (self.serving_fe is None):
            self._find_serving_frontend(active_frontends)

        # Check that the serving frontend is still in the active frontend list.
        # If not, there are two possible reasons:
        #
        # 1) We are running with option --ignore-http-errors and the tsp client
        #    has just reconnected.
        # 2) The initial procedure to find the serving frontend got confused
        #    due to other Sat-IP clients running on the same host and was
        #    actually pointing to a frontend serving another client. Now, this
        #    other client stopped and the frontend is no longer active.
        #
        # In any case, try to find the serving frontend again.
        if not any([fe['name'] == self.serving_fe for fe in active_frontends]):
            logger.warning("Sat-IP {} has become inactive.".format(
                self.serving_fe))
            self._find_serving_frontend(active_frontends)
            if (self.serving_fe is not None):
                logger.info("Switching to {}".format(self.serving_fe))

        # Finally, parse the status from the serving frontend.
        serving_fe = [
            fe for fe in active_frontends if fe['name'] == self.serving_fe
        ]
        if len(serving_fe) == 0:
            return

        try:
            return self._parse_fe_info(serving_fe[0])
        except ValueError:
            return
def fe_stats ( self ) : self . _assert_addr ( ) url = self . base_url + "/cgi-bin/index.cgi" try : rv = self . session . get ( url , params = { 'cmd' : 'frontend_info' } ) except requests . exceptions . ConnectionError as errc : logger . error ( "Connection Error: {}" . format ( errc ) ) logger . info ( "Reconnecting" ) self . login ( ) return except requests . exceptions . HTTPError as errh : logger . error ( "HTTP Error: {}" . format ( errh ) ) logger . info ( "Reconnecting" ) self . login ( ) return except requests . exceptions . RequestException as err : logger . error ( "Error: {}" . format ( err ) ) logger . info ( "Reconnecting" ) self . login ( ) return try : info = rv . json ( ) except ValueError : if ( "/cgi-bin/login.cgi" in rv . text and rv . status_code == 200 ) : logger . warning ( "Sat-IP server has closed the session. " "Reconnecting." ) self . login ( ) return if 'frontends' not in info : return # Select the active frontends: active_frontends = [ ] for fe in info [ 'frontends' ] : if fe [ 'frontend' ] [ 'ip' ] != 'none' and fe [ 'frontend' ] [ 'ip' ] != 'NA' : active_frontends . append ( fe [ 'frontend' ] ) if len ( active_frontends ) == 0 : logger . warning ( "Could not find any active frontend" ) return logger . debug ( "Active frontends: {}" . format ( active_frontends ) ) # Define the active frontend serving this client if ( self . serving_fe is None ) : self . _find_serving_frontend ( active_frontends ) # Check that the serving frontend is still in the active frontend list. # If not, there are two possible reasons: # # 1) We are running with option --ignore-http-errors and the tsp client #    has just reconnected. # 2) The initial procedure to find the serving frontend got confused #    due to other Sat-IP clients running on the same host and was #    actually pointing to a frontend serving another client. Now, this #    other client stopped and the frontend is no longer active. # # In any case, try to find the serving frontend again. if not any ( [ fe [ 'name' ] == self . serving_fe for fe in active_frontends ] ) : logger . warning ( "Sat-IP {} has become inactive." . format ( self . serving_fe ) ) self . _find_serving_frontend ( active_frontends ) if ( self . serving_fe is not None ) : logger . info ( "Switching to {}" . format ( self . serving_fe ) ) # Finally, parse the status from the serving frontend. serving_fe = [ fe for fe in active_frontends if fe [ 'name' ] == self . serving_fe ] if len ( serving_fe ) == 0 : return try : return self . _parse_fe_info ( serving_fe [ 0 ] ) except ValueError : return