summaryrefslogtreecommitdiffstats
path: root/pyload
diff options
context:
space:
mode:
Diffstat (limited to 'pyload')
-rw-r--r--pyload/Core.py1
-rw-r--r--pyload/InitHomeDir.py64
-rw-r--r--pyload/__init__.py88
-rw-r--r--pyload/cli/Cli.py1
-rw-r--r--pyload/webui/__init__.py1
5 files changed, 76 insertions, 79 deletions
diff --git a/pyload/Core.py b/pyload/Core.py
index 957f6144d..ec53bf7da 100644
--- a/pyload/Core.py
+++ b/pyload/Core.py
@@ -21,7 +21,6 @@ from sys import argv, executable, exit
from time import time, sleep
from traceback import print_exc
-from pyload import InitHomeDir
from pyload.manager.AccountManager import AccountManager
from pyload.manager.CaptchaManager import CaptchaManager
from pyload.config.Parser import ConfigParser
diff --git a/pyload/InitHomeDir.py b/pyload/InitHomeDir.py
deleted file mode 100644
index 8ec9a92ce..000000000
--- a/pyload/InitHomeDir.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- coding: utf-8 -*-
-# @author: RaNaN
-
-""" This modules inits working directories and global variables, pydir and homedir """
-
-from os import makedirs, path, chdir
-from os.path import join
-import sys
-from sys import argv, platform
-
-import __builtin__
-
-__builtin__.owd = path.abspath("") # original working directory
-__builtin__.pypath = path.abspath(path.join(__file__, "..", ".."))
-
-sys.path.append(join(pypath, "pyload", "lib"))
-
-homedir = ""
-
-if platform == 'nt':
- homedir = path.expanduser("~")
- if homedir == "~":
- import ctypes
-
- CSIDL_APPDATA = 26
- _SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW
- _SHGetFolderPath.argtypes = [ctypes.wintypes.HWND,
- ctypes.c_int,
- ctypes.wintypes.HANDLE,
- ctypes.wintypes.DWORD, ctypes.wintypes.LPCWSTR]
-
- path_buf = ctypes.wintypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
- result = _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf)
- homedir = path_buf.value
-else:
- homedir = path.expanduser("~")
-
-__builtin__.homedir = homedir
-
-args = " ".join(argv[1:])
-
-# dirty method to set configdir from commandline arguments
-if "--configdir=" in args:
- for aa in argv:
- if aa.startswith("--configdir="):
- configdir = aa.replace("--configdir=", "", 1).strip()
-elif path.exists(path.join(pypath, "pyload", "config", "configdir")):
- f = open(path.join(pypath, "pyload", "config", "configdir"), "rb")
- c = f.read().strip()
- f.close()
- configdir = path.join(pypath, c)
-else:
- if platform in ("posix", "linux2"):
- configdir = path.join(homedir, ".pyload")
- else:
- configdir = path.join(homedir, "pyload")
-
-if not path.exists(configdir):
- makedirs(configdir, 0700)
-
-__builtin__.configdir = configdir
-chdir(configdir)
-
-# print "Using %s as working directory." % configdir
diff --git a/pyload/__init__.py b/pyload/__init__.py
index 154ab22b6..1c9daedbd 100644
--- a/pyload/__init__.py
+++ b/pyload/__init__.py
@@ -2,19 +2,83 @@
__all__ = ["__status_code__", "__status__", "__version_info__", "__version__", "__author_name__", "__author_mail__", "__license__"]
-__status_code__ = 4
-__status__ = {1: "Planning",
- 2: "Pre-Alpha",
- 3: "Alpha",
- 4: "Beta",
- 5: "Production/Stable",
- 6: "Mature",
- 7: "Inactive"}[__status_code__] #: PyPI Development Status Classifiers
-
__version_info__ = (0, 4, 10)
-__version__ = '.'.join(map(str, __version_info__))
+__version__ = '.'.join(map(str, __version_info__))
-__author_name__ = "pyLoad Team"
-__author_mail__ = "admin@pyload.org"
+__status_code__ = 4
+__status__ = {1: "Planning",
+ 2: "Pre-Alpha",
+ 3: "Alpha",
+ 4: "Beta",
+ 5: "Production/Stable",
+ 6: "Mature",
+ 7: "Inactive"}[__status_code__] #: PyPI Development Status Classifiers
__license__ = "GNU Affero General Public License v3"
+
+__authors__ = [("Marius" , "mkaay@mkaay.de" ),
+ ("RaNaN" , "Mast3rRaNaN@hotmail.de"),
+ ("Stefano" , "l.stickell@yahoo.it" ),
+ ("Walter Purcaro", "vuolter@gmail.com" ),
+ ("himbrr" , "himbrr@himbrr.ws" ),
+ ("sebnapi" , "" ),
+ ("spoob" , "spoob@gmx.de" ),
+ ("zoidberg10" , "zoidberg@mujmail.cz" )]
+
+
+################################# InitHomeDir #################################
+
+import __builtin__
+import os
+import sys
+
+from codecs import getwriter
+
+from pyload.utils import get_console_encoding
+
+projectdir = os.path.abspath(os.path.join(__file__, ".."))
+homedir = os.path.expanduser("~")
+enc = get_console_encoding(sys.stdout.encoding)
+
+sys.os.path.append(os.path.join(projectdir, "lib"))
+sys.stdout = getwriter(enc)(sys.stdout, errors="replace")
+
+if homedir == "~" and os.name == "nt":
+ import ctypes
+
+ CSIDL_APPDATA = 26
+
+ _SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW
+ _SHGetFolderPath.argtypes = [ctypes.wintypes.HWND,
+ ctypes.c_int,
+ ctypes.wintypes.HANDLE,
+ ctypes.wintypes.DWORD,
+ ctypes.wintypes.LPCWSTR]
+
+ path_buf = ctypes.wintypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
+
+ _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf)
+
+ homedir = path_buf.value
+
+try:
+ p = os.path.join(projectdir, "config", "configdir")
+ if os.path.exists(p):
+ f = open(p, "rb")
+ configdir = f.read().strip()
+ f.close()
+
+except IOError:
+ if os.name == "posix":
+ configdir = os.path.join(homedir, ".pyload")
+ else:
+ configdir = os.path.join(homedir, "pyload")
+
+
+__builtin__.owd = os.path.abspath("") #: original working directory
+__builtin__.pypath = os.path.abspath(os.path.join(projectdir, ".."))
+__builtin__.pycore = None #: Store global Core.Core instance (will be set by Core on its init)
+
+__builtin__.projectdir = projectdir
+__builtin__.homedir = homedir
+__builtin__.configdir = configdir \ No newline at end of file
diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py
index 294d8f25a..d8c8602fc 100644
--- a/pyload/cli/Cli.py
+++ b/pyload/cli/Cli.py
@@ -26,7 +26,6 @@ else:
sys.stdout = getwriter(enc)(sys.stdout, errors="replace")
-from pyload import InitHomeDir
from pyload.cli.printer import *
from pyload.cli import AddPackage, ManageFiles
diff --git a/pyload/webui/__init__.py b/pyload/webui/__init__.py
index 964be4d3d..925ab9cb6 100644
--- a/pyload/webui/__init__.py
+++ b/pyload/webui/__init__.py
@@ -13,7 +13,6 @@ PYLOAD_DIR = abspath(join(THEME_DIR, "..", "..", ".."))
sys.path.append(PYLOAD_DIR)
-from pyload import InitHomeDir
from pyload.utils import decode, formatSize
import bottle