diff options
Diffstat (limited to 'pyLoadCore.py')
-rwxr-xr-x | pyLoadCore.py | 61 |
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:
|