diff options
author | Nitzo <nitzo2001@yahoo.com> | 2016-01-08 18:12:34 +0100 |
---|---|---|
committer | Nitzo <nitzo2001@yahoo.com> | 2016-01-08 18:12:34 +0100 |
commit | 09df5bc5047244c34ca2cddaffcdf09f07be7c21 (patch) | |
tree | 2c19f0833df58bf8643a7ad2257dc219e35acf61 /module/plugins/hooks | |
parent | [ClickNLoad] Update (diff) | |
download | pyload-09df5bc5047244c34ca2cddaffcdf09f07be7c21.tar.xz |
[ClickNLoad] Update
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r-- | module/plugins/hooks/ClickNLoad.py | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/module/plugins/hooks/ClickNLoad.py b/module/plugins/hooks/ClickNLoad.py index 443b3325f..81c630f93 100644 --- a/module/plugins/hooks/ClickNLoad.py +++ b/module/plugins/hooks/ClickNLoad.py @@ -17,7 +17,7 @@ from module.plugins.internal.misc import forward, lock class ClickNLoad(Addon): __name__ = "ClickNLoad" __type__ = "hook" - __version__ = "0.55" + __version__ = "0.56" __status__ = "testing" __config__ = [("activated", "bool" , "Activated" , True ), @@ -52,24 +52,12 @@ class ClickNLoad(Addon): self.pyload.scheduler.addJob(5, self.proxy, threaded=False) + def deactivate(self): + self._shutdown() + + def exit(self): - if self.server_running: - self.log_info(_("Shutting down proxy...")) - - self.do_exit = True - - try: - wakeup_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - wakeup_socket.connect(("127.0.0.1" if any(_ip == self.cnl_ip for _ip in ("0.0.0.0", "")) else self.cnl_ip, self.cnl_port)) - wakeup_socket.close() - except Exception: - pass - - success_exit = self.exit_done.wait(10) - if success_exit: - self.log_debug(_("Server exited successfully")) - else: - self.log_warning(_("Server was not exited gracefully, shutdown forced")) + self._shutdown() @lock @@ -133,6 +121,7 @@ class ClickNLoad(Addon): break dock_socket.close() + self.server_running = False self.exit_done.set() except socket.timeout: @@ -143,3 +132,23 @@ class ClickNLoad(Addon): self.log_error(e) time.sleep(240) return self._server() + + + def _shutdown(self): + if self.server_running: + self.log_info(_("Shutting down proxy...")) + + self.do_exit = True + + try: + wakeup_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + wakeup_socket.connect(("127.0.0.1" if any(_ip == self.cnl_ip for _ip in ("0.0.0.0", "")) else self.cnl_ip, self.cnl_port)) + wakeup_socket.close() + except Exception: + pass + + success_exit = self.exit_done.wait(10) + if success_exit: + self.log_debug(_("Server exited successfully")) + else: + self.log_warning(_("Server was not exited gracefully, shutdown forced")) |