예제 #1
0
class NetworkSpeedDaemon(VMCDaemon):
    """
    I enque fake SIG_SPEED UnsolicitedNotifications
    """

    def __init__(self, frequency, device, notification_manager):
        super(NetworkSpeedDaemon, self).__init__(frequency, device, notification_manager)
        self.netspeed = NetworkSpeed()

    def start(self):
        log.msg("DAEMONS: DAEMON %s started..." % self.__class__.__name__)
        self.netspeed.start()
        self.loop = LoopingCall(self.function)
        self.loop.start(self.frequency)

    def stop(self):
        log.msg("DAEMONS: DAEMON %s stopped..." % self.__class__.__name__)

        self.loop.stop()
        self.netspeed.stop()

    def function(self):
        up, down = self.netspeed["up"], self.netspeed["down"]
        n = N.UnsolicitedNotification(N.SIG_SPEED, bps_to_human(up, down))
        self.manager.on_notification_received(n)
예제 #2
0
class NetworkSpeedDaemon(VMCDaemon):
    """
    I enque fake SIG_SPEED UnsolicitedNotifications
    """
    def __init__(self, frequency, device, notification_manager):
        super(NetworkSpeedDaemon, self).__init__(frequency, device,
                                                 notification_manager)
        self.netspeed = NetworkSpeed()

    def start(self):
        log.msg("DAEMONS: DAEMON %s started..." % self.__class__.__name__)
        self.netspeed.start()
        self.loop = LoopingCall(self.function)
        self.loop.start(self.frequency)

    def stop(self):
        log.msg("DAEMONS: DAEMON %s stopped..." % self.__class__.__name__)

        self.loop.stop()
        self.netspeed.stop()

    def function(self):
        up, down = self.netspeed['up'], self.netspeed['down']
        n = N.UnsolicitedNotification(N.SIG_SPEED, bps_to_human(up, down))
        self.manager.on_notification_received(n)
예제 #3
0
 def __init__(self, frequency, device, notification_manager):
     super(NetworkSpeedDaemon, self).__init__(frequency, device, notification_manager)
     self.netspeed = NetworkSpeed()
예제 #4
0
 def __init__(self, frequency, device, notification_manager):
     super(NetworkSpeedDaemon, self).__init__(frequency, device,
                                              notification_manager)
     self.netspeed = NetworkSpeed()