summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-28 16:42:00 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-28 16:42:00 +0200
commit66e87e5b316b0fa813c8446402944dde770e556e (patch)
treed99fcfdba0f924360b319594f31d7ff98560561d
parentso.biz fix (diff)
downloadpyload-66e87e5b316b0fa813c8446402944dde770e556e.tar.xz
preparation for plugin updates
-rw-r--r--module/config/default.conf2
-rw-r--r--module/plugins/hooks/UpdateManager.py62
-rwxr-xr-xpyLoadCore.py23
3 files changed, 63 insertions, 24 deletions
diff --git a/module/config/default.conf b/module/config/default.conf
index 915604084..deb780142 100644
--- a/module/config/default.conf
+++ b/module/config/default.conf
@@ -7,7 +7,7 @@ remote - "Remote":
str password : "Password" = pwhere
ssl - "SSL":
bool activated : "Activated"= False
- str cert : "SSL Certificate" = ssl.crt
+ str cert : "SSL Certificate" = ssl.srt
str key : "SSL Key" = ssl.key
webinterface - "Webinterface":
bool activated : "Activated" = True
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index 2981df9a0..8e2c4368b 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -25,35 +25,73 @@ class UpdateManager(Hook):
__name__ = "UpdateManager"
__version__ = "0.1"
__description__ = """checks for updates"""
- __config__ = [ ("activated", "bool", "Activated" , "True"),
- ("interval", "int", "Check interval in minutes" , "180")]
+ __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
-
+ self.updated = False
+
def coreReady(self):
- #@TODO check plugins, restart, and other stuff
+ #@TODO check plugins, restart, and other stuff
pass
-
+
def periodical(self):
- self.checkForUpdate()
-
-
+ update = self.checkForUpdate()
+ if self.updated:
+ self.log.info(_("*** Plugins were updated, please restart pyLoad ***"))
+ if not update:
+ self.checkPlugins()
+
+
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() )
+ 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/ ***"))
+ self.log.info(_("*** Get it here: http://pyload.org/download ***"))
return True
except:
self.log.error(_("Not able to connect server"))
+ return False
+
+
+ def checkPlugins(self):
+ """ checks for plugins updates"""
+
+ string = ""
+
+ string += self.createUpdateList(self.core.pluginManager.crypterPlugins, "crypter")
+ string += self.createUpdateList(self.core.pluginManager.hosterPlugins, "hoster")
+ string += self.createUpdateList(self.core.pluginManager.containerPlugins, "container")
+ string += self.createUpdateList(self.core.pluginManager.accountPlugins, "account")
+ string += self.createUpdateList(self.core.pluginManager.hookPlugins, "hook")
+ string += self.createUpdateList(self.core.pluginManager.captchaPlugins, "captcha")
+
+ try:
+ updates = getURL("updateurl", post={"plugins": string})
+ except:
+ self.log.warning(_("Plugins could not be updated"))
+ updates = ""
+
+ updates = updates.splitlines()
+
+ for plugin in updates:
+ type, name, url = plugin.split("|")
+ print type, name, url
+ #@TODO save url content to disk
+
+ def createUpdateList(self, plugins, type):
+ """ create string list for update check """
+ string = ""
+ for name,plugin in plugins.iteritems():
+ string += "%s|%s|%s\n" % (type, name, plugin["v"])
- \ No newline at end of file
+ return string \ No newline at end of file
diff --git a/pyLoadCore.py b/pyLoadCore.py
index f33cf3a1f..dd4741d3e 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -368,17 +368,18 @@ class Core(object):
file_created = False
else:
file_created = False
- if not file_exists and not quiet:
- if file_created:
- #self.log.info( _("%s created") % description )
- pass
- else:
- if not empty:
- self.log.warning(_("could not find %(desc)s: %(name)s") % {"desc": description, "name": tmp_name})
+
+ if not file_exists and not quiet:
+ if file_created:
+ #self.log.info( _("%s created") % description )
+ pass
else:
- print _("could not create %(desc)s: %(name)s") % {"desc": description, "name": tmp_name}
- if essential:
- exit()
+ if not empty:
+ self.log.warning(_("could not find %(desc)s: %(name)s") % {"desc": description, "name": tmp_name})
+ else:
+ print _("could not create %(desc)s: %(name)s") % {"desc": description, "name": tmp_name}
+ if essential:
+ exit()
def isClientConnected(self):
return (self.lastClientConnected + 30) > time.time()
@@ -520,7 +521,7 @@ class ServerMethods():
status['total'] = self.core.files.getFileCount()
status['speed'] = 0
- for pyfile in [x.active for x in self.core.threadManager.threads if x.active]:
+ for pyfile in [x.active for x in self.core.threadManager.threads if x.active and x.active != "quit"]:
status['speed'] += pyfile.getSpeed()
status['download'] = not self.core.threadManager.pause and self.is_time_download()