(self, data)
Update the receiver stats kept internally

        Args:
            data : Dictionary of tuples corresponding to the receiver metrics.
                   Each tuple should consist of the value and its unit.
Update the receiver stats kept internally
Update the receiver stats kept internally
def update(self, data):
        """Update the receiver stats kept internally

        Args:
            data : Dictionary of tuples corresponding to the receiver metrics.
                   Each tuple should consist of the value and its unit.

        """

        # The input should be a dictionary of tuples
        assert (isinstance(data, dict))
        assert (all([isinstance(x, tuple) for x in data.values()]))

        # All keys in the input dictionary must be supported receiver metrics
        assert (all([k in self._metrics for k in data.keys()]))

        # Copy all the data
        self.stats = data

        # Is it time to log a new line?
        t_now = time.time()
        if (t_now - self.t_last_print) < self.min_interval:
            return

        self.t_last_print = t_now

        # Append metrics to log file
        if (self.logfile):
            with open(self.logfile, 'a') as fd:
                fd.write(str(self) + "\n")

        # Report over HTTP to a remote address
        if (self.report):
            self.reporter.send(self.get_stats())
            # If the reporter object is configured to report to the Monitoring
            # API but, at this point, it is still waiting for registration to
            # complete, don't log the status to the console yet. Otherwise, the
            # user would likely miss the logs indicating completion of the
            # registration procedure. On the other hand, if a log file is
            # enabled, it is OK to log into it throughout the registration.
            #
            # Besides, if the reporter is configured to report to the
            # Monitoring API and the registration is not complete yet, the
            # above call does not really send the report yet. Nevertheless, it
            # is still required. Refer to the implementation.
            #
            # As soon as the registration procedure ends (as indicated by the
            # "registration_running" flag), console logs are reactivated, even
            # if the registration fails.
            if (self.reporter.bs_monitoring is not None
                    and not self.reporter.bs_monitoring.registered
                    and self.reporter.bs_monitoring.registration_running):
                return

        # Print to console
        if (self.echo):
            print_end = '\n' if self.scroll else '\r'
            if (not self.scroll):
                sys.stdout.write("\033[K")
            print(str(self), end=print_end)
def update ( self , data ) : # The input should be a dictionary of tuples assert ( isinstance ( data , dict ) ) assert ( all ( [ isinstance ( x , tuple ) for x in data . values ( ) ] ) ) # All keys in the input dictionary must be supported receiver metrics assert ( all ( [ k in self . _metrics for k in data . keys ( ) ] ) ) # Copy all the data self . stats = data # Is it time to log a new line? t_now = time . time ( ) if ( t_now - self . t_last_print ) < self . min_interval : return self . t_last_print = t_now # Append metrics to log file if ( self . logfile ) : with open ( self . logfile , 'a' ) as fd : fd . write ( str ( self ) + "\n" ) # Report over HTTP to a remote address if ( self . report ) : self . reporter . send ( self . get_stats ( ) ) # If the reporter object is configured to report to the Monitoring # API but, at this point, it is still waiting for registration to # complete, don't log the status to the console yet. Otherwise, the # user would likely miss the logs indicating completion of the # registration procedure. On the other hand, if a log file is # enabled, it is OK to log into it throughout the registration. # # Besides, if the reporter is configured to report to the # Monitoring API and the registration is not complete yet, the # above call does not really send the report yet. Nevertheless, it # is still required. Refer to the implementation. # # As soon as the registration procedure ends (as indicated by the # "registration_running" flag), console logs are reactivated, even # if the registration fails. if ( self . reporter . bs_monitoring is not None and not self . reporter . bs_monitoring . registered and self . reporter . bs_monitoring . registration_running ) : return # Print to console if ( self . echo ) : print_end = '\n' if self . scroll else '\r' if ( not self . scroll ) : sys . stdout . write ( "\033[K" ) print ( str ( self ) , end = print_end )