├── NetWatcher2.egg-info ├── PKG-INFO ├── SOURCES.txt ├── dependency_links.txt ├── entry_points.txt └── top_level.txt ├── README.md ├── build └── lib.linux-x86_64-2.7 │ ├── netwatcher │ ├── __init__.py │ ├── common.py │ ├── core.py │ ├── data │ │ ├── config.glade │ │ ├── config.glade~ │ │ └── netwatcher.js │ ├── gtkui.py │ └── webui.py │ └── netwatcher2 │ ├── __init__.py │ ├── common.py │ ├── core.py │ ├── data │ ├── config.glade │ ├── netwatcher.js │ └── netwatcher.js~ │ ├── gtkui.py │ └── webui.py ├── dist ├── NetWatcher-0.1-py2.7.egg ├── NetWatcher2-0.2-py2.7.egg └── NetWatcher2-0.2.01-py2.7.egg ├── netwatcher2 ├── __init__.py ├── common.py ├── core.py ├── data │ ├── config.glade │ └── netwatcher.js ├── gtkui.py └── webui.py ├── setup.py └── setup.py~ /NetWatcher2.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: NetWatcher2 3 | Version: 0.2.01 4 | Summary: UNKNOWN 5 | Home-page: UNKNOWN 6 | Author: Cole Morgen (originally from Riccardo Poggi) 7 | Author-email: morgenman@gmail.com 8 | License: GPLv3 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /NetWatcher2.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | NetWatcher2.egg-info/PKG-INFO 3 | NetWatcher2.egg-info/SOURCES.txt 4 | NetWatcher2.egg-info/dependency_links.txt 5 | NetWatcher2.egg-info/entry_points.txt 6 | NetWatcher2.egg-info/top_level.txt 7 | netwatcher2/__init__.py 8 | netwatcher2/common.py 9 | netwatcher2/core.py 10 | netwatcher2/gtkui.py 11 | netwatcher2/webui.py -------------------------------------------------------------------------------- /NetWatcher2.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /NetWatcher2.egg-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | 2 | [deluge.plugin.core] 3 | NetWatcher2 = netwatcher2:CorePlugin 4 | [deluge.plugin.gtkui] 5 | NetWatcher2 = netwatcher2:GtkUIPlugin 6 | [deluge.plugin.web] 7 | NetWatcher2 = netwatcher2:WebUIPlugin 8 | -------------------------------------------------------------------------------- /NetWatcher2.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | netwatcher2 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ================= 2 | Deluge NetWatcher2 3 | ================= 4 | 5 | _NetWatcher2_ is a plugin for the [Deluge bittorrent client](http://deluge-torrent.org/) that reduces the download speed of torrents to a set value if there is someone connected to the same network. 6 | 7 | This is an fork of rikpg's NetWatcher plugin 8 | 9 | Features: 10 | 11 | - Set a custom ip list. 12 | - Set the check rate. 13 | - Set the download rate. 14 | - Option to enable logging to a file. 15 | 16 | 17 | Usage 18 | ----- 19 | 20 | ### Ip Addresses 21 | 22 | Insert a list of comma separated ip addresses in the __Ip Addresses__ field, like `192.168.1.45, 192.168.1.128, 192.168.1.149`, and these addresses will be cheked every X minutes. 23 | 24 | Working rationale as follow: 25 | 26 | - At least one ip address is on-line => pause all 27 | - All the ip-addresses are off-line => resume all 28 | 29 | **Note:** The ip-addresses status is checked through ping requests. 30 | 31 | ### Custom logging 32 | 33 | It's also possibile to log the NetWatcher2 activity into a file. 34 | 35 | Other than knowing what happened when we weren't at the computer, the use of this feature combined with a Dropbox-like service makes it very easy to monitor torrents status without having to access the web-interface. 36 | To support this combined usage the log extension is `.txt`. 37 | 38 | 39 | Install the plugin 40 | ------------------ 41 | 42 | There are various ways to do it: 43 | 44 | 1. Download the egg from [here](https://github.com/morgenman/NetWatcher2/downloads) and follow one of [these instructions](http://dev.deluge-torrent.org/wiki/Plugins#InstallingPlugins). 45 | 46 | 2. Or download the source code (available [here](https://github.com/morgenman/NetWatcher2)), build the egg and then copy it in the deluge _plugins_ directory: 47 | 48 | $ python setup.py bdist_egg 49 | $ cp dist/*.egg ~/.config/deluge/plugins 50 | 51 | 3. Or like a developer, link to the egg with setuptools develop command: 52 | 53 | $ python setup.py develop -mxd ~/.config/deluge/plugins -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # __init__.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.plugins.init import PluginInitBase 41 | 42 | class CorePlugin(PluginInitBase): 43 | def __init__(self, plugin_name): 44 | from core import Core as _plugin_cls 45 | self._plugin_cls = _plugin_cls 46 | super(CorePlugin, self).__init__(plugin_name) 47 | 48 | class GtkUIPlugin(PluginInitBase): 49 | def __init__(self, plugin_name): 50 | from gtkui import GtkUI as _plugin_cls 51 | self._plugin_cls = _plugin_cls 52 | super(GtkUIPlugin, self).__init__(plugin_name) 53 | 54 | class WebUIPlugin(PluginInitBase): 55 | def __init__(self, plugin_name): 56 | from webui import WebUI as _plugin_cls 57 | self._plugin_cls = _plugin_cls 58 | super(WebUIPlugin, self).__init__(plugin_name) 59 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/common.py: -------------------------------------------------------------------------------- 1 | # 2 | # common.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | def get_resource(filename): 41 | import pkg_resources, os 42 | return pkg_resources.resource_filename("netwatcher", os.path.join("data", filename)) 43 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/core.py: -------------------------------------------------------------------------------- 1 | # 2 | # core.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.plugins.pluginbase import CorePluginBase 42 | import deluge.component as component 43 | import deluge.configmanager 44 | from deluge.core.rpcserver import export 45 | from twisted.internet import reactor, utils, defer 46 | 47 | import os.path 48 | 49 | 50 | DEFAULT_PREFS = { 51 | "ip_addresses": [], 52 | "download_rate": 125, 53 | "check_rate": 5, # minutes 54 | "custom_log": False, 55 | "log_dir": os.path.expanduser('~'), 56 | } 57 | 58 | 59 | # custom logging 60 | import logging 61 | logger = logging.getLogger("NetWatcher") 62 | logger.parent = 0 63 | logger.setLevel(logging.INFO) 64 | config = deluge.configmanager.ConfigManager("netwatcher.conf", 65 | DEFAULT_PREFS) 66 | dlspeed = config["download_rate"] 67 | 68 | 69 | 70 | class Core(CorePluginBase): 71 | 72 | def enable(self): 73 | self.config = deluge.configmanager.ConfigManager("netwatcher.conf", 74 | DEFAULT_PREFS) 75 | dlspeed = self.config["download_rate"] 76 | if self.config["custom_log"]: 77 | #TODO: The changes are applied at startup, so there's need for 78 | # a restart in order to log correctly 79 | file_path = os.path.join(self.config["log_dir"], 'netwatcher_log.txt') 80 | fh = logging.FileHandler(file_path) 81 | fh.setLevel(logging.INFO) 82 | formatter = logging.Formatter("[%(asctime)s] %(message)s", 83 | datefmt="%b-%d %H:%M") 84 | fh.setFormatter(formatter) 85 | logger.addHandler(fh) 86 | 87 | else: 88 | logger.addHandler(logging.NullHanlder()) 89 | 90 | logger.info('## Starting New Session ##') 91 | 92 | self.do_schedule() 93 | 94 | def disable(self): 95 | self.timer.cancel() 96 | 97 | def update(self): 98 | pass 99 | 100 | @staticmethod 101 | def regulate_torrents(scan_result): 102 | """Resume/Pause all torrents if `scan_result` is 'Free'/'Busy'.""" 103 | logger.info('## Updating ##') 104 | for torrent in component.get("Core").torrentmanager.torrents.values(): 105 | # empty keys -> full status 106 | if scan_result == 'Busy': 107 | limit = (dlspeed) 108 | torrent.set_max_download_speed(limit) 109 | 110 | 111 | elif scan_result == 'Free': 112 | limit = -1 113 | torrent.set_max_download_speed(limit) 114 | 115 | def do_schedule(self, timer=True): 116 | """Schedule of network scan and subsequent torrent regulation.""" 117 | d = self._quick_scan() 118 | d.addCallback(self.regulate_torrents) 119 | 120 | if timer: 121 | self.timer = reactor.callLater(self.config["check_rate"] * 60, 122 | self.do_schedule) 123 | 124 | def _quick_scan(self): 125 | """Return 'Busy' if any of the known addresses is alive, 'Free' 126 | otherwise. 127 | 128 | The scan is performed through ping requests. 129 | 130 | """ 131 | # Ping exit codes: 132 | # 0 - the address is alive (online) 133 | # 1 - the address is not alive (offline) 134 | # 2 - an error occured 135 | log.debug("spawning ping requests to all known addresses..") 136 | options = "{} -c1 -w1 -q" 137 | outputs = [utils.getProcessValue("ping", options.format(addr).split()) 138 | for addr in self.config["ip_addresses"]] 139 | 140 | # XXX: the following two lines will shadow ping errors (exit == 2) 141 | d = defer.gatherResults(outputs) 142 | d.addCallback(lambda x: 'Free' if all(x) else 'Busy') 143 | 144 | return d 145 | 146 | @export 147 | def set_config(self, config): 148 | """Sets the config dictionary""" 149 | for key in config.keys(): 150 | self.config[key] = config[key] 151 | self.config.save() 152 | 153 | self.timer.cancel() 154 | self.do_schedule() 155 | logger.info('## Setting Config ##') 156 | 157 | self.update() 158 | 159 | @export 160 | def get_config(self): 161 | """Returns the config dictionary""" 162 | return self.config.config 163 | self.update() -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/data/config.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 5 8 | dialog 9 | select-folder 10 | 11 | 12 | True 13 | False 14 | 2 15 | 16 | 17 | True 18 | False 19 | end 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | False 29 | True 30 | end 31 | 0 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | False 42 | 43 | 44 | True 45 | False 46 | 10 47 | 48 | 49 | True 50 | False 51 | 0 52 | none 53 | 54 | 55 | True 56 | False 57 | 10 58 | 11 59 | 12 60 | 61 | 62 | True 63 | False 64 | 65 | 66 | True 67 | False 68 | 69 | 70 | True 71 | False 72 | Ip Addresses: 73 | 74 | 75 | False 76 | True 77 | 2 78 | 0 79 | 80 | 81 | 82 | 83 | True 84 | True 85 | Comma separated list of ip adresses 86 | 87 | True 88 | False 89 | False 90 | True 91 | True 92 | 93 | 94 | True 95 | True 96 | 2 97 | 1 98 | 99 | 100 | 101 | 102 | False 103 | True 104 | 2 105 | 0 106 | 107 | 108 | 109 | 110 | True 111 | False 112 | 1 113 | 5 114 | 7 115 | eg: 192.168.1.45, 192.168.1.128, 192.168.1.149 116 | True 117 | True 118 | 119 | 120 | False 121 | False 122 | 1 123 | 124 | 125 | 126 | 127 | True 128 | False 129 | 130 | 131 | True 132 | False 133 | Check network status every: 134 | 135 | 136 | False 137 | True 138 | 2 139 | 0 140 | 141 | 142 | 143 | 144 | True 145 | True 146 | Check rate in minutes 147 | 148 | True 149 | False 150 | False 151 | False 152 | True 153 | True 154 | 1 1 1440 1 10 0 155 | True 156 | 157 | 158 | False 159 | True 160 | 2 161 | 1 162 | 163 | 164 | 165 | 166 | True 167 | False 168 | min 169 | 170 | 171 | False 172 | True 173 | 2 174 | 2 175 | 176 | 177 | 178 | 179 | False 180 | True 181 | 10 182 | 2 183 | 184 | 185 | 186 | 187 | 188 | 189 | True 190 | False 191 | 192 | 193 | True 194 | False 195 | Speed when client is active: 196 | 197 | 198 | False 199 | True 200 | 2 201 | 0 202 | 203 | 204 | 205 | 206 | True 207 | True 208 | Download Speed 209 | 210 | True 211 | False 212 | False 213 | False 214 | True 215 | True 216 | 1 1 1440 1 10 0 217 | True 218 | 219 | 220 | False 221 | True 222 | 2 223 | 1 224 | 225 | 226 | 227 | 228 | True 229 | False 230 | KiB/s 231 | 232 | 233 | False 234 | True 235 | 2 236 | 2 237 | 238 | 239 | 240 | 241 | False 242 | True 243 | 10 244 | 2 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | True 254 | False 255 | <b>Settings</b> 256 | True 257 | 258 | 259 | label_item 260 | 261 | 262 | 263 | 264 | False 265 | True 266 | 0 267 | 268 | 269 | 270 | 271 | True 272 | False 273 | 0 274 | none 275 | 276 | 277 | True 278 | False 279 | 10 280 | 10 281 | 12 282 | 283 | 284 | True 285 | False 286 | 287 | 288 | True 289 | False 290 | 291 | 292 | Additional logging to: 293 | True 294 | True 295 | False 296 | Enable/Disable additional logging 297 | False 298 | True 299 | 300 | 301 | False 302 | True 303 | 2 304 | 0 305 | 306 | 307 | 308 | 309 | True 310 | False 311 | start 312 | 313 | 314 | False 315 | Log folder 316 | select-folder 317 | 318 | 319 | True 320 | True 321 | 2 322 | 0 323 | 324 | 325 | 326 | 327 | False 328 | True 329 | 2 330 | 1 331 | 332 | 333 | 334 | 335 | True 336 | True 337 | 0 338 | 339 | 340 | 341 | 342 | True 343 | False 344 | 345 | 346 | True 347 | True 348 | 1 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | True 358 | False 359 | <b>Custom Logging (restart to apply log changes)</b> 360 | True 361 | 362 | 363 | label_item 364 | 365 | 366 | 367 | 368 | False 369 | True 370 | 1 371 | 372 | 373 | 374 | 375 | 376 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/data/config.glade~: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 5 8 | dialog 9 | select-folder 10 | 11 | 12 | True 13 | False 14 | 2 15 | 16 | 17 | True 18 | False 19 | end 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | False 29 | True 30 | end 31 | 0 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | False 42 | 43 | 44 | True 45 | False 46 | 10 47 | 48 | 49 | True 50 | False 51 | 0 52 | none 53 | 54 | 55 | True 56 | False 57 | 10 58 | 11 59 | 12 60 | 61 | 62 | True 63 | False 64 | 65 | 66 | True 67 | False 68 | 69 | 70 | True 71 | False 72 | Ip Addresses: 73 | 74 | 75 | False 76 | True 77 | 2 78 | 0 79 | 80 | 81 | 82 | 83 | True 84 | True 85 | Comma separated list of ip adresses 86 | 87 | True 88 | False 89 | False 90 | True 91 | True 92 | 93 | 94 | True 95 | True 96 | 2 97 | 1 98 | 99 | 100 | 101 | 102 | False 103 | True 104 | 2 105 | 0 106 | 107 | 108 | 109 | 110 | True 111 | False 112 | 1 113 | 5 114 | 7 115 | eg: 192.168.1.45, 192.168.1.128, 192.168.1.149 116 | True 117 | True 118 | 119 | 120 | False 121 | False 122 | 1 123 | 124 | 125 | 126 | 127 | True 128 | False 129 | 130 | 131 | True 132 | False 133 | Check network status every: 134 | 135 | 136 | False 137 | True 138 | 2 139 | 0 140 | 141 | 142 | 143 | 144 | True 145 | True 146 | Check rate in minutes 147 | 148 | True 149 | False 150 | False 151 | False 152 | True 153 | True 154 | 1 1 1440 1 10 0 155 | True 156 | 157 | 158 | False 159 | True 160 | 2 161 | 1 162 | 163 | 164 | 165 | 166 | True 167 | False 168 | min 169 | 170 | 171 | False 172 | True 173 | 2 174 | 2 175 | 176 | 177 | 178 | 179 | False 180 | True 181 | 10 182 | 2 183 | 184 | 185 | 186 | 187 | 188 | 189 | True 190 | False 191 | 192 | 193 | True 194 | False 195 | Speed when client is active: 196 | 197 | 198 | False 199 | True 200 | 2 201 | 0 202 | 203 | 204 | 205 | 206 | True 207 | True 208 | Download Speed 209 | 210 | True 211 | False 212 | False 213 | False 214 | True 215 | True 216 | 1 1 1440 1 10 0 217 | True 218 | 219 | 220 | False 221 | True 222 | 2 223 | 1 224 | 225 | 226 | 227 | 228 | True 229 | False 230 | KiB/s 231 | 232 | 233 | False 234 | True 235 | 2 236 | 2 237 | 238 | 239 | 240 | 241 | False 242 | True 243 | 10 244 | 2 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | True 254 | False 255 | <b>Settings</b> 256 | True 257 | 258 | 259 | label_item 260 | 261 | 262 | 263 | 264 | False 265 | True 266 | 0 267 | 268 | 269 | 270 | 271 | True 272 | False 273 | 0 274 | none 275 | 276 | 277 | True 278 | False 279 | 10 280 | 10 281 | 12 282 | 283 | 284 | True 285 | False 286 | 287 | 288 | True 289 | False 290 | 291 | 292 | Additional logging to: 293 | True 294 | True 295 | False 296 | Enable/Disable additional logging 297 | False 298 | True 299 | 300 | 301 | False 302 | True 303 | 2 304 | 0 305 | 306 | 307 | 308 | 309 | True 310 | False 311 | start 312 | 313 | 314 | False 315 | Log folder 316 | select-folder 317 | 318 | 319 | True 320 | True 321 | 2 322 | 0 323 | 324 | 325 | 326 | 327 | False 328 | True 329 | 2 330 | 1 331 | 332 | 333 | 334 | 335 | True 336 | True 337 | 0 338 | 339 | 340 | 341 | 342 | True 343 | False 344 | 345 | 346 | True 347 | True 348 | 1 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | True 358 | False 359 | <b>Custom Logging (restart to apply log changes)</b> 360 | True 361 | 362 | 363 | label_item 364 | 365 | 366 | 367 | 368 | False 369 | True 370 | 1 371 | 372 | 373 | 374 | 375 | 376 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/data/netwatcher.js: -------------------------------------------------------------------------------- 1 | /* 2 | Script: netwatcher.js 3 | The client-side javascript code for the NetWatcher plugin. 4 | 5 | Copyright: 6 | (C) Riccardo Poggi 2009 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, write to: 19 | The Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor 21 | Boston, MA 02110-1301, USA. 22 | 23 | In addition, as a special exception, the copyright holders give 24 | permission to link the code of portions of this program with the OpenSSL 25 | library. 26 | You must obey the GNU General Public License in all respects for all of 27 | the code used other than OpenSSL. If you modify file(s) with this 28 | exception, you may extend this exception to your version of the file(s), 29 | but you are not obligated to do so. If you do not wish to do so, delete 30 | this exception statement from your version. If you delete this exception 31 | statement from all source files in the program, then also delete it here. 32 | */ 33 | 34 | NetWatcherPlugin = Ext.extend(Deluge.Plugin, { 35 | constructor: function(config) { 36 | config = Ext.apply({ 37 | name: "NetWatcher" 38 | }, config); 39 | NetWatcherPlugin.superclass.constructor.call(this, config); 40 | }, 41 | 42 | onDisable: function() { 43 | 44 | }, 45 | 46 | onEnable: function() { 47 | 48 | } 49 | }); 50 | new NetWatcherPlugin(); 51 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/gtkui.py: -------------------------------------------------------------------------------- 1 | # 2 | # gtkui.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | import gtk 41 | 42 | from deluge.log import LOG as log 43 | from deluge.ui.client import client 44 | from deluge.plugins.pluginbase import GtkPluginBase 45 | import deluge.component as component 46 | import deluge.common 47 | 48 | from common import get_resource 49 | 50 | class GtkUI(GtkPluginBase): 51 | 52 | def enable(self): 53 | self.glade = gtk.glade.XML(get_resource("config.glade")) 54 | 55 | self.on_show_prefs() 56 | component.get("Preferences").add_page("NetWatcher", self.glade.get_widget("prefs_box")) 57 | 58 | component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs) 59 | component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs) 60 | 61 | def disable(self): 62 | component.get("Preferences").remove_page("NetWatcher") 63 | component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs) 64 | component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs) 65 | 66 | def on_apply_prefs(self): 67 | log.debug("applying prefs for NetWatcher") 68 | config = {} 69 | config["check_rate"] = self.glade.get_widget("spin_check_rate").get_value_as_int() 70 | config["download_rate"] = self.glade.get_widget("spin_dl_rate").get_value_as_int() 71 | config["ip_addresses"] = [addr.strip() for addr in self.glade.get_widget("addresses_entry").get_text().split(',')] 72 | config["custom_log"] = self.glade.get_widget("logging_check_button").get_active() 73 | config["log_dir"] = self.glade.get_widget("custom_logging_path").get_filename() 74 | 75 | client.netwatcher.set_config(config) 76 | 77 | def on_show_prefs(self): 78 | client.netwatcher.get_config().addCallback(self.cb_get_config) 79 | 80 | def cb_get_config(self, config): 81 | "callback for on show_prefs" 82 | self.glade.get_widget("spin_check_rate").set_value(config["check_rate"]) 83 | self.glade.get_widget("spin_dl_rate").set_value(config["download_rate"]) 84 | self.glade.get_widget("addresses_entry").set_text(', '.join(config["ip_addresses"])) 85 | self.glade.get_widget("logging_check_button").set_active(config["custom_log"]) 86 | self.glade.get_widget("custom_logging_path").set_filename(config["log_dir"]) 87 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher/webui.py: -------------------------------------------------------------------------------- 1 | # 2 | # webui.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.ui.client import client 42 | from deluge import component 43 | from deluge.plugins.pluginbase import WebPluginBase 44 | 45 | from common import get_resource 46 | 47 | class WebUI(WebPluginBase): 48 | 49 | scripts = [get_resource("netwatcher.js")] 50 | 51 | def enable(self): 52 | pass 53 | 54 | def disable(self): 55 | pass 56 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # __init__.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.plugins.init import PluginInitBase 41 | 42 | class CorePlugin(PluginInitBase): 43 | def __init__(self, plugin_name): 44 | from core import Core as _plugin_cls 45 | self._plugin_cls = _plugin_cls 46 | super(CorePlugin, self).__init__(plugin_name) 47 | 48 | class GtkUIPlugin(PluginInitBase): 49 | def __init__(self, plugin_name): 50 | from gtkui import GtkUI as _plugin_cls 51 | self._plugin_cls = _plugin_cls 52 | super(GtkUIPlugin, self).__init__(plugin_name) 53 | 54 | class WebUIPlugin(PluginInitBase): 55 | def __init__(self, plugin_name): 56 | from webui import WebUI as _plugin_cls 57 | self._plugin_cls = _plugin_cls 58 | super(WebUIPlugin, self).__init__(plugin_name) 59 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/common.py: -------------------------------------------------------------------------------- 1 | # 2 | # common.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | def get_resource(filename): 41 | import pkg_resources, os 42 | return pkg_resources.resource_filename("netwatcher2", os.path.join("data", filename)) -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/core.py: -------------------------------------------------------------------------------- 1 | # 2 | # core.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.plugins.pluginbase import CorePluginBase 42 | import deluge.component as component 43 | import deluge.configmanager 44 | from deluge.core.rpcserver import export 45 | from twisted.internet import reactor, utils, defer 46 | 47 | import os.path 48 | 49 | 50 | DEFAULT_PREFS = { 51 | "ip_addresses": [], 52 | "download_rate": 125, 53 | "check_rate": 5, # minutes 54 | "custom_log": False, 55 | "log_dir": os.path.expanduser('~'), 56 | } 57 | 58 | 59 | # custom logging 60 | import logging 61 | logger = logging.getLogger("NetWatcher2") 62 | logger.parent = 0 63 | logger.setLevel(logging.INFO) 64 | config = deluge.configmanager.ConfigManager("netwatcher2.conf", 65 | DEFAULT_PREFS) 66 | dlspeed = config["download_rate"] 67 | 68 | result = [] 69 | 70 | class Core(CorePluginBase): 71 | 72 | def enable(self): 73 | self.config = deluge.configmanager.ConfigManager("netwatcher2.conf", 74 | DEFAULT_PREFS) 75 | dlspeed = self.config["download_rate"] 76 | if self.config["custom_log"]: 77 | #TODO: The changes are applied at startup, so there's need for 78 | # a restart in order to log correctly 79 | file_path = os.path.join(self.config["log_dir"], 'netwatcher2_log.txt') 80 | fh = logging.FileHandler(file_path) 81 | fh.setLevel(logging.INFO) 82 | formatter = logging.Formatter("[%(asctime)s] %(message)s", 83 | datefmt="%b-%d %H:%M") 84 | fh.setFormatter(formatter) 85 | logger.addHandler(fh) 86 | 87 | else: 88 | logger.addHandler(logging.NullHandler()) 89 | 90 | logger.info('\n \n## Starting New Session ##') 91 | 92 | result = 1 93 | self.do_schedule() 94 | 95 | def disable(self): 96 | self.timer.cancel() 97 | 98 | def update(self): 99 | pass 100 | 101 | @staticmethod 102 | def regulate_torrents(scan_result): 103 | """Resume/Pause all torrents if `scan_result` is 'Free'/'Busy'.""" 104 | logger.info('## Updating ##') 105 | global result 106 | for torrent in component.get("Core").torrentmanager.torrents.values(): 107 | # empty keys -> full status 108 | if scan_result == 'Busy' and torrent.options["auto_managed"]: 109 | limit = (dlspeed) 110 | torrent.set_max_download_speed(limit) 111 | 112 | elif scan_result == 'Free' and torrent.options["auto_managed"]: 113 | limit = -1 114 | torrent.set_max_download_speed(limit) 115 | if scan_result == 'Busy' and result==0: 116 | logger.info('## Speed Limit Activated ##') 117 | result = 1 118 | elif scan_result == 'Free' and result==1: 119 | logger.info('## Speed Limit DeActivated ##') 120 | result = 0 121 | def do_schedule(self, timer=True): 122 | """Schedule of network scan and subsequent torrent regulation.""" 123 | d = self._quick_scan() 124 | d.addCallback(self.regulate_torrents) 125 | 126 | if timer: 127 | self.timer = reactor.callLater(self.config["check_rate"] * 60, 128 | self.do_schedule) 129 | 130 | def _quick_scan(self): 131 | """Return 'Busy' if any of the known addresses is alive, 'Free' 132 | otherwise. 133 | 134 | The scan is performed through ping requests. 135 | 136 | """ 137 | # Ping exit codes: 138 | # 0 - the address is alive (online) 139 | # 1 - the address is not alive (offline) 140 | # 2 - an error occured 141 | log.debug("spawning ping requests to all known addresses..") 142 | options = "{} -c1 -w1 -q" 143 | outputs = [utils.getProcessValue("ping", options.format(addr).split()) 144 | for addr in self.config["ip_addresses"]] 145 | 146 | # XXX: the following two lines will shadow ping errors (exit == 2) 147 | d = defer.gatherResults(outputs) 148 | d.addCallback(lambda x: 'Free' if all(x) else 'Busy') 149 | 150 | return d 151 | 152 | 153 | @export 154 | def set_config(self, config): 155 | """Sets the config dictionary""" 156 | for key in config.keys(): 157 | self.config[key] = config[key] 158 | self.config.save() 159 | 160 | self.timer.cancel() 161 | self.do_schedule() 162 | logger.info('## Setting Config ##') 163 | self.update() 164 | 165 | @export 166 | def get_config(self): 167 | """Returns the config dictionary""" 168 | return self.config.config 169 | self.update() -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/data/config.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 5 8 | dialog 9 | select-folder 10 | 11 | 12 | True 13 | False 14 | 2 15 | 16 | 17 | True 18 | False 19 | end 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | False 29 | True 30 | end 31 | 0 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | False 42 | 43 | 44 | True 45 | False 46 | 10 47 | 48 | 49 | True 50 | False 51 | 0 52 | none 53 | 54 | 55 | True 56 | False 57 | 10 58 | 11 59 | 12 60 | 61 | 62 | True 63 | False 64 | 65 | 66 | True 67 | False 68 | 69 | 70 | True 71 | False 72 | Ip Addresses: 73 | 74 | 75 | False 76 | True 77 | 2 78 | 0 79 | 80 | 81 | 82 | 83 | True 84 | True 85 | Comma separated list of ip adresses 86 | 87 | True 88 | False 89 | False 90 | True 91 | True 92 | 93 | 94 | True 95 | True 96 | 2 97 | 1 98 | 99 | 100 | 101 | 102 | False 103 | True 104 | 2 105 | 0 106 | 107 | 108 | 109 | 110 | True 111 | False 112 | 1 113 | 5 114 | 7 115 | eg: 192.168.1.45, 192.168.1.128, 192.168.1.149 116 | True 117 | True 118 | 119 | 120 | False 121 | False 122 | 1 123 | 124 | 125 | 126 | 127 | True 128 | False 129 | 130 | 131 | True 132 | False 133 | Check network status every: 134 | 135 | 136 | False 137 | True 138 | 2 139 | 0 140 | 141 | 142 | 143 | 144 | True 145 | True 146 | Check rate in minutes 147 | 148 | True 149 | False 150 | False 151 | False 152 | True 153 | True 154 | 1 1 1440 1 10 0 155 | True 156 | 157 | 158 | False 159 | True 160 | 2 161 | 1 162 | 163 | 164 | 165 | 166 | True 167 | False 168 | min 169 | 170 | 171 | False 172 | True 173 | 2 174 | 2 175 | 176 | 177 | 178 | 179 | False 180 | True 181 | 10 182 | 2 183 | 184 | 185 | 186 | 187 | 188 | 189 | True 190 | False 191 | 192 | 193 | True 194 | False 195 | Speed when client is active: 196 | 197 | 198 | False 199 | True 200 | 2 201 | 0 202 | 203 | 204 | 205 | 206 | True 207 | True 208 | Download Speed 209 | 210 | True 211 | False 212 | False 213 | False 214 | True 215 | True 216 | 1 1 1440 1 10 0 217 | True 218 | 219 | 220 | False 221 | True 222 | 2 223 | 1 224 | 225 | 226 | 227 | 228 | True 229 | False 230 | KiB/s 231 | 232 | 233 | False 234 | True 235 | 2 236 | 2 237 | 238 | 239 | 240 | 241 | False 242 | True 243 | 10 244 | 2 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | True 254 | False 255 | <b>Settings</b> 256 | True 257 | 258 | 259 | label_item 260 | 261 | 262 | 263 | 264 | False 265 | True 266 | 0 267 | 268 | 269 | 270 | 271 | True 272 | False 273 | 0 274 | none 275 | 276 | 277 | True 278 | False 279 | 10 280 | 10 281 | 12 282 | 283 | 284 | True 285 | False 286 | 287 | 288 | True 289 | False 290 | 291 | 292 | Additional logging to: 293 | True 294 | True 295 | False 296 | Enable/Disable additional logging 297 | False 298 | True 299 | 300 | 301 | False 302 | True 303 | 2 304 | 0 305 | 306 | 307 | 308 | 309 | True 310 | False 311 | start 312 | 313 | 314 | False 315 | Log folder 316 | select-folder 317 | 318 | 319 | True 320 | True 321 | 2 322 | 0 323 | 324 | 325 | 326 | 327 | False 328 | True 329 | 2 330 | 1 331 | 332 | 333 | 334 | 335 | True 336 | True 337 | 0 338 | 339 | 340 | 341 | 342 | True 343 | False 344 | 345 | 346 | True 347 | True 348 | 1 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | True 358 | False 359 | <b>Custom Logging (restart to apply log changes)</b> 360 | True 361 | 362 | 363 | label_item 364 | 365 | 366 | 367 | 368 | False 369 | True 370 | 1 371 | 372 | 373 | 374 | 375 | 376 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/data/netwatcher.js: -------------------------------------------------------------------------------- 1 | /* 2 | Script: netwatcher.js 3 | The client-side javascript code for the NetWatcher plugin. 4 | 5 | Copyright: 6 | (C) Riccardo Poggi 2009 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, write to: 19 | The Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor 21 | Boston, MA 02110-1301, USA. 22 | 23 | In addition, as a special exception, the copyright holders give 24 | permission to link the code of portions of this program with the OpenSSL 25 | library. 26 | You must obey the GNU General Public License in all respects for all of 27 | the code used other than OpenSSL. If you modify file(s) with this 28 | exception, you may extend this exception to your version of the file(s), 29 | but you are not obligated to do so. If you do not wish to do so, delete 30 | this exception statement from your version. If you delete this exception 31 | statement from all source files in the program, then also delete it here. 32 | */ 33 | 34 | NetWatcherPlugin = Ext.extend(Deluge.Plugin, { 35 | constructor: function(config) { 36 | config = Ext.apply({ 37 | name: "NetWatcher2" 38 | }, config); 39 | NetWatcherPlugin.superclass.constructor.call(this, config); 40 | }, 41 | 42 | onDisable: function() { 43 | 44 | }, 45 | 46 | onEnable: function() { 47 | 48 | } 49 | }); 50 | new NetWatcherPlugin(); -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/data/netwatcher.js~: -------------------------------------------------------------------------------- 1 | /* 2 | Script: netwatcher.js 3 | The client-side javascript code for the NetWatcher plugin. 4 | 5 | Copyright: 6 | (C) Riccardo Poggi 2009 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, write to: 19 | The Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor 21 | Boston, MA 02110-1301, USA. 22 | 23 | In addition, as a special exception, the copyright holders give 24 | permission to link the code of portions of this program with the OpenSSL 25 | library. 26 | You must obey the GNU General Public License in all respects for all of 27 | the code used other than OpenSSL. If you modify file(s) with this 28 | exception, you may extend this exception to your version of the file(s), 29 | but you are not obligated to do so. If you do not wish to do so, delete 30 | this exception statement from your version. If you delete this exception 31 | statement from all source files in the program, then also delete it here. 32 | */ 33 | 34 | NetWatcherPlugin = Ext.extend(Deluge.Plugin, { 35 | constructor: function(config) { 36 | config = Ext.apply({ 37 | name: "NetWatcher" 38 | }, config); 39 | NetWatcherPlugin.superclass.constructor.call(this, config); 40 | }, 41 | 42 | onDisable: function() { 43 | 44 | }, 45 | 46 | onEnable: function() { 47 | 48 | } 49 | }); 50 | new NetWatcherPlugin(); 51 | -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/gtkui.py: -------------------------------------------------------------------------------- 1 | # 2 | # gtkui.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | import gtk 41 | 42 | from deluge.log import LOG as log 43 | from deluge.ui.client import client 44 | from deluge.plugins.pluginbase import GtkPluginBase 45 | import deluge.component as component 46 | import deluge.common 47 | 48 | from common import get_resource 49 | 50 | class GtkUI(GtkPluginBase): 51 | 52 | def enable(self): 53 | self.glade = gtk.glade.XML(get_resource("config.glade")) 54 | 55 | self.on_show_prefs() 56 | component.get("Preferences").add_page("NetWatcher2", self.glade.get_widget("prefs_box")) 57 | 58 | component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs) 59 | component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs) 60 | 61 | def disable(self): 62 | component.get("Preferences").remove_page("NetWatcher2") 63 | component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs) 64 | component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs) 65 | 66 | def on_apply_prefs(self): 67 | log.debug("applying prefs for NetWatcher2") 68 | config = {} 69 | config["check_rate"] = self.glade.get_widget("spin_check_rate").get_value_as_int() 70 | config["download_rate"] = self.glade.get_widget("spin_dl_rate").get_value_as_int() 71 | config["ip_addresses"] = [addr.strip() for addr in self.glade.get_widget("addresses_entry").get_text().split(',')] 72 | config["custom_log"] = self.glade.get_widget("logging_check_button").get_active() 73 | config["log_dir"] = self.glade.get_widget("custom_logging_path").get_filename() 74 | 75 | client.netwatcher2.set_config(config) 76 | 77 | def on_show_prefs(self): 78 | client.netwatcher2.get_config().addCallback(self.cb_get_config) 79 | 80 | def cb_get_config(self, config): 81 | "callback for on show_prefs" 82 | self.glade.get_widget("spin_check_rate").set_value(config["check_rate"]) 83 | self.glade.get_widget("spin_dl_rate").set_value(config["download_rate"]) 84 | self.glade.get_widget("addresses_entry").set_text(', '.join(config["ip_addresses"])) 85 | self.glade.get_widget("logging_check_button").set_active(config["custom_log"]) 86 | self.glade.get_widget("custom_logging_path").set_filename(config["log_dir"]) -------------------------------------------------------------------------------- /build/lib.linux-x86_64-2.7/netwatcher2/webui.py: -------------------------------------------------------------------------------- 1 | # 2 | # webui.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.ui.client import client 42 | from deluge import component 43 | from deluge.plugins.pluginbase import WebPluginBase 44 | 45 | from common import get_resource 46 | 47 | class WebUI(WebPluginBase): 48 | 49 | scripts = [get_resource("netwatcher.js")] 50 | 51 | def enable(self): 52 | pass 53 | 54 | def disable(self): 55 | pass 56 | -------------------------------------------------------------------------------- /dist/NetWatcher-0.1-py2.7.egg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/morgenman/NetWatcher2/faad289cbfb560b7bab93b2ae560cca55986e941/dist/NetWatcher-0.1-py2.7.egg -------------------------------------------------------------------------------- /dist/NetWatcher2-0.2-py2.7.egg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/morgenman/NetWatcher2/faad289cbfb560b7bab93b2ae560cca55986e941/dist/NetWatcher2-0.2-py2.7.egg -------------------------------------------------------------------------------- /dist/NetWatcher2-0.2.01-py2.7.egg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/morgenman/NetWatcher2/faad289cbfb560b7bab93b2ae560cca55986e941/dist/NetWatcher2-0.2.01-py2.7.egg -------------------------------------------------------------------------------- /netwatcher2/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # __init__.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.plugins.init import PluginInitBase 41 | 42 | class CorePlugin(PluginInitBase): 43 | def __init__(self, plugin_name): 44 | from core import Core as _plugin_cls 45 | self._plugin_cls = _plugin_cls 46 | super(CorePlugin, self).__init__(plugin_name) 47 | 48 | class GtkUIPlugin(PluginInitBase): 49 | def __init__(self, plugin_name): 50 | from gtkui import GtkUI as _plugin_cls 51 | self._plugin_cls = _plugin_cls 52 | super(GtkUIPlugin, self).__init__(plugin_name) 53 | 54 | class WebUIPlugin(PluginInitBase): 55 | def __init__(self, plugin_name): 56 | from webui import WebUI as _plugin_cls 57 | self._plugin_cls = _plugin_cls 58 | super(WebUIPlugin, self).__init__(plugin_name) 59 | -------------------------------------------------------------------------------- /netwatcher2/common.py: -------------------------------------------------------------------------------- 1 | # 2 | # common.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | def get_resource(filename): 41 | import pkg_resources, os 42 | return pkg_resources.resource_filename("netwatcher2", os.path.join("data", filename)) -------------------------------------------------------------------------------- /netwatcher2/core.py: -------------------------------------------------------------------------------- 1 | # 2 | # core.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.plugins.pluginbase import CorePluginBase 42 | import deluge.component as component 43 | import deluge.configmanager 44 | from deluge.core.rpcserver import export 45 | from twisted.internet import reactor, utils, defer 46 | 47 | import os.path 48 | 49 | 50 | DEFAULT_PREFS = { 51 | "ip_addresses": [], 52 | "download_rate": 125, 53 | "check_rate": 5, # minutes 54 | "custom_log": False, 55 | "log_dir": os.path.expanduser('~'), 56 | } 57 | 58 | 59 | # custom logging 60 | import logging 61 | logger = logging.getLogger("NetWatcher2") 62 | logger.parent = 0 63 | logger.setLevel(logging.INFO) 64 | config = deluge.configmanager.ConfigManager("netwatcher2.conf", 65 | DEFAULT_PREFS) 66 | dlspeed = config["download_rate"] 67 | 68 | result = [] 69 | 70 | class Core(CorePluginBase): 71 | 72 | def enable(self): 73 | self.config = deluge.configmanager.ConfigManager("netwatcher2.conf", 74 | DEFAULT_PREFS) 75 | dlspeed = self.config["download_rate"] 76 | if self.config["custom_log"]: 77 | #TODO: The changes are applied at startup, so there's need for 78 | # a restart in order to log correctly 79 | file_path = os.path.join(self.config["log_dir"], 'netwatcher2_log.txt') 80 | fh = logging.FileHandler(file_path) 81 | fh.setLevel(logging.INFO) 82 | formatter = logging.Formatter("[%(asctime)s] %(message)s", 83 | datefmt="%b-%d %H:%M") 84 | fh.setFormatter(formatter) 85 | logger.addHandler(fh) 86 | 87 | else: 88 | logger.addHandler(logging.NullHandler()) 89 | 90 | logger.info('\n \n## Starting New Session ##') 91 | 92 | result = 1 93 | self.do_schedule() 94 | 95 | def disable(self): 96 | self.timer.cancel() 97 | 98 | def update(self): 99 | pass 100 | 101 | @staticmethod 102 | def regulate_torrents(scan_result): 103 | """Resume/Pause all torrents if `scan_result` is 'Free'/'Busy'.""" 104 | logger.info('## Updating ##') 105 | global result 106 | for torrent in component.get("Core").torrentmanager.torrents.values(): 107 | # empty keys -> full status 108 | if scan_result == 'Busy' and torrent.options["auto_managed"]: 109 | limit = (dlspeed) 110 | torrent.set_max_download_speed(limit) 111 | 112 | elif scan_result == 'Free' and torrent.options["auto_managed"]: 113 | limit = -1 114 | torrent.set_max_download_speed(limit) 115 | if scan_result == 'Busy' and result==0: 116 | logger.info('## Speed Limit Activated ##') 117 | result = 1 118 | elif scan_result == 'Free' and result==1: 119 | logger.info('## Speed Limit DeActivated ##') 120 | result = 0 121 | def do_schedule(self, timer=True): 122 | """Schedule of network scan and subsequent torrent regulation.""" 123 | d = self._quick_scan() 124 | d.addCallback(self.regulate_torrents) 125 | 126 | if timer: 127 | self.timer = reactor.callLater(self.config["check_rate"] * 60, 128 | self.do_schedule) 129 | 130 | def _quick_scan(self): 131 | """Return 'Busy' if any of the known addresses is alive, 'Free' 132 | otherwise. 133 | 134 | The scan is performed through ping requests. 135 | 136 | """ 137 | # Ping exit codes: 138 | # 0 - the address is alive (online) 139 | # 1 - the address is not alive (offline) 140 | # 2 - an error occured 141 | log.debug("spawning ping requests to all known addresses..") 142 | options = "{} -c1 -w1 -q" 143 | outputs = [utils.getProcessValue("ping", options.format(addr).split()) 144 | for addr in self.config["ip_addresses"]] 145 | 146 | # XXX: the following two lines will shadow ping errors (exit == 2) 147 | d = defer.gatherResults(outputs) 148 | d.addCallback(lambda x: 'Free' if all(x) else 'Busy') 149 | 150 | return d 151 | 152 | 153 | @export 154 | def set_config(self, config): 155 | """Sets the config dictionary""" 156 | for key in config.keys(): 157 | self.config[key] = config[key] 158 | self.config.save() 159 | 160 | self.timer.cancel() 161 | self.do_schedule() 162 | logger.info('## Setting Config ##') 163 | self.update() 164 | 165 | @export 166 | def get_config(self): 167 | """Returns the config dictionary""" 168 | return self.config.config 169 | self.update() -------------------------------------------------------------------------------- /netwatcher2/data/config.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 5 8 | dialog 9 | select-folder 10 | 11 | 12 | True 13 | False 14 | 2 15 | 16 | 17 | True 18 | False 19 | end 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | False 29 | True 30 | end 31 | 0 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | False 42 | 43 | 44 | True 45 | False 46 | 10 47 | 48 | 49 | True 50 | False 51 | 0 52 | none 53 | 54 | 55 | True 56 | False 57 | 10 58 | 11 59 | 12 60 | 61 | 62 | True 63 | False 64 | 65 | 66 | True 67 | False 68 | 69 | 70 | True 71 | False 72 | Ip Addresses: 73 | 74 | 75 | False 76 | True 77 | 2 78 | 0 79 | 80 | 81 | 82 | 83 | True 84 | True 85 | Comma separated list of ip adresses 86 | 87 | True 88 | False 89 | False 90 | True 91 | True 92 | 93 | 94 | True 95 | True 96 | 2 97 | 1 98 | 99 | 100 | 101 | 102 | False 103 | True 104 | 2 105 | 0 106 | 107 | 108 | 109 | 110 | True 111 | False 112 | 1 113 | 5 114 | 7 115 | eg: 192.168.1.45, 192.168.1.128, 192.168.1.149 116 | True 117 | True 118 | 119 | 120 | False 121 | False 122 | 1 123 | 124 | 125 | 126 | 127 | True 128 | False 129 | 130 | 131 | True 132 | False 133 | Check network status every: 134 | 135 | 136 | False 137 | True 138 | 2 139 | 0 140 | 141 | 142 | 143 | 144 | True 145 | True 146 | Check rate in minutes 147 | 148 | True 149 | False 150 | False 151 | False 152 | True 153 | True 154 | 1 1 1440 1 10 0 155 | True 156 | 157 | 158 | False 159 | True 160 | 2 161 | 1 162 | 163 | 164 | 165 | 166 | True 167 | False 168 | min 169 | 170 | 171 | False 172 | True 173 | 2 174 | 2 175 | 176 | 177 | 178 | 179 | False 180 | True 181 | 10 182 | 2 183 | 184 | 185 | 186 | 187 | 188 | 189 | True 190 | False 191 | 192 | 193 | True 194 | False 195 | Speed when client is active: 196 | 197 | 198 | False 199 | True 200 | 2 201 | 0 202 | 203 | 204 | 205 | 206 | True 207 | True 208 | Download Speed 209 | 210 | True 211 | False 212 | False 213 | False 214 | True 215 | True 216 | 1 1 1440 1 10 0 217 | True 218 | 219 | 220 | False 221 | True 222 | 2 223 | 1 224 | 225 | 226 | 227 | 228 | True 229 | False 230 | KiB/s 231 | 232 | 233 | False 234 | True 235 | 2 236 | 2 237 | 238 | 239 | 240 | 241 | False 242 | True 243 | 10 244 | 2 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | True 254 | False 255 | <b>Settings</b> 256 | True 257 | 258 | 259 | label_item 260 | 261 | 262 | 263 | 264 | False 265 | True 266 | 0 267 | 268 | 269 | 270 | 271 | True 272 | False 273 | 0 274 | none 275 | 276 | 277 | True 278 | False 279 | 10 280 | 10 281 | 12 282 | 283 | 284 | True 285 | False 286 | 287 | 288 | True 289 | False 290 | 291 | 292 | Additional logging to: 293 | True 294 | True 295 | False 296 | Enable/Disable additional logging 297 | False 298 | True 299 | 300 | 301 | False 302 | True 303 | 2 304 | 0 305 | 306 | 307 | 308 | 309 | True 310 | False 311 | start 312 | 313 | 314 | False 315 | Log folder 316 | select-folder 317 | 318 | 319 | True 320 | True 321 | 2 322 | 0 323 | 324 | 325 | 326 | 327 | False 328 | True 329 | 2 330 | 1 331 | 332 | 333 | 334 | 335 | True 336 | True 337 | 0 338 | 339 | 340 | 341 | 342 | True 343 | False 344 | 345 | 346 | True 347 | True 348 | 1 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | True 358 | False 359 | <b>Custom Logging (restart to apply log changes)</b> 360 | True 361 | 362 | 363 | label_item 364 | 365 | 366 | 367 | 368 | False 369 | True 370 | 1 371 | 372 | 373 | 374 | 375 | 376 | -------------------------------------------------------------------------------- /netwatcher2/data/netwatcher.js: -------------------------------------------------------------------------------- 1 | /* 2 | Script: netwatcher.js 3 | The client-side javascript code for the NetWatcher plugin. 4 | 5 | Copyright: 6 | (C) Riccardo Poggi 2009 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, write to: 19 | The Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor 21 | Boston, MA 02110-1301, USA. 22 | 23 | In addition, as a special exception, the copyright holders give 24 | permission to link the code of portions of this program with the OpenSSL 25 | library. 26 | You must obey the GNU General Public License in all respects for all of 27 | the code used other than OpenSSL. If you modify file(s) with this 28 | exception, you may extend this exception to your version of the file(s), 29 | but you are not obligated to do so. If you do not wish to do so, delete 30 | this exception statement from your version. If you delete this exception 31 | statement from all source files in the program, then also delete it here. 32 | */ 33 | 34 | NetWatcherPlugin = Ext.extend(Deluge.Plugin, { 35 | constructor: function(config) { 36 | config = Ext.apply({ 37 | name: "NetWatcher2" 38 | }, config); 39 | NetWatcherPlugin.superclass.constructor.call(this, config); 40 | }, 41 | 42 | onDisable: function() { 43 | 44 | }, 45 | 46 | onEnable: function() { 47 | 48 | } 49 | }); 50 | new NetWatcherPlugin(); -------------------------------------------------------------------------------- /netwatcher2/gtkui.py: -------------------------------------------------------------------------------- 1 | # 2 | # gtkui.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | import gtk 41 | 42 | from deluge.log import LOG as log 43 | from deluge.ui.client import client 44 | from deluge.plugins.pluginbase import GtkPluginBase 45 | import deluge.component as component 46 | import deluge.common 47 | 48 | from common import get_resource 49 | 50 | class GtkUI(GtkPluginBase): 51 | 52 | def enable(self): 53 | self.glade = gtk.glade.XML(get_resource("config.glade")) 54 | 55 | self.on_show_prefs() 56 | component.get("Preferences").add_page("NetWatcher2", self.glade.get_widget("prefs_box")) 57 | 58 | component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs) 59 | component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs) 60 | 61 | def disable(self): 62 | component.get("Preferences").remove_page("NetWatcher2") 63 | component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs) 64 | component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs) 65 | 66 | def on_apply_prefs(self): 67 | log.debug("applying prefs for NetWatcher2") 68 | config = {} 69 | config["check_rate"] = self.glade.get_widget("spin_check_rate").get_value_as_int() 70 | config["download_rate"] = self.glade.get_widget("spin_dl_rate").get_value_as_int() 71 | config["ip_addresses"] = [addr.strip() for addr in self.glade.get_widget("addresses_entry").get_text().split(',')] 72 | config["custom_log"] = self.glade.get_widget("logging_check_button").get_active() 73 | config["log_dir"] = self.glade.get_widget("custom_logging_path").get_filename() 74 | 75 | client.netwatcher2.set_config(config) 76 | 77 | def on_show_prefs(self): 78 | client.netwatcher2.get_config().addCallback(self.cb_get_config) 79 | 80 | def cb_get_config(self, config): 81 | "callback for on show_prefs" 82 | self.glade.get_widget("spin_check_rate").set_value(config["check_rate"]) 83 | self.glade.get_widget("spin_dl_rate").set_value(config["download_rate"]) 84 | self.glade.get_widget("addresses_entry").set_text(', '.join(config["ip_addresses"])) 85 | self.glade.get_widget("logging_check_button").set_active(config["custom_log"]) 86 | self.glade.get_widget("custom_logging_path").set_filename(config["log_dir"]) -------------------------------------------------------------------------------- /netwatcher2/webui.py: -------------------------------------------------------------------------------- 1 | # 2 | # webui.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.ui.client import client 42 | from deluge import component 43 | from deluge.plugins.pluginbase import WebPluginBase 44 | 45 | from common import get_resource 46 | 47 | class WebUI(WebPluginBase): 48 | 49 | scripts = [get_resource("netwatcher.js")] 50 | 51 | def enable(self): 52 | pass 53 | 54 | def disable(self): 55 | pass 56 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # 2 | # setup.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from setuptools import setup 41 | 42 | __plugin_name__ = "NetWatcher2" 43 | __author__ = "Cole Morgen (originally from Riccardo Poggi)" 44 | __author_email__ = "morgenman@gmail.com" 45 | __version__ = "0.2.01" 46 | __url__ = "" 47 | __license__ = "GPLv3" 48 | __description__ = "" 49 | __long_description__ = """""" 50 | __pkg_data__ = {__plugin_name__.lower(): ["template/*", "data/*"]} 51 | 52 | setup( 53 | name=__plugin_name__, 54 | version=__version__, 55 | description=__description__, 56 | author=__author__, 57 | author_email=__author_email__, 58 | url=__url__, 59 | license=__license__, 60 | long_description=__long_description__ if __long_description__ else __description__, 61 | 62 | packages=[__plugin_name__.lower()], 63 | package_data = __pkg_data__, 64 | 65 | entry_points=""" 66 | [deluge.plugin.core] 67 | %s = %s:CorePlugin 68 | [deluge.plugin.gtkui] 69 | %s = %s:GtkUIPlugin 70 | [deluge.plugin.web] 71 | %s = %s:WebUIPlugin 72 | """ % ((__plugin_name__, __plugin_name__.lower())*3) 73 | ) -------------------------------------------------------------------------------- /setup.py~: -------------------------------------------------------------------------------- 1 | # 2 | # setup.py 3 | # 4 | # Copyright (C) 2009 Riccardo Poggi 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from setuptools import setup 41 | 42 | __plugin_name__ = "NetWatcher2" 43 | __author__ = "Cole Morgen (originally from Riccardo Poggi)" 44 | __author_email__ = "morgenman@gmail.com" 45 | __version__ = "0.2" 46 | __url__ = "" 47 | __license__ = "GPLv3" 48 | __description__ = "" 49 | __long_description__ = """""" 50 | __pkg_data__ = {__plugin_name__.lower(): ["template/*", "data/*"]} 51 | 52 | setup( 53 | name=__plugin_name__, 54 | version=__version__, 55 | description=__description__, 56 | author=__author__, 57 | author_email=__author_email__, 58 | url=__url__, 59 | license=__license__, 60 | long_description=__long_description__ if __long_description__ else __description__, 61 | 62 | packages=[__plugin_name__.lower()], 63 | package_data = __pkg_data__, 64 | 65 | entry_points=""" 66 | [deluge.plugin.core] 67 | %s = %s:CorePlugin 68 | [deluge.plugin.gtkui] 69 | %s = %s:GtkUIPlugin 70 | [deluge.plugin.web] 71 | %s = %s:WebUIPlugin 72 | """ % ((__plugin_name__, __plugin_name__.lower())*3) 73 | ) --------------------------------------------------------------------------------