diff options
author | mkaay <mkaay@mkaay.de> | 2010-01-04 20:35:26 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-01-04 20:35:26 +0100 |
commit | 89acc0ff595f73956572c8892ccb860c06fba33a (patch) | |
tree | 6edad5f8e0ca153b186a182b63aa5a5de815fe05 /module/plugins/hooks | |
parent | fixed webserver (diff) | |
download | pyload-89acc0ff595f73956572c8892ccb860c06fba33a.tar.xz |
added hook system
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r-- | module/plugins/hooks/ContainerDownload.py | 42 | ||||
-rw-r--r-- | module/plugins/hooks/Hook.py | 51 | ||||
-rw-r--r-- | module/plugins/hooks/__init__.py | 1 |
3 files changed, 94 insertions, 0 deletions
diff --git a/module/plugins/hooks/ContainerDownload.py b/module/plugins/hooks/ContainerDownload.py new file mode 100644 index 000000000..d031cdf69 --- /dev/null +++ b/module/plugins/hooks/ContainerDownload.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: mkaay + @interface-version: 0.1 +""" + +from module.plugins.hooks.Hook import Hook + +from os.path import join, abspath + +class ContainerDownload(Hook): + def __init__(self, core): + Hook.__init__(self, core) + props = {} + props['name'] = "ContainerDownload" + props['version'] = "0.1" + props['description'] = """add the downloaded container to current package""" + props['author_name'] = ("mkaay") + props['author_mail'] = ("mkaay@mkaay.de") + self.props = props + + def downloadFinished(self, pyfile): + filename = pyfile.status.filename + if filename.endswith(".dlc") or filename.endswith(".ccf") or filename.endswith(".rsdf"): + self.logger.info("ContainerDownload hook: adding container file") + location = abspath(join(pyfile.folder, filename)) + newFile = self.core.file_list.collector.addLink(location) + self.core.file_list.packager.addFileToPackage(pyfile.package.data["id"], self.core.file_list.collector.popFile(newFile)) diff --git a/module/plugins/hooks/Hook.py b/module/plugins/hooks/Hook.py new file mode 100644 index 000000000..f02432718 --- /dev/null +++ b/module/plugins/hooks/Hook.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: mkaay + @interface-version: 0.1 +""" + +import logging + +class Hook(): + def __init__(self, core): + self.logger = logging.getLogger("log") + props = {} + props['name'] = "Hook" + props['version'] = "0.1" + props['description'] = """interface for hook""" + props['author_name'] = ("mkaay") + props['author_mail'] = ("mkaay@mkaay.de") + self.props = props + self.core = core + + def downloadStarts(self, pyfile): + pass + + def downloadFinished(self, pyfile): + pass + + def packageFinished(self, pypack): + """ + not implemented! + """ + pass + + def beforeReconnecting(self, ip): + pass + + def afterReconnecting(self, ip): + pass diff --git a/module/plugins/hooks/__init__.py b/module/plugins/hooks/__init__.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/module/plugins/hooks/__init__.py @@ -0,0 +1 @@ + |