summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-08 16:47:52 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-08 16:47:52 +0100
commit1ecdd9f6b53fec45e1d48592e3ff56aa7a576bec (patch)
tree8d9e42cb670a24b4a9adb439cfc15c4277a61716
parentnew MultiHoster hook (diff)
downloadpyload-1ecdd9f6b53fec45e1d48592e3ff56aa7a576bec.tar.xz
some cleanups, closed #490
-rw-r--r--module/Api.py7
-rw-r--r--module/HookManager.py5
-rw-r--r--module/database/DatabaseBackend.py2
-rw-r--r--module/network/HTTPChunk.py2
-rw-r--r--module/network/HTTPDownload.py2
-rw-r--r--module/plugins/Hook.py13
-rw-r--r--module/plugins/Hoster.py4
-rw-r--r--module/plugins/hooks/ExternalScripts.py9
-rw-r--r--module/plugins/hooks/ExtractArchive.py4
-rw-r--r--module/plugins/hooks/MultiHoster.py1
-rw-r--r--module/plugins/internal/UnRar.py2
-rw-r--r--module/utils/__init__.py6
-rw-r--r--module/utils/fs.py2
-rw-r--r--module/web/pyload_app.py4
-rwxr-xr-xpyLoadCore.py2
15 files changed, 31 insertions, 34 deletions
diff --git a/module/Api.py b/module/Api.py
index 11b06ff32..fba02d574 100644
--- a/module/Api.py
+++ b/module/Api.py
@@ -19,7 +19,7 @@
import re
from base64 import standard_b64encode
-from os.path import join
+from os.path import join, isabs
from time import time
from itertools import chain
@@ -300,7 +300,10 @@ class Api(Iface):
else:
folder = ""
- folder = folder.replace("http://", "").replace(":", "").replace("\\", "_") #.replace("/", "_")
+ if isabs(folder):
+ folder = folder.replace("/", "_")
+
+ folder = folder.replace("http://", "").replace(":", "").replace("\\", "_").replace("..", "")
self.core.log.info(_("Added package %(name)s containing %(count)d links") % {"name": name, "count": len(links)})
pid = self.core.files.addPackage(name, folder, dest, password)
diff --git a/module/HookManager.py b/module/HookManager.py
index 3691fe3ed..8afd6fe26 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -28,9 +28,6 @@ from module.threads.HookThread import HookThread
from module.plugins.PluginManager import literal_eval
from utils import lock, to_string
-def class_name(p):
- return p.rpartition(".")[2]
-
class HookManager:
""" Manages hooks, loading, unloading. """
@@ -71,7 +68,6 @@ class HookManager:
print_exc()
def addRPC(self, plugin, func, doc):
- plugin = class_name(plugin)
doc = doc.strip() if doc else ""
if plugin in self.methods:
@@ -225,7 +221,6 @@ class HookManager:
return info
def addEventListener(self, plugin, func, event):
- plugin = class_name(plugin)
if plugin not in self.events:
self.events[plugin] = []
self.events[plugin].append((func, event))
diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py
index e10bcbbaf..32f75328c 100644
--- a/module/database/DatabaseBackend.py
+++ b/module/database/DatabaseBackend.py
@@ -25,7 +25,7 @@ from shutil import move
from Queue import Queue
from traceback import print_exc
-from module.utils import chmod
+from module.utils.fs import chmod
try:
from pysqlite2 import dbapi2 as sqlite3
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py
index b637aef32..add2cc094 100644
--- a/module/network/HTTPChunk.py
+++ b/module/network/HTTPChunk.py
@@ -20,7 +20,7 @@ from os import remove, stat, fsync
from os.path import exists
from time import sleep
from re import search
-from module.utils import fs_encode
+from module.utils.fs import fs_encode
import codecs
import pycurl
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 0d5fc59c9..6ac39a051 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -29,7 +29,7 @@ from HTTPChunk import ChunkInfo, HTTPChunk
from HTTPRequest import BadHeader
from module.plugins.Hoster import Abort
-from module.utils import save_join, fs_encode
+from module.utils.fs import save_join, fs_encode
class HTTPDownload():
""" loads a url http + ftp """
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index c0ce7d99c..83ef091ae 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -19,22 +19,25 @@
from traceback import print_exc
-from functools import wraps
+#from functools import wraps
from module.utils import has_method
from Base import Base
+def class_name(p):
+ return p.rpartition(".")[2]
+
class Expose(object):
""" used for decoration to declare rpc services """
def __new__(cls, f, *args, **kwargs):
- hookManager.addRPC(f.__module__, f.func_name, f.func_doc)
+ hookManager.addRPC(class_name(f.__module__), f.func_name, f.func_doc)
return f
def AddEventListener(event):
""" used to register method for events """
class _klass(object):
def __new__(cls, f, *args, **kwargs):
- hookManager.addEventListener(f.__module__, f.func_name, event)
+ hookManager.addEventListener(class_name(f.__module__), f.func_name, event)
return f
return _klass
@@ -42,11 +45,11 @@ def AddEventListener(event):
class ConfigHandler(object):
""" register method as config handler """
def __new__(cls, f, *args, **kwargs):
- hookManager.addConfigHandler(f.__module__, f.func_name)
+ hookManager.addConfigHandler(class_name(f.__module__), f.func_name)
return f
def threaded(f):
- @wraps(f)
+ #@wraps(f)
def run(*args,**kwargs):
hookManager.startThread(f, *args, **kwargs)
return run
diff --git a/module/plugins/Hoster.py b/module/plugins/Hoster.py
index 54c2efdfd..bef4b1949 100644
--- a/module/plugins/Hoster.py
+++ b/module/plugins/Hoster.py
@@ -29,7 +29,7 @@ if os.name != "nt":
from Base import Base, Fail, Retry
from module.utils import chunks #legacy import
-from module.utils.fs import save_join, save_path, fs_encode, fs_decode,\
+from module.utils.fs import save_join, save_filename, fs_encode, fs_decode,\
remove, makedirs, chmod, stat, exists, join
@@ -339,7 +339,7 @@ class Hoster(Base):
# convert back to unicode
location = fs_decode(location)
- name = save_path(self.pyfile.name)
+ name = save_filename(self.pyfile.name)
filename = join(location, name)
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py
index 2e77f1dae..39fe2b9f0 100644
--- a/module/plugins/hooks/ExternalScripts.py
+++ b/module/plugins/hooks/ExternalScripts.py
@@ -14,16 +14,15 @@
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: mkaay
- @interface-version: 0.1
+ @author: RaNaN
"""
import subprocess
-from os import listdir, access, X_OK, makedirs
-from os.path import join, exists, basename
+from os import access, X_OK, makedirs
+from os.path import basename
from module.plugins.Hook import Hook
-from module.utils import save_join
+from module.utils.fs import save_join, exists, join, listdir
class ExternalScripts(Hook):
__name__ = "ExternalScripts"
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 82e9c1d36..d9c2e57bb 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -4,7 +4,7 @@
import sys
import os
from os import remove, chmod, makedirs
-from os.path import exists, basename, isfile, isdir, join
+from os.path import basename, isfile, isdir, join
from traceback import print_exc
from copy import copy
@@ -48,7 +48,7 @@ if os.name != "nt":
from pwd import getpwnam
from grp import getgrnam
-from module.utils import save_join, fs_encode
+from module.utils.fs import save_join, fs_encode, exists
from module.plugins.Hook import Hook, threaded, Expose
from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword
diff --git a/module/plugins/hooks/MultiHoster.py b/module/plugins/hooks/MultiHoster.py
index 1f40a4ddd..749f2c104 100644
--- a/module/plugins/hooks/MultiHoster.py
+++ b/module/plugins/hooks/MultiHoster.py
@@ -69,6 +69,7 @@ class MultiHoster(Hook):
def refreshAccounts(self, plugin=None, user=None):
self.plugins = {}
+
for name, account in self.core.accountManager.iterAccounts():
if isinstance(account, MultiHosterAccount) and account.isUsable():
self.addHoster(account)
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index feac4c176..9f57a9ad6 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -23,7 +23,7 @@ from os.path import join
from glob import glob
from subprocess import Popen, PIPE
-from module.utils import save_join, decode
+from module.utils.fs import save_join, decode
from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError
class UnRar(AbtractExtractor):
diff --git a/module/utils/__init__.py b/module/utils/__init__.py
index 8457eba07..3b0fb673a 100644
--- a/module/utils/__init__.py
+++ b/module/utils/__init__.py
@@ -194,8 +194,4 @@ def html_unescape(text):
if __name__ == "__main__":
print freeSpace(".")
- print remove_chars("ab'cdgdsf''ds'", "'ghd")
-
-
-# TODO: Legacy import
-from fs import chmod, save_path, save_join, fs_decode, fs_encode, free_space \ No newline at end of file
+ print remove_chars("ab'cdgdsf''ds'", "'ghd") \ No newline at end of file
diff --git a/module/utils/fs.py b/module/utils/fs.py
index 1b5f61c17..03832e368 100644
--- a/module/utils/fs.py
+++ b/module/utils/fs.py
@@ -41,7 +41,7 @@ def makedirs(path, mode=0660):
def listdir(path):
return os.listdir(fs_encode(path))
-def save_path(name):
+def save_filename(name):
#remove some chars
if os.name == 'nt':
return remove_chars(name, '/\\?%*:|"<>')
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index fffa19b48..a19dce24c 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -22,7 +22,6 @@ from operator import itemgetter, attrgetter
import time
import os
import sys
-from os import listdir
from os.path import isdir, isfile, join, abspath
from sys import getfilesystemencoding
from urllib import unquote
@@ -36,7 +35,8 @@ from utils import render_to_response, parse_permissions, parse_userdata, \
from filters import relpath, unquotepath
-from module.utils import formatSize, save_join, fs_encode, fs_decode
+from module.utils import formatSize
+from module.utils.fs import save_join, fs_encode, fs_decode, listdir
# Helper
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 5e32219f8..233eda335 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -456,7 +456,7 @@ class Core(object):
# import memdebug
# memdebug.start(8002)
# from meliae import scanner
-# scanner.dump_all_objects('objs.json')
+# scanner.dump_all_objects(self.path('objs.json'))
locals().clear()