summaryrefslogtreecommitdiffstats
path: root/pyload
diff options
context:
space:
mode:
Diffstat (limited to 'pyload')
-rw-r--r--pyload/Core.py17
-rw-r--r--pyload/DownloadManager.py28
-rw-r--r--pyload/FileManager.py28
-rw-r--r--pyload/InitHomeDir.py47
-rw-r--r--pyload/datatypes/PyPackage.py2
-rw-r--r--pyload/setup/Setup.py3
-rw-r--r--pyload/utils/pylgettext.py61
7 files changed, 73 insertions, 113 deletions
diff --git a/pyload/Core.py b/pyload/Core.py
index d18c80cad..6f3893481 100644
--- a/pyload/Core.py
+++ b/pyload/Core.py
@@ -30,6 +30,7 @@ import os
from os import _exit, execl, getcwd, remove, walk, chdir, close
import signal
import sys
+import gettext
from sys import argv, executable, exit
from time import time, sleep
from traceback import print_exc
@@ -41,7 +42,8 @@ import subprocess
subprocess.__doc__ = None # the module with the largest doc we are using
-import InitHomeDir
+from InitHomeDir import init_dir
+init_dir()
from AccountManager import AccountManager
from config.ConfigParser import ConfigParser
@@ -54,7 +56,6 @@ from Scheduler import Scheduler
from remote.RemoteManager import RemoteManager
from utils.JsEngine import JsEngine
-import utils.pylgettext as gettext
from utils import formatSize, get_console_encoding
from utils.fs import free_space, exists, makedirs, join, chmod
@@ -73,19 +74,11 @@ sys.stdout = getwriter(enc)(sys.stdout, errors="replace")
# - configurable auth system ldap/mysql
# - cron job like sheduler
# - plugin stack / multi decrypter
-# - media plugin type
-# - general progress info
# - content attribute for files / sync status
# - sync with disk content / file manager / nested packages
# - sync between pyload cores
# - new attributes (date|sync status)
-# - embedded packages
-# - would require new/modified link collector concept
-# - pausable links/packages
-# - toggable accounts
-# - interaction manager
# - improve external scripts
-# - make pyload undestructable to fail plugins -> see ConfigParser first
class Core(object):
"""pyLoad Core, one tool to rule them all... (the filehosters) :D"""
@@ -309,7 +302,6 @@ class Core(object):
self.config = ConfigParser()
- gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
translation = gettext.translation("pyLoad", self.path("locale"),
languages=[self.config['general']['language'], "en"], fallback=True)
translation.install(True)
@@ -383,6 +375,7 @@ class Core(object):
from AddonManager import AddonManager
from interaction.InteractionManager import InteractionManager
from threads.ThreadManager import ThreadManager
+ from DownloadManager import DownloadManager
Api.initComponents()
self.api = Api(self)
@@ -395,6 +388,7 @@ class Core(object):
self.interactionManager = self.im = InteractionManager(self)
self.accountManager = AccountManager(self)
self.threadManager = ThreadManager(self)
+ self.downloadManager = DownloadManager(self)
self.addonManager = AddonManager(self)
self.remoteManager = RemoteManager(self)
@@ -481,6 +475,7 @@ class Core(object):
_exit(0)
# TODO check exits codes, clean exit is still blocked
+ self.downloadManager.work()
self.threadManager.work()
self.interactionManager.work()
self.scheduler.work()
diff --git a/pyload/DownloadManager.py b/pyload/DownloadManager.py
new file mode 100644
index 000000000..b877db355
--- /dev/null
+++ b/pyload/DownloadManager.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+###############################################################################
+# Copyright(c) 2008-2014 pyLoad Team
+# http://www.pyload.org
+#
+# This file is part of pyLoad.
+# pyLoad is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Subjected to the terms and conditions in LICENSE
+#
+# @author: RaNaN
+###############################################################################
+
+
+class DownloadManager:
+ """ Schedules and manages download and decrypter jobs. """
+
+ def __init__(self, core):
+ self.core = core
+
+ def work(self):
+ """ Does the periodical work """
+
diff --git a/pyload/FileManager.py b/pyload/FileManager.py
index 4ea7dc5cc..2edf81bfc 100644
--- a/pyload/FileManager.py
+++ b/pyload/FileManager.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
###############################################################################
-# Copyright(c) 2008-2012 pyLoad Team
+# Copyright(c) 2008-2014 pyLoad Team
# http://www.pyload.org
#
# This file is part of pyLoad.
@@ -35,14 +35,12 @@ def invalidate(func):
return new
-# TODO: needs to be replaced later
-OWNER = 0
-
class FileManager:
"""Handles all request made to obtain information,
modify status or other request for links or packages"""
ROOT_PACKAGE = -1
+ ROOT_OWNER = -1
def __init__(self, core):
"""Constructor"""
@@ -94,17 +92,17 @@ class FileManager:
pass
@invalidate
- def addLinks(self, data, package):
+ def addLinks(self, data, pid, owner):
"""Add links, data = (plugin, url) tuple. Internal method should use API."""
- self.db.addLinks(data, package, OWNER)
- self.evm.dispatchEvent("package:updated", package)
+ self.db.addLinks(data, pid, owner)
+ self.evm.dispatchEvent("package:updated", pid)
@invalidate
- def addPackage(self, name, folder, root, password, site, comment, paused):
+ def addPackage(self, name, folder, root, password, site, comment, paused, owner):
"""Adds a package to database"""
pid = self.db.addPackage(name, folder, root, password, site, comment,
- PackageStatus.Paused if paused else PackageStatus.Ok, OWNER)
+ PackageStatus.Paused if paused else PackageStatus.Ok, owner)
p = self.db.getPackageInfo(pid)
self.evm.dispatchEvent("package:inserted", pid, p.root, p.packageorder)
@@ -115,7 +113,7 @@ class FileManager:
def getPackage(self, pid):
"""return package instance"""
if pid == self.ROOT_PACKAGE:
- return RootPackage(self, OWNER)
+ return RootPackage(self, self.ROOT_OWNER)
elif pid in self.packages:
pack = self.packages[pid]
pack.timestamp = time()
@@ -133,7 +131,7 @@ class FileManager:
def getPackageInfo(self, pid):
"""returns dict with package information"""
if pid == self.ROOT_PACKAGE:
- pack = RootPackage(self, OWNER).toInfoData()
+ pack = RootPackage(self, self.ROOT_OWNER).toInfoData()
elif pid in self.packages:
pack = self.packages[pid].toInfoData()
pack.stats = self.db.getStatsForPackage(pid)
@@ -177,7 +175,7 @@ class FileManager:
@read_lock
def getTree(self, pid, full, state, search=None):
""" return a TreeCollection and fill the info data of containing packages.
- optional filter only unfnished files
+ optional filter only unfinished files
"""
view = TreeCollection(pid)
@@ -202,7 +200,7 @@ class FileManager:
# root package is not in database, create an instance
if pid == self.ROOT_PACKAGE:
- view.root = RootPackage(self, OWNER).toInfoData()
+ view.root = RootPackage(self, self.ROOT_OWNER).toInfoData()
packs[self.ROOT_PACKAGE] = view.root
elif pid in packs:
view.root = packs[pid]
@@ -533,8 +531,6 @@ class FileManager:
# cantor won't be happy if we put the package in itself
if pid == root or p.root == root: return False
- # TODO move real folders
-
# we assume pack is not in use anyway, so we can release it
self.releasePackage(pid)
self.db.movePackage(p.root, p.packageorder, pid, root)
@@ -552,8 +548,6 @@ class FileManager:
if not self.getPackageInfo(pid):
raise PackageDoesNotExist(pid)
- # TODO move real files
-
self.db.moveFiles(f.package, fids, pid)
return True
diff --git a/pyload/InitHomeDir.py b/pyload/InitHomeDir.py
index 4c7fce2eb..a68e1a197 100644
--- a/pyload/InitHomeDir.py
+++ b/pyload/InitHomeDir.py
@@ -1,23 +1,19 @@
#!/usr/bin/env python
# -*- 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: RaNaN
-
- This modules inits working directories and global variables, pydir and homedir
-"""
+###############################################################################
+# Copyright(c) 2008-2014 pyLoad Team
+# http://www.pyload.org
+#
+# This file is part of pyLoad.
+# pyLoad is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Subjected to the terms and conditions in LICENSE
+#
+# @author: RaNaN
+###############################################################################
from os import makedirs, path, chdir
from os.path import join
@@ -87,10 +83,17 @@ if not configdir:
configname = ".pyload" if platform in ("posix", "linux2", "darwin") else "pyload"
configdir = path.join(homedir, configname + dev)
-if not path.exists(configdir):
- makedirs(configdir, 0700)
+def init_dir(other_path=None):
+ # switch to pyload home directory, or path at other_path
+ global configdir
+
+ if other_path is not None:
+ configdir = join(pypath, other_path)
+
+ if not path.exists(configdir):
+ makedirs(configdir, 0700)
-__builtin__.configdir = configdir
-chdir(configdir)
+ __builtin__.configdir = configdir
+ chdir(configdir)
#print "Using %s as working directory." % configdir
diff --git a/pyload/datatypes/PyPackage.py b/pyload/datatypes/PyPackage.py
index 955986942..41a733fe5 100644
--- a/pyload/datatypes/PyPackage.py
+++ b/pyload/datatypes/PyPackage.py
@@ -90,7 +90,7 @@ class PyPackage:
self.m.releasePackage(self.id)
def delete(self):
- self.m.deletePackage(self.id)
+ self.m.removePackage(self.id)
def deleteIfEmpty(self):
""" True if deleted """
diff --git a/pyload/setup/Setup.py b/pyload/setup/Setup.py
index c61a389e2..aa65edb4b 100644
--- a/pyload/setup/Setup.py
+++ b/pyload/setup/Setup.py
@@ -19,13 +19,14 @@
import os
import sys
import socket
+import gettext
import webbrowser
from getpass import getpass
from time import time
from sys import exit
-from pyload.utils import pylgettext as gettext
+
from pyload.utils.fs import abspath, dirname, exists, join, makedirs
from pyload.utils import get_console_encoding
from pyload.web.ServerThread import WebServer
diff --git a/pyload/utils/pylgettext.py b/pyload/utils/pylgettext.py
deleted file mode 100644
index fb36fecee..000000000
--- a/pyload/utils/pylgettext.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-from gettext import *
-
-_searchdirs = None
-
-origfind = find
-
-def setpaths(pathlist):
- global _searchdirs
- if isinstance(pathlist, list):
- _searchdirs = pathlist
- else:
- _searchdirs = list(pathlist)
-
-
-def addpath(path):
- global _searchdirs
- if _searchdirs is None:
- _searchdirs = list(path)
- else:
- if path not in _searchdirs:
- _searchdirs.append(path)
-
-
-def delpath(path):
- global _searchdirs
- if _searchdirs is not None:
- if path in _searchdirs:
- _searchdirs.remove(path)
-
-
-def clearpath():
- global _searchdirs
- if _searchdirs is not None:
- _searchdirs = None
-
-
-def find(domain, localedir=None, languages=None, all=False):
- if _searchdirs is None:
- return origfind(domain, localedir, languages, all)
- searches = [localedir] + _searchdirs
- results = list()
- for dir in searches:
- res = origfind(domain, dir, languages, all)
- if all is False:
- results.append(res)
- else:
- results.extend(res)
- if all is False:
- results = filter(lambda x: x is not None, results)
- if len(results) == 0:
- return None
- else:
- return results[0]
- else:
- return results
-
-#Is there a smarter/cleaner pythonic way for this?
-translation.func_globals['find'] = find