summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-11-27 23:51:44 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-11-27 23:51:44 +0100
commit7fb23f31ac129442f35d2d98a5ef3f0b387dc8e2 (patch)
tree5d28138f06a75130dd343dc609207b182af80f65
parentfixed file_list (diff)
downloadpyload-7fb23f31ac129442f35d2d98a5ef3f0b387dc8e2.tar.xz
updated xmlrpc methods
-rw-r--r--module/file_list.py28
-rwxr-xr-xpyLoadCore.py61
2 files changed, 70 insertions, 19 deletions
diff --git a/module/file_list.py b/module/file_list.py
index f3bfc0b8a..1bcfb8580 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -151,6 +151,9 @@ class File_List(object):
returns a free id
"""
ids = []
+ for pypack in (packager.file_list.data["packages"] + packager.file_list.data["queue"]):
+ for pyf in pypack.links:
+ ids.append(pyf.id)
for pyfile in collector.file_list.data["collector"]:
ids.append(pyfile.id)
id = 1
@@ -235,6 +238,20 @@ class File_List(object):
return ("queue", n, pypack)
raise NoSuchElementException()
+ def _getFileFromID(packager, id):
+ """
+ returns PyLoadFile instance and position with given id
+ """
+ for n, pypack in enumerate(packager.file_list.data["packages"]):
+ for pyfile in pypack.files:
+ if pyfile.id == id:
+ return ("packages", n, pyfile, pypack, pid)
+ for n, pypack in enumerate(packager.file_list.data["queue"]):
+ for pyfile in pypack.files:
+ if pyfile.id == id:
+ return ("queue", n, pyfile, pypack, pid)
+ raise NoSuchElementException()
+
def addNewPackage(packager, package_name=None):
pypack = PyLoadPackage()
pypack.id = packager._getFreeID()
@@ -251,6 +268,17 @@ class File_List(object):
finally:
packager.file_list.lock.release()
+ def removeFile(packager, id):
+ """
+ removes PyLoadFile instance with the given id from package
+ """
+ packager.file_list.lock.acquire()
+ try:
+ key, n, pyfile, pypack, pid = self._getFileFromID()
+ del pypack.files[n]
+ finally:
+ packager.file_list.lock.release()
+
def pushPackage2Queue(packager, id):
packager.file_list.lock.acquire()
try:
diff --git a/pyLoadCore.py b/pyLoadCore.py
index df4e472c6..9a9cd8306 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -180,11 +180,12 @@ class Core(object):
self.server.register_function(self.status_downloads)
self.server.register_function(self.status_server)
self.server.register_function(self.kill)
- self.server.register_function(self.del_urls)
+ self.server.register_function(self.del_links)
+ self.server.register_function(self.del_packages)
self.server.register_function(self.add_urls)
- self.server.register_function(self.get_urls)
- self.server.register_function(self.move_urls_up)
- self.server.register_function(self.move_urls_down)
+ self.server.register_function(self.get_queue)
+ #self.server.register_function(self.move_urls_up)
+ #self.server.register_function(self.move_urls_down)
self.server.register_function(self.is_time_download)
self.server.register_function(self.is_time_reconnect)
self.server.register_function(self.get_conf_val)
@@ -326,27 +327,49 @@ class Core(object):
self.file_list.collector.addLink(link)
self.file_list.save()
- def del_urls(self, ids):
+ def del_links(self, ids):
for id in ids:
- self.file_list.remove_id(id)
+ try:
+ self.file_list.collector.removeFile(id)
+ except:
+ self.file_list.packages.removeFile(id)
+ self.file_list.save()
+
+ def del_packages(self, ids):
+ for id in ids:
+ self.file_list.packages.removePackage(id)
self.file_list.save()
def kill(self):
self.do_kill = True
return True
- def get_urls(self):
- return self.file_list.data
-
- def move_urls_up(self, ids):
- for id in ids:
- self.file_list.move(id)
- self.file_list.save()
-
- def move_urls_down(self, ids):
- for id in ids:
- self.file_list.move(id, 1)
- self.file_list.save()
+ def get_queue(self):
+ data = []
+ for q in self.file_list.data["queue"]:
+ ds = {
+ "id": q.data.id,
+ "name": q.data.package_name,
+ "folder": q.data.folder,
+ "files": []
+ }
+ for f in q.links:
+ ds["files"].append({
+ "name": f.status.name,
+ "status": f.status.type,
+ "url": f.url
+ })
+ data.append(ds)
+
+ #def move_urls_up(self, ids):
+ # for id in ids:
+ # self.file_list.move(id)
+ # self.file_list.save()
+
+ #def move_urls_down(self, ids):
+ # for id in ids:
+ # self.file_list.move(id, 1)
+ # self.file_list.save()
def read_url_list(self, url_list):
"""read links from txt"""
@@ -355,7 +378,7 @@ class Core(object):
links = txt.readlines()
for link in links:
if link != "\n":
- self.file_list.append(link)
+ self.file_list.collector.addLink(link)
new_links += 1
txt.close()