Changes between Version 9 and Version 10 of Development/1.2/Plugin
- Timestamp:
- 09/11/2009 01:47:59 AM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Development/1.2/Plugin
v9 v10 231 231 232 232 def update_stats(self): 233 s ession_status = component.get("Core").get_session_status(["total_download", "total_upload"])234 self.total_upload = self.config["total_upload"] + s ession_status["total_upload"]235 self.total_download = self.config["total_download"] + s ession_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"] 236 236 237 237 }}} … … 241 241 You'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. 242 242 243 At this point the function isn't doing anything because it isn't called anywhere! So it's time to add our LoopingCallto take care of this for us.244 245 We need to import the LoopingCallclass 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.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. 246 246 247 247 {{{ … … 252 252 }}} 253 253 254 Now, we want to setup and start the LoopingCallwhen the plugin is enabled, so lets modify `enable()` again.254 Now, we want to setup and start the `LoopingCall` when the plugin is enabled, so lets modify `enable()` again. 255 255 256 256 {{{ … … 267 267 }}} 268 268 269 The syntax for the LoopingCallis 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 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