diff options
-rw-r--r-- | module/PluginThread.py | 2 | ||||
-rw-r--r-- | module/web/media/img/dialog-question.png | bin | 0 -> 2073 bytes | |||
-rw-r--r-- | module/web/media/js/admin.coffee | 58 | ||||
-rw-r--r-- | module/web/media/js/admin.js | 1 | ||||
-rw-r--r-- | module/web/templates/default/admin.html | 61 | ||||
-rwxr-xr-x | pyLoadCli.py | 83 | ||||
-rwxr-xr-x | pyLoadCore.py | 11 |
7 files changed, 117 insertions, 99 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py index 967762999..8d1516bde 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -34,7 +34,7 @@ from PyFile import PyFile from plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload from common.packagetools import parseNames from utils import save_join -from remote.thriftbackend.thriftgen.pyload.ttypes import OnlineStatus +from Api import OnlineStatus class PluginThread(Thread): """abstract base class for thread types""" diff --git a/module/web/media/img/dialog-question.png b/module/web/media/img/dialog-question.png Binary files differnew file mode 100644 index 000000000..b0af3db5b --- /dev/null +++ b/module/web/media/img/dialog-question.png diff --git a/module/web/media/js/admin.coffee b/module/web/media/js/admin.coffee new file mode 100644 index 000000000..82b0dd3ec --- /dev/null +++ b/module/web/media/js/admin.coffee @@ -0,0 +1,58 @@ +root = this + +window.addEvent "domready", -> + + root.passwordDialog = new MooDialog {destroyOnHide: false} + root.passwordDialog.setContent $ 'password_box' + + $("login_password_reset").addEvent "click", (e) -> root.passwordDialog.close() + $("login_password_button").addEvent "click", (e) -> + + newpw = $("login_new_password").get("value") + newpw2 = $("login_new_password2").get("value") + + if newpw is newpw2 + form = $("password_form") + form.set "send", { + onSuccess: (data) -> + root.notify.alert "Success", { + 'className': 'success' + } + onFailure: (data) -> + root.notify.alert "Error", { + 'className': 'error' + } + } + + form.send() + + root.passwordDialog.close() + else + alert '{{_("Passwords did not match.")}}' + + e.stop() + + for item in $$(".change_password") + id = item.get("id") + user = id.split("|")[1] + $("user_login").set("value", user) + item.addEvent "click", (e) -> root.passwordDialog.open() + + $('quit-pyload').addEvent "click", (e) -> + new MooDialog.Confirm "{{_('You are really sure you want to quit pyLoad?')}}", -> + new Request.JSON({ + url: '/api/kill' + method: 'get' + }).send() + , -> + e.stop() + + $('restart-pyload').addEvent "click", (e) -> + new MooDialog.Confirm "{{_('Are you sure you want to restart pyLoad?')}}", -> + new Request.JSON({ + url: '/api/restart' + method: 'get' + onSuccess: (data) -> alert "{{_('pyLoad restarted')}}" + }).send() + , -> + e.stop()
\ No newline at end of file diff --git a/module/web/media/js/admin.js b/module/web/media/js/admin.js new file mode 100644 index 000000000..6ecea6514 --- /dev/null +++ b/module/web/media/js/admin.js @@ -0,0 +1 @@ +var root;root=this;window.addEvent("domready",function(){var f,c,b,e,a,d;root.passwordDialog=new MooDialog({destroyOnHide:false});root.passwordDialog.setContent($("password_box"));$("login_password_reset").addEvent("click",function(g){return root.passwordDialog.close()});$("login_password_button").addEvent("click",function(j){var h,i,g;i=$("login_new_password").get("value");g=$("login_new_password2").get("value");if(i===g){h=$("password_form");h.set("send",{onSuccess:function(k){return root.notify.alert("Success",{className:"success"})},onFailure:function(k){return root.notify.alert("Error",{className:"error"})}});h.send();root.passwordDialog.close()}else{alert('{{_("Passwords did not match.")}}')}return j.stop()});d=$$(".change_password");for(e=0,a=d.length;e<a;e++){c=d[e];f=c.get("id");b=f.split("|")[1];$("user_login").set("value",b);c.addEvent("click",function(g){return root.passwordDialog.open()})}$("quit-pyload").addEvent("click",function(g){new MooDialog.Confirm("{{_('You are really sure you want to quit pyLoad?')}}",function(){return new Request.JSON({url:"/api/kill",method:"get"}).send()},function(){});return g.stop()});return $("restart-pyload").addEvent("click",function(g){new MooDialog.Confirm("{{_('Are you sure you want to restart pyLoad?')}}",function(){return new Request.JSON({url:"/api/restart",method:"get",onSuccess:function(h){return alert("{{_('pyLoad restarted')}}")}}).send()},function(){});return g.stop()})});
\ No newline at end of file diff --git a/module/web/templates/default/admin.html b/module/web/templates/default/admin.html index df1843997..b049411fd 100644 --- a/module/web/templates/default/admin.html +++ b/module/web/templates/default/admin.html @@ -1,64 +1,19 @@ {% extends 'default/base.html' %} {% block head %} - <script type="text/javascript"> - - root = this; - - window.addEvent("domready", function() { - - root.passwordDialog = new MooDialog({destroyOnHide: false}); - root.passwordDialog.setContent($('password_box')); - - $("login_password_reset").addEvent("click", function(e) {root.passwordDialog.close();}); - $("login_password_button").addEvent("click", function(e) { - - var current = $("login_current_password").get("value"); - var newpw = $("login_new_password").get("value"); - var newpw2 = $("login_new_password2").get("value"); - - if (newpw == newpw2) { - var form = $("password_form"); - - form.set("send", { - onSuccess: function(data) { - root.notify.alert("Success", { - 'className': 'success' - }); - }, - onFailure: function(data) { - root.notify.alert("Error", { - 'className': 'error' - }); - }}); - - form.send(); - - root.passwordDialog.close(); - } else { - alert("{{_("Passwords did not match.")}}"); - } - e.stop(); - }); - - $$(".change_password").each(function(item) { - var id = item.get("id"); - var user = id.split("|")[1]; - $("user_login").set("value", user); - - item.addEvent("click", function(e) { - root.passwordDialog.open(); - }); - }); - }); - </script> + <script type="text/javascript" src="media/js/admin.js"></script> {% endblock %} -{% block title %}{{ _("Administrate User") }} - {{ super() }} {% endblock %} -{% block subtitle %}{{ _("Administrate User") }}{% endblock %} +{% block title %}{{ _("Administrate") }} - {{ super() }} {% endblock %} +{% block subtitle %}{{ _("Administrate") }}{% endblock %} {% block content %} + + <a href="#" id="quit-pyload" style="font-size: large; font-weight: bold;">{{_("Quit pyLoad")}}</a> | + <a href="#" id="restart-pyload" style="font-size: large; font-weight: bold;">{{_("Restart pyLoad")}}</a> + <br> + <br> {{ _("To add user or change passwords use:") }} <b>python pyLoadCore.py -u</b><br> {{ _("Important: Admin user have always all permissions!") }} diff --git a/pyLoadCli.py b/pyLoadCli.py index 791f642ac..c992914a7 100755 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -33,17 +33,13 @@ from traceback import print_exc import ConfigParser from codecs import getwriter + if os.name == "nt": enc = "cp850" else: enc = "utf8" - -sys.stdout = getwriter(enc)(sys.stdout, errors = "replace") - -#original working dir -OWD = abspath("") - +sys.stdout = getwriter(enc)(sys.stdout, errors="replace") from module import InitHomeDir from module.cli.printer import * @@ -177,10 +173,10 @@ class Cli: println(line, cyan(download.name)) line += 1 println(line, - blue("[") + yellow(z * "#" + (25 - z) * " ") + blue("] ") + green(str(percent) + "%") + _( - " Speed: ") + green(formatSize(download.speed) + "/s") + _(" Size: ") + green( - download.format_size) + _(" Finished in: ") + green(download.format_eta) + _( - " ID: ") + green(download.fid)) + blue("[") + yellow(z * "#" + (25 - z) * " ") + blue("] ") + green(str(percent) + "%") + _( + " Speed: ") + green(formatSize(download.speed) + "/s") + _(" Size: ") + green( + download.format_size) + _(" Finished in: ") + green(download.format_eta) + _( + " ID: ") + green(download.fid)) line += 1 if download.status == 5: println(line, cyan(download.name)) @@ -192,13 +188,13 @@ class Cli: line += 1 status = self.client.statusServer() if status.pause: - paused = _("Status: ") + red("paused") + paused = _("Status:") + " " + red(_("paused")) else: - paused = _("Status: ") + red("running") + paused = _("Status:") + " " + red(_("running")) - println(line, - paused + _(" total Speed: ") + red(formatSize(speed) + "/s") + _( - " Files in queue: ") + red(status.queue) + _(" Total: ") + red(status.total)) + println(line,"%s %s: %s %s: %s %s: %s" % ( + paused, _("total Speed"), red(formatSize(speed) + "/s"), _("Files in queue"), red( + status.queue), _("Total"), red(status.total))) return line + 1 @@ -274,8 +270,8 @@ class Cli: if download.status == 12: # downloading print print_status(download) print "\tDownloading: %s @ %s/s\t %s (%s%%)" % ( - download.format_eta, formatSize(download.speed), formatSize(download.size - download.bleft), - download.percent) + download.format_eta, formatSize(download.speed), formatSize(download.size - download.bleft), + download.percent) elif download.status == 5: print print_status(download) print "\tWaiting: %s" % download.format_wait @@ -318,22 +314,22 @@ class Cli: elif command == "check": print _("Checking %d links:") % len(args) print - rid = client.checkOnlineStatus(args).rid - self.printOnlineCheck(client, rid) + rid = self.client.checkOnlineStatus(args).rid + self.printOnlineCheck(self.client, rid) elif command == "check_container": path = args[0] - if not exists(join(OWD, path)): + if not exists(join(owd, path)): print _("File does not exists.") return - f = open(join(OWD, path), "rb") + f = open(join(owd, path), "rb") content = f.read() f.close() - rid = client.checkOnlineStatusContainer([], basename(f.name), content).rid - self.printOnlineCheck(client, rid) + rid = self.client.checkOnlineStatusContainer([], basename(f.name), content).rid + self.printOnlineCheck(self.client, rid) elif command == "pause": @@ -445,21 +441,21 @@ def print_status(download): def print_commands(): commands = [("status", _("Prints server status")), - ("queue", _("Prints downloads in queue")), - ("collector", _("Prints downloads in collector")), - ("add <name> <link1> <link2>...", _("Adds package to queue")), - ("add_coll <name> <link1> <link2>...", _("Adds package to collector")), - ("del_file <fid> <fid2>...", _("Delete Files from Queue/Collector")), - ("del_package <pid> <pid2>...", _("Delete Packages from Queue/Collector")), - ("move <pid> <pid2>...", _("Move Packages from Queue to Collector or vice versa")), - ("restart_file <fid> <fid2>...", _("Restart files")), - ("restart_package <pid> <pid2>...", _("Restart packages")), - ("check <container|url> ...", _("Check online status, works with local container")), - ("check_container path", _("Checks online status of a container file")), - ("pause", _("Pause the server")), - ("unpause", _("continue downloads")), - ("toggle", _("Toggle pause/unpause")), - ("kill", _("kill server")), ] + ("queue", _("Prints downloads in queue")), + ("collector", _("Prints downloads in collector")), + ("add <name> <link1> <link2>...", _("Adds package to queue")), + ("add_coll <name> <link1> <link2>...", _("Adds package to collector")), + ("del_file <fid> <fid2>...", _("Delete Files from Queue/Collector")), + ("del_package <pid> <pid2>...", _("Delete Packages from Queue/Collector")), + ("move <pid> <pid2>...", _("Move Packages from Queue to Collector or vice versa")), + ("restart_file <fid> <fid2>...", _("Restart files")), + ("restart_package <pid> <pid2>...", _("Restart packages")), + ("check <container|url> ...", _("Check online status, works with local container")), + ("check_container path", _("Checks online status of a container file")), + ("pause", _("Pause the server")), + ("unpause", _("continue downloads")), + ("toggle", _("Toggle pause/unpause")), + ("kill", _("kill server")), ] print _("List of commands:") print @@ -476,7 +472,8 @@ def writeConfig(opts): except: print _("Couldn't write user config file") -if __name__ == "__main__": + +def main(): config = {"addr": "127.0.0.1", "port": "7227", "language": "en"} try: config["language"] = os.environ["LANG"][0:2] @@ -494,7 +491,7 @@ if __name__ == "__main__": config[opt[0]] = opt[1] translation = gettext.translation("pyLoadCli", join(pypath, "locale"), - languages=["en", config["language"]]) + languages=["en", config["language"]]) translation.install(unicode=True) interactive = False @@ -519,7 +516,7 @@ if __name__ == "__main__": elif option in ("-l", "--language"): config["language"] = params translation = gettext.translation("pyLoadCli", join(pypath, "locale"), - languages=["en", config["language"]]) + languages=["en", config["language"]]) translation.install(unicode=True) elif option in ("-h", "--help"): print_help(config) @@ -585,3 +582,7 @@ if __name__ == "__main__": if client: writeConfig(config) cli = Cli(client, command) + + +if __name__ == "__main__": + main()
\ No newline at end of file diff --git a/pyLoadCore.py b/pyLoadCore.py index ae84f111c..ad84bdef5 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -624,14 +624,12 @@ def deamon(): pyload_core.start() -# And so it begins... -if __name__ == "__main__": +def main(): #change name to 'pyLoadCore' #from module.lib.rename_process import renameProcess #renameProcess('pyLoadCore') - if "--daemon" in sys.argv: - deamon() + deamon() else: pyload_core = Core() try: @@ -641,3 +639,8 @@ if __name__ == "__main__": pyload_core.log.info(_("killed pyLoad from Terminal")) pyload_core.removeLogger() _exit(1) + +# And so it begins... +if __name__ == "__main__": + main() + |