summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-18 22:33:06 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-18 22:33:06 +0100
commitd79c1b3a6d1a6481b77598edf71fcb53eb6bb655 (patch)
tree04746ec4511a4d3e134a3781cb7e68dc3974411c
parentyoutube fix, xdccrequest abort dl implemented (diff)
downloadpyload-d79c1b3a6d1a6481b77598edf71fcb53eb6bb655.tar.xz
closed #242, #243, #244
-rw-r--r--module/ThreadManager.py3
-rw-r--r--module/network/Browser.py1
-rw-r--r--module/plugins/Plugin.py3
-rw-r--r--module/plugins/PluginManager.py8
-rw-r--r--module/plugins/hoster/MegauploadCom.py21
-rw-r--r--module/setup.py19
-rw-r--r--module/web/ServerThread.py8
-rw-r--r--module/web/pyload_app.py21
-rw-r--r--module/web/templates/jinja/default/base.html4
-rw-r--r--module/web/templates/jinja/default/setup.html13
-rw-r--r--module/web/webinterface.py26
-rwxr-xr-xpyLoadCli.py4
12 files changed, 103 insertions, 28 deletions
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index f3da9a713..0462dd8c2 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -157,11 +157,12 @@ class ThreadManager:
("http://checkip.dyndns.org/",".*Current IP Address: (\S+)</body>.*")]
ip = ""
- while not ip:
+ for i in range(10):
try:
sv = choice(services)
ip = getURL(sv[0])
ip = re.match(sv[1], ip).group(1)
+ break
except:
ip = ""
sleep(1)
diff --git a/module/network/Browser.py b/module/network/Browser.py
index 9585eb7cc..6cc907491 100644
--- a/module/network/Browser.py
+++ b/module/network/Browser.py
@@ -76,6 +76,7 @@ class Browser(object):
def httpDownload(self, url, filename, get={}, post={}, ref=True, cookies=True, chunks=1, resume=False, progressNotify=None):
""" this can also download ftp """
+ self._size = 0
self.dl = HTTPDownload(url, filename, get, post, self.lastEffectiveURL if ref else None,
self.cj if cookies else None, self.bucket, self.interface,
self.proxies, progressNotify)
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index e59977451..6182b0f7f 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -127,7 +127,6 @@ class Plugin(object):
def preprocessing(self, thread):
""" handles important things to do before starting """
- self.setup()
self.thread = thread
if self.account:
@@ -135,6 +134,8 @@ class Plugin(object):
else:
self.req.clearCookies()
+ self.setup()
+
self.pyfile.setStatus("starting")
return self.process(self.pyfile)
diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py
index 1e42e5a63..a911cdd1e 100644
--- a/module/plugins/PluginManager.py
+++ b/module/plugins/PluginManager.py
@@ -282,8 +282,12 @@ class PluginManager():
if value.has_key("class"):
classes.append(value["class"])
continue
-
- if not self.core.config.getPlugin(name, "load"):
+
+ try:
+ if not self.core.config.getPlugin(name, "load"):
+ continue
+ except:
+ self.log.debug("Failed to load %s" % name)
continue
try:
diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py
index 20cff6e63..a7bc85856 100644
--- a/module/plugins/hoster/MegauploadCom.py
+++ b/module/plugins/hoster/MegauploadCom.py
@@ -9,6 +9,8 @@ from module.network.RequestFactory import getURL
from module.unescape import unescape
+from pycurl import error
+
def getInfo(urls):
url = "http://megaupload.com/mgr_linkcheck.php"
@@ -98,7 +100,24 @@ class MegauploadCom(Hoster):
else:
self.download_api()
pyfile.name = self.get_file_name()
- self.download(pyfile.url)
+
+ try:
+ self.download(pyfile.url)
+ except error, e:
+ if e.args and e.args[0] == 33:
+ # undirect download and resume , not a good idea
+ page = self.load(pyfile.url)
+ self.download(re.search(r'href=\"(http://[^\"]*?)\" class=\"down_ad_butt1\">', page).group(1))
+ return
+ else:
+ raise
+
+ check = self.checkDownload({"dllink": re.compile(r'href=\"(http://[^\"]*?)\" class=\"down_ad_butt1\">')})
+ if check == "dllink":
+ self.log.warning(_("You should enable direct Download in your Megaupload Account settings"))
+
+ pyfile.size = 0
+ self.download(self.lastCheck.group(1))
def download_html(self):
for i in range(3):
diff --git a/module/setup.py b/module/setup.py
index f7b5839e0..39352d6d3 100644
--- a/module/setup.py
+++ b/module/setup.py
@@ -20,14 +20,11 @@ from getpass import getpass
import gettext
from hashlib import sha1
import os
-from os import remove
from os import makedirs
from os.path import abspath
from os.path import dirname
from os.path import exists
-from os.path import isfile
from os.path import join
-import random
import re
from subprocess import PIPE
from subprocess import call
@@ -51,6 +48,22 @@ class Setup():
translation.install(True)
print ""
+ print _("Would you like to configure pyLoad via Webinterface?")
+ print _("You need a Browser and a connection to this PC for it.")
+ viaweb = self.ask(_("Start initial webinterface for configuration?"), "y", bool=True)
+ if viaweb:
+ try:
+ from module.web import ServerThread
+ ServerThread.setup = self
+ from module.web import webinterface
+ webinterface.run_simple()
+ return False
+ except Exception, e:
+ print "Setup failed with this error: ", e
+ print "Falling back to commandline setup."
+
+
+ print ""
print _("Welcome to the pyLoad Configuration Assistent.")
print _("It will check your system and make a basic setup in order to run pyLoad.")
print ""
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py
index 9af888c6e..b343b6526 100644
--- a/module/web/ServerThread.py
+++ b/module/web/ServerThread.py
@@ -1,11 +1,11 @@
#!/usr/bin/env python
from __future__ import with_statement
-from os import makedirs
-from os.path import exists, join
+from os.path import exists
import threading
import logging
core = None
+setup = None
log = logging.getLogger("log")
class WebServer(threading.Thread):
@@ -28,10 +28,6 @@ class WebServer(threading.Thread):
import webinterface
global webinterface
- cache = join("tmp", "jinja_cache")
- if not exists(cache):
- makedirs(cache)
-
if self.https:
if not exists(self.cert) or not exists(self.key):
log.warning(_("SSL certificates not found."))
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index 4d6d4354c..82701e755 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -33,7 +33,7 @@ from urllib import unquote
from bottle import route, static_file, request, response, redirect, HTTPError, error
-from webinterface import PYLOAD, PROJECT_DIR
+from webinterface import PYLOAD, PROJECT_DIR, SETUP
from utils import render_to_response, parse_permissions, parse_userdata, login_required
from filters import relpath, unquotepath
@@ -70,7 +70,7 @@ def base(messages):
@error(500)
def error500(error):
return base(["An Error occured, please enable debug mode to get more details.", error,
- error.traceback.replace("\n", "<br>")])
+ error.traceback.replace("\n", "<br>") if error.traceback else "No Traceback"])
@route('/media/:path#.+#')
@@ -86,7 +86,10 @@ def favicon():
@route('/login', method="GET")
def login():
- return render_to_response("login.html", proc=[pre_processor])
+ if not PYLOAD and SETUP:
+ redirect("/setup")
+ else:
+ return render_to_response("login.html", proc=[pre_processor])
@route("/login", method="POST")
def login_post():
@@ -285,7 +288,7 @@ def config():
elif not data["trafficleft"]:
data["trafficleft"] = _("not available")
else:
- data["trafficleft"] = formatSize(data["trafficleft"])
+ data["trafficleft"] = formatSize(data["trafficleft"] * 1024)
if data["validuntil"] == -1:
data["validuntil"] = _("unlimited")
@@ -493,4 +496,12 @@ def logs(item=-1):
@route("/admin")
def admin():
- return base([]) \ No newline at end of file
+ return base(["Comming Soon."])
+
+
+@route("/setup")
+def setup():
+ if PYLOAD or not SETUP:
+ return base([_("Run pyLoadCore.py -s to access the setup.")])
+
+ return render_to_response('setup.html', {"user" : False, "perms": False})
diff --git a/module/web/templates/jinja/default/base.html b/module/web/templates/jinja/default/base.html
index 04c6dfbad..f5e2b9634 100644
--- a/module/web/templates/jinja/default/base.html
+++ b/module/web/templates/jinja/default/base.html
@@ -201,7 +201,9 @@ function AddBox()
<div id="head-panel">
+
<div id="head-search-and-login">
+ {% block headpanel %}
{% if user.is_authenticated %}
@@ -222,6 +224,7 @@ function AddBox()
<span style="padding-right: 2px;">{{_("Please Login!")}}</span>
{% endif %}
+ {% endblock %}
</div>
<a href="/"><img id="head-logo" src="/media/default/img/pyload-logo-edited3.5-new-font-small.png" alt="pyLoad" /></a>
@@ -293,6 +296,7 @@ function AddBox()
<div class="level1" style="clear:both">
</div>
+<noscript><h1>Enable JavaScript to use the webinterface.</h1></noscript>
{% for message in messages %}
<b><p>{{message}}</p></b>
diff --git a/module/web/templates/jinja/default/setup.html b/module/web/templates/jinja/default/setup.html
new file mode 100644
index 000000000..39ef6f1e8
--- /dev/null
+++ b/module/web/templates/jinja/default/setup.html
@@ -0,0 +1,13 @@
+{% extends 'default/base.html' %}
+
+{% block title %}{{ _("Setup") }} - {{ super() }} {% endblock %}
+{% block subtitle %}{{ _("Setup") }}{% endblock %}
+{% block headpanel %}Welcome to pyLoad{% endblock %}
+{% block menu %}
+ <li style="height: 25px"> <!-- Needed to get enough margin -->
+ </li>
+{% endblock %}
+
+{% block content %}
+ Comming Soon.
+{% endblock %} \ No newline at end of file
diff --git a/module/web/webinterface.py b/module/web/webinterface.py
index ef5046f44..0d94fb4dc 100644
--- a/module/web/webinterface.py
+++ b/module/web/webinterface.py
@@ -36,13 +36,21 @@ from bottle import run, app
from jinja2 import Environment, FileSystemLoader, PrefixLoader, FileSystemBytecodeCache
from middlewares import StripPathMiddleware, GZipMiddleWare
-try:
- import module.web.ServerThread
+SETUP = None
+PYLOAD = None
- if not module.web.ServerThread.core:
- raise Exception
- PYLOAD = module.web.ServerThread.core.server_methods
- config = module.web.ServerThread.core.config
+try:
+ from module.web import ServerThread
+
+ if not ServerThread.core:
+ if ServerThread.setup:
+ SETUP = ServerThread.setup
+ config = SETUP.config
+ else:
+ raise Exception
+ else:
+ PYLOAD = ServerThread.core.server_methods
+ config = ServerThread.core.config
except:
import xmlrpclib
@@ -85,7 +93,11 @@ LOG_ROOT = config.get('log', 'log_folder')
DEBUG = config.get("general","debug_mode")
bottle.debug(DEBUG)
-bcc = FileSystemBytecodeCache(join("tmp","jinja_cache"))
+cache = join("tmp", "jinja_cache")
+if not exists(cache):
+ makedirs(cache)
+
+bcc = FileSystemBytecodeCache(cache)
loader = PrefixLoader({
"default": FileSystemLoader(join(PROJECT_DIR, "templates", "jinja", "default"))
})
diff --git a/pyLoadCli.py b/pyLoadCli.py
index 415025fa0..dc22f8d3b 100755
--- a/pyLoadCli.py
+++ b/pyLoadCli.py
@@ -578,8 +578,8 @@ if __name__ == "__main__":
interactive = False
command = None
- shortOptions = 'ilu:p:a:hc'
- longOptions = ['interactive', 'local', "username=", "pw=", "address=", "port=", "help", "commands"]
+ shortOptions = 'iu:p:a:hc'
+ longOptions = ['interactive', "username=", "pw=", "address=", "port=", "help", "commands"]
try:
opts, extraparams = getopt(sys.argv[1:], shortOptions, longOptions)