summaryrefslogtreecommitdiffstats
path: root/pyLoadCore.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-27 15:26:33 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-27 15:26:33 +0100
commitff7d4f1a13db0f4a9d6c427dcccbb0d1faf6c577 (patch)
treef84a1bc86164d5dbdc5cba0c0a49b85dd8c642c0 /pyLoadCore.py
parentstop button works, closes #59 (diff)
downloadpyload-ff7d4f1a13db0f4a9d6c427dcccbb0d1faf6c577.tar.xz
closes #51
Diffstat (limited to 'pyLoadCore.py')
-rwxr-xr-xpyLoadCore.py61
1 files changed, 39 insertions, 22 deletions
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 979abaf44..c062374bc 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -125,8 +125,10 @@ class Core(object):
self.server_methods = ServerMethods(self)
self.file_list = File_List(self)
self.thread_list = Thread_List(self)
-
- self.server_methods.check_update()
+
+ self.last_update_check = 0
+ self.update_check_interval = 1800
+ self.update_available = self.check_update()
self.init_server()
self.init_webserver() # start webinterface like cli, gui etc
@@ -160,7 +162,9 @@ class Core(object):
if self.do_kill:
self.shutdown()
self.logger.info("pyLoad quits")
- exit()
+ exit()
+ if self.last_update_check + self.update_check_interval <= time.time():
+ self.update_available = self.check_update()
def init_server(self):
try:
@@ -323,41 +327,51 @@ class Core(object):
thread.shutdown = True
thread.join(15)
self.file_list.save()
-
- ####################################
- ########## XMLRPC Methods ##########
- ####################################
-class ServerMethods():
- def __init__(self, core):
- self.core = core
+ def check_update(self):
+ try:
+ if self.config['updates']['search_updates']:
+ version_check = Request().load("http://update.pyload.org/index.php?do=dev%s&download=%s" % (CURRENT_VERSION, False))
+ if version_check == "":
+ self.logger.info("No Updates for pyLoad")
+ return False
+ else:
+ self.logger.info("New pyLoad Version %s available" % version_check)
+ return True
+ else:
+ return False
+ finally:
+ self.last_update_check = time.time()
- def check_update(self):
- """checks newst version"""
- if self.core.config['updates']['search_updates']:
+ def install_update(self):
+ if self.config['updates']['search_updates']:
version_check = Request().load("http://update.pyload.org/index.php?do=dev%s&download=%s" % (CURRENT_VERSION, self.core.config['updates']['install_updates']))
if version_check == "":
- self.core.logger.info("No Updates for pyLoad")
return False
else:
- if self.core.config['updates']['install_updates']:
+ if self.config['updates']['install_updates']:
try:
tmp_zip_name = __import__("tempfile").NamedTemporaryFile(suffix=".zip").name
- tmp_zip = open(tmp_zip_name, 'w')
+ tmp_zip = open(tmp_zip_name, 'wb')
tmp_zip.write(version_check)
tmp_zip.close()
__import__("module.Unzip", globals(), locals(), "Unzip", -1).Unzip().extract(tmp_zip_name, "Test/")
return True
-
except:
- self.logger.core.info("Auto install Faild")
+ self.logger.info("Auto install Failed")
return False
-
else:
- self.core.logger.info("New pyLoad Version %s available" % version_check)
- return True
+ return False
else:
return False
+
+ ####################################
+ ########## XMLRPC Methods ##########
+ ####################################
+
+class ServerMethods():
+ def __init__(self, core):
+ self.core = core
def status_downloads(self):
downloads = []
@@ -521,7 +535,10 @@ class ServerMethods():
return lines[offset:]
def stop_downloads(self):
- self.core.thread_list.stopAllDownloads()
+ self.core.thread_list.stopAllDownloads()
+
+ def update_available(self):
+ return self.core.update_available
#def move_urls_up(self, ids):
# for id in ids: