Changes between Version 9 and Version 10 of Development/1.2/Plugin


Ignore:
Timestamp:
09/11/2009 01:47:59 AM (15 years ago)
Author:
andar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Development/1.2/Plugin

    v9 v10  
    231231 
    232232    def update_stats(self): 
    233         session_status = component.get("Core").get_session_status(["total_download", "total_upload"]) 
    234         self.total_upload = self.config["total_upload"] + session_status["total_upload"] 
    235         self.total_download = self.config["total_download"] + session_status["total_download"] 
     233        status = component.get("Core").get_session_status(["total_download", "total_upload"]) 
     234        self.total_upload = self.config["total_upload"] + status["total_upload"] 
     235        self.total_download = self.config["total_download"] + status["total_download"] 
    236236 
    237237}}} 
     
    241241You'll see that we're updating our member variables `total_upload` and `total_download` with the values in our config dictionary plus the session byte count.  This will give us a total download/upload count over all our sessions. 
    242242 
    243 At this point the function isn't doing anything because it isn't called anywhere! So it's time to add our LoopingCall to take care of this for us. 
    244  
    245 We need to import the LoopingCall class first.  Since we use Twisted for our mainloop, we import this class from there.  You will want to put this import with the rest at the top of the file. 
     243At this point the function isn't doing anything because it isn't called anywhere! So it's time to add our `LoopingCall` to take care of this for us. 
     244 
     245We need to import the `LoopingCall` class first.  Since we use Twisted for our mainloop, we import this class from there.  You will want to put this import with the rest at the top of the file. 
    246246 
    247247{{{ 
     
    252252}}} 
    253253 
    254 Now, we want to setup and start the LoopingCall when the plugin is enabled, so lets modify `enable()` again. 
     254Now, we want to setup and start the `LoopingCall` when the plugin is enabled, so lets modify `enable()` again. 
    255255 
    256256{{{ 
     
    267267}}} 
    268268 
    269 The syntax for the LoopingCall is simple, it just takes function you wish to call in the timer.  Next, we simply `start()` the timer with a value in seconds that determines it's frequency, in this case the function will be called every 2 seconds. 
    270  
     269The syntax for the `LoopingCall` is simple, it just takes function you wish to call in the timer.  Next, we simply `start()` the timer with a value in seconds that determines it's frequency, in this case the function will be called every 2 seconds. 
     270