summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/HookManager.py3
-rw-r--r--module/InitHomeDir.py21
-rw-r--r--module/config/default.conf3
-rw-r--r--module/plugins/hooks/UpdateManager.py59
4 files changed, 71 insertions, 15 deletions
diff --git a/module/HookManager.py b/module/HookManager.py
index 3df8a1fc7..77a17b0aa 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -69,7 +69,8 @@ class HookManager():
self.plugins = plugins
-
+
+ @try_catch
def periodical(self):
for plugin in self.plugins:
if plugin.isActivated() and plugin.lastCall + plugin.interval < time():
diff --git a/module/InitHomeDir.py b/module/InitHomeDir.py
index a3fc64e50..d7f98180a 100644
--- a/module/InitHomeDir.py
+++ b/module/InitHomeDir.py
@@ -31,24 +31,23 @@ __builtin__.pypath = path.abspath(path.join(__file__,"..",".."))
homedir = ""
-try:
- from win32com.shell import shellcon, shell
- homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
-except ImportError: # quick semi-nasty fallback for non-windows/win32com case
- if platform == 'nt':
+
+if platform == 'nt':
+ homedir = path.expanduser("~")
+ if homedir == "~":
import ctypes
CSIDL_APPDATA = 26
_SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW
_SHGetFolderPath.argtypes = [ctypes.wintypes.HWND,
- ctypes.c_int,
- ctypes.wintypes.HANDLE,
- ctypes.wintypes.DWORD, ctypes.wintypes.LPCWSTR]
-
+ ctypes.c_int,
+ ctypes.wintypes.HANDLE,
+ ctypes.wintypes.DWORD, ctypes.wintypes.LPCWSTR]
+
path_buf = ctypes.wintypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
result = _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf)
homedir = path_buf.value
- else:
- homedir = path.expanduser("~")
+else:
+ homedir = path.expanduser("~")
__builtin__.homedir = homedir
diff --git a/module/config/default.conf b/module/config/default.conf
index e9c7782e6..df8682804 100644
--- a/module/config/default.conf
+++ b/module/config/default.conf
@@ -31,9 +31,6 @@ general - "General":
int min_free_space : "Min Free Space (MB)" = 200
bool folder_per_package : "Create folder for each package" = True
ip download_interface : "Outgoing IP address for downloads" = None
-updates - "Updates":
- bool search_updates : "Search" = True
- bool install_updates : "Install" = False
reconnect - "Reconnect":
bool activated : "Use Reconnect" = False
str method : "Method" = None
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
new file mode 100644
index 000000000..2981df9a0
--- /dev/null
+++ b/module/plugins/hooks/UpdateManager.py
@@ -0,0 +1,59 @@
+# -*- 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.network.Request import getURL
+from module.plugins.Hook import Hook
+
+class UpdateManager(Hook):
+ __name__ = "UpdateManager"
+ __version__ = "0.1"
+ __description__ = """checks for updates"""
+ __config__ = [ ("activated", "bool", "Activated" , "True"),
+ ("interval", "int", "Check interval in minutes" , "180")]
+ __author_name__ = ("RaNaN")
+ __author_mail__ = ("ranan@pyload.org")
+
+ def setup(self):
+ self.interval = self.getConfig("interval") * 60
+
+ def coreReady(self):
+ #@TODO check plugins, restart, and other stuff
+ pass
+
+ def periodical(self):
+ self.checkForUpdate()
+
+
+ def checkForUpdate(self):
+ """ checks if an update is available"""
+
+ try:
+ version_check = getURL("http://get.pyload.org/check/%s/" % self.core.server_methods.get_server_version() )
+ if version_check == "":
+ self.log.info(_("No Updates for pyLoad"))
+ return False
+ else:
+ self.log.info(_("*** New pyLoad Version %s available ***") % version_check)
+ self.log.info(_("*** Get it here: http://get.pyload.org/get/ ***"))
+ return True
+ except:
+ self.log.error(_("Not able to connect server"))
+
+ \ No newline at end of file