diff --git a/deluge/ui/webui/lib/newforms_plus.py b/deluge/ui/webui/lib/newforms_plus.py index 2e43448f5..05b88fb19 100644 --- a/deluge/ui/webui/lib/newforms_plus.py +++ b/deluge/ui/webui/lib/newforms_plus.py @@ -1,7 +1,12 @@ # -*- coding: utf-8 -*- # # Copyright (C) Martijn Voncken 2008 -# Django Licence, see ./newforms_portable/LICENCE +# +# FilteredForm contains code copied from django newforms : +# Copyright (c) 2005, the Lawrence Journal-World +# +# All code in this file under Django Licence +# See ./newforms_portable/LICENCE # from newforms_portable import * @@ -9,7 +14,6 @@ import newforms_portable as newforms from newforms_portable.forms import BoundField from newforms_portable.util import ErrorList, escape - import sys, os import web diff --git a/deluge/ui/webui/page_decorators.py b/deluge/ui/webui/page_decorators.py index 741dec41c..97084f93b 100644 --- a/deluge/ui/webui/page_decorators.py +++ b/deluge/ui/webui/page_decorators.py @@ -1,3 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# deluge_webserver.py +# +# Copyright (C) Martijn Voncken 2008 +# +# 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, 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, write to: +# The Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor +# Boston, MA 02110-1301, USA. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the OpenSSL +# library. +# You must obey the GNU General Public License in all respects for all of +# the code used other than OpenSSL. If you modify file(s) with this +# exception, you may extend this exception to your version of the file(s), +# but you are not obligated to do so. If you do not wish to do so, delete +# this exception statement from your version. If you delete this exception +# statement from all source files in the program, then also delete it here. + """ decorators for html-pages. """ diff --git a/deluge/ui/webui/run_devserver b/deluge/ui/webui/run_devserver index 4f9cc7970..64053f81e 100755 --- a/deluge/ui/webui/run_devserver +++ b/deluge/ui/webui/run_devserver @@ -1,4 +1,36 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# deluge_webserver.py +# +# Copyright (C) Martijn Voncken 2008 +# +# 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, 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, write to: +# The Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor +# Boston, MA 02110-1301, USA. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the OpenSSL +# library. +# You must obey the GNU General Public License in all respects for all of +# the code used other than OpenSSL. If you modify file(s) with this +# exception, you may extend this exception to your version of the file(s), +# but you are not obligated to do so. If you do not wish to do so, delete +# this exception statement from your version. If you delete this exception +# statement from all source files in the program, then also delete it here. + #only for development/debugging. import deluge_webserver diff --git a/deluge/ui/webui/scripts/add_torrent_to_deluge_webui b/deluge/ui/webui/scripts/add_torrent_to_deluge_webui deleted file mode 100755 index 740857ccb..000000000 --- a/deluge/ui/webui/scripts/add_torrent_to_deluge_webui +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -pwd=deluge -url=http://localhost:8112 - -for arg in "$@" -do - curl -F torrent=@"$arg" -F pwd=$pwd $url/remote/torrent/add -done - diff --git a/deluge/ui/webui/scripts/add_torrents_to_deluge.user.js b/deluge/ui/webui/scripts/add_torrents_to_deluge.user.js deleted file mode 100644 index ca6c59efc..000000000 --- a/deluge/ui/webui/scripts/add_torrents_to_deluge.user.js +++ /dev/null @@ -1,207 +0,0 @@ -// ==UserScript== -// @name Add Torrents To Deluge -// @namespace http://blog.monstuff.com/archives/cat_greasemonkey.html -// @description Let's you add torrents to the deluge WebUi -// @include http://isohunt.com/torrent_details/* -// @include http://thepiratebay.org/details.php?* -// @include http://torrentreactor.net/view.php?* -// @include http://www.mininova.org/* -// @include http://www.torrentspy.com/* -// @include http://ts.searching.com/* -// @include * -// ==/UserScript== - -//url-based submit and parsing based on : "Add Torrents To utorrent" by Julien Couvreur -//binary magic,contains from http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html - -//these parameters need to be edited before using the script - -// Server address -var host = "localhost"; -// Server port -var port = "8112"; -//open_page: "_blank" for a new window or "deluge_webui" for window re-use -//(not for private=1) -var open_page = "_blank" -//Private-trackers 0/1 -//different behavior, gets torrent-data from (private) site and pops up a message. -var private_submit = 1; -//deluge_password, only needed if private_submit = 1. -var deluge_password = 'deluge'; -//======================== - - -if (host == "") { alert('You need to configure the "Add Torrents To Deluge" user script with your WebUI parameters before using it.'); } - - - -function scanLinks() { - var links = getLinks(); - - for (var i=0; i < links.length; i++){ - var link = links[i]; - if (match(link.href)) { - if (private_submit) { - makeUTorrentLink_private(link,i); - } - else { - makeUTorrentLink(link); - } - } - } -} - -function makeUTorrentLink(link) { - var uTorrentLink = document.createElement('a'); - uTorrentLink.setAttribute("href", makeUTorrentUrl(link.href)); - uTorrentLink.setAttribute("target", open_page); - uTorrentLink.style.paddingLeft = "5px"; - uTorrentLink.innerHTML = ""; - link.parentNode.insertBefore(uTorrentLink, link.nextSibling); - return uTorrentLink -} - -function makeUTorrentUrl(url) { - var uTorrentUrl = "http://"+host+":"+port+"/torrent/add?redir_after_login=1"; - return uTorrentUrl + "&url=" + escape(url); -} - -function makeUTorrentLink_private(link,i) { - var id = 'deluge_link' + i; - var uTorrentLink = document.createElement('a'); - uTorrentLink.setAttribute("href", '#'); - uTorrentLink.setAttribute("id", id); - uTorrentLink.style.paddingLeft = "5px"; - uTorrentLink.innerHTML = ""; - link.parentNode.insertBefore(uTorrentLink, link.nextSibling); - - ulink = document.getElementById(id) - ulink.addEventListener("click", evt_private_submit_factory(link.href),false); - - return uTorrentLink -} - -function evt_private_submit_factory(url) { - //can this be done without magic? - function evt_private_submit(evt) { - GM_xmlhttpRequest({ method: 'GET', url: url, - overrideMimeType: 'text/plain; charset=x-user-defined', - onload: function(xhr) { - var stream = translateToBinaryString(xhr.responseText); - var data_b64 = window.btoa(stream); - post_to_webui(url, data_b64); - }, - onerror:function(xhr) { - alert('error fetching torrent file'); - } - }); - return false; - } - return evt_private_submit; -} - - -function post_to_webui(url,data_b64){ - //alert('here1'); - //data contains the content of the .torrent-file. - var POST_data = ('pwd=' + encodeURIComponent(deluge_password) + - '&torrent_name=' + encodeURIComponent(url) + '.torrent' + //+.torrent is a clutch! - '&data_b64=' + encodeURIComponent(data_b64) ); - //alert(POST_data); - - GM_xmlhttpRequest({ method: 'POST', - url: "http://"+host+":"+port+"/remote/torrent/add", - headers:{'Content-type':'application/x-www-form-urlencoded'}, - data: POST_data, - onload: function(xhr) { - if (xhr.responseText == 'ok\n') { - alert('Added torrent to webui : \n' + url); - } - else { - alert('Error adding torrent to webui:\n"' + xhr.responseText + '"'); - } - - }, - onerror:function(xhr) { - alert('error submitting torrent file'); - } - - }); -} - - - - - -function match(url) { - - // isohunt format - if (url.match(/http:\/\/.*isohunt\.com\/download\//i)) { - return true; - } - - if (url.match(/\.torrent$/)) { - return true; - } - - if (url.match(/http:\/\/.*bt-chat\.com\/download\.php/)) { - return true; - } - - // TorrentReactor - if (url.match(/http:\/\/dl\.torrentreactor\.net\/download.php\?/i)) { - return true; - } - - // Mininova - if (url.match(/http:\/\/www\.mininova\.org\/get\//i)) { - return true; - } - - // Mininova - if (url.match(/http:\/\/www\.mininova\.org\/get\//i)) { - return true; - } - - // TorrentSpy - if (url.match(/http:\/\/ts\.searching\.com\/download\.asp\?/i)) { - return true; - } - if (url.match(/http:\/\/www\.torrentspy\.com\/download.asp\?/i)) { - return true; - } - - // Seedler - if (url.match(/http:\/\/.*seedler\.org\/download\.x\?/i)) { - return true; - } - return false; -} - - -function getLinks() { - var doc_links = document.links; - var links = new Array(); - for (var i=0; i < doc_links.length; i++){ - links.push(doc_links[i]); - } - return links; -} - -var image = "data:image/gif;base64,R0lGODlhEAAQAMZyAB1CdihAYx5CdiBEeCJGeSZJfChKfChLfSpPgTBRgThRdDRUgzRVhDVWhDZWhThYhjtbiD1ciD5diT5eiz9eikBeiUFeiT5fjT1gjkBfjERijkdjiUhljkVnlEdolUxokExqkk5qkU9rklBrklFtk1BullFulk5vmlZymFx3nE97rVZ5pUx8sl54nlt5oVl6pE5/tWJ6nVp9qFqArWOEq1uIuW6EpGCItl2Ku26Gp2KKuGuIrF+MvWaLtl+Nv3KJqG+KrGaOu2aQv2SRwnGOs2uQvGqSwICOpoCQqm6Ww3OVvHKWv3iWuoKWsn+XtnacxXaeynifyXigzICewn2gxnqizoqfunujzpWesX6l0IyivYijw4+jvpOiuoOp0puktY2x2I6y2Y+z2pG02pW43Ze42pa43Z/A4qjG56jH56nI6KzJ6a/M67nR67zW8sLa9cff+M/k+P///////////////////////////////////////////////////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgB/ACwAAAAAEAAQAAAHkIB/goOEhYaCX1iHhkdIXU2LgzFARExbkYInCBcvRVSRHgQNEiYoPUmHGAkjO1FSSilBNYYQFTllY2BeSzJChg4iWmhpZ2JXOjgqhBMFH1xvbmtmWUMwM4QZBws/cXBsZFU+LCuFDwIhVm1qYVA8Nx2FEQQDHDZOU09GNIcWDAAGFEC0cBEpwAYNJUgowMQwEAA7"; - -scanLinks(); - -/* -binary magic,contains code taken from -http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html -*/ -function translateToBinaryString(text){ - var out; - out=''; - for(i=0;i +# +# 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, 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, write to: +# The Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor +# Boston, MA 02110-1301, USA. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the OpenSSL +# library. +# You must obey the GNU General Public License in all respects for all of +# the code used other than OpenSSL. If you modify file(s) with this +# exception, you may extend this exception to your version of the file(s), +# but you are not obligated to do so. If you do not wish to do so, delete +# this exception statement from your version. If you delete this exception +# statement from all source files in the program, then also delete it here. + + import os import re template_dirs = ['~/prj/WebUi/templates/deluge', diff --git a/deluge/ui/webui/tests/multicall_notepad.py b/deluge/ui/webui/tests/multicall_notepad.py deleted file mode 100644 index 4781e5d3f..000000000 --- a/deluge/ui/webui/tests/multicall_notepad.py +++ /dev/null @@ -1,102 +0,0 @@ -""" -test multicall. -""" -import time - -from WebUi.webserver_common import ws, proxy, async_proxy -ws.init_06() - -TORRENT_KEYS = ['name', 'total_size', 'num_files', 'num_pieces', 'piece_length', - 'eta', 'ratio', 'file_progress', 'distributed_copies', 'total_done', - 'total_uploaded', 'state', 'paused', 'progress', 'next_announce', - 'total_payload_download', 'total_payload_upload', 'download_payload_rate', - 'upload_payload_rate', 'num_peers', 'num_seeds', 'total_peers', 'total_seeds', - 'total_wanted', 'tracker', 'trackers', 'tracker_status', 'save_path', - 'files', 'file_priorities', 'compact', 'max_connections', - 'max_upload_slots', 'max_download_speed', 'prioritize_first_last', 'private' - ] - -if False: - # - #A: translate this into 1 multicall: - - start = time.time() - stats = { - 'download_rate':proxy.get_download_rate(), - 'upload_rate':proxy.get_upload_rate(), - 'max_download':proxy.get_config_value('max_download_speed'), - 'max_upload':proxy.get_config_value('max_upload_speed'), - 'num_connections':proxy.get_num_connections(), - 'max_num_connections':proxy.get_config_value('max_connections_global') - } - - print "sync-stats:",time.time() - start - - print stats - - # - #map callback to a a dict-setter - def dict_cb(key,d): - def callback(result): - d[key] = result - return callback - - start = time.time() - d = {} - async_proxy.get_download_rate(dict_cb('download_rate',d)) - async_proxy.get_upload_rate(dict_cb('upload_rate',d)) - async_proxy.get_config_value(dict_cb('max_download',d),"max_download_speed") - async_proxy.get_config_value(dict_cb('max_upload',d),"max_upload_speed") - async_proxy.get_num_connections(dict_cb("num_connections",d)) - async_proxy.get_config_value(dict_cb('max_num_connections',d),"max_connections_global") - - async_proxy.force_call(block=True) - - print "Async-stats:",time.time() - start - print d - - # - #B: translate this to multicall: - # - - #old-sync: - start = time.time() - - torrent_list = [proxy.get_torrent_status(id, TORRENT_KEYS ) - for id in proxy.get_session_state() - ] - - print "sync-list:",time.time() - start - print torrent_list[0] - - #new async: - """ - torrent.compact, - torrent.max_connections, - torrent.max_upload_slots, - torrent.max_upload_speed, - torrent.max_download_speed, - torrent.prioritize_first_last, - torrent.private - """ - - - start = time.time() - - torrent_ids = proxy.get_session_state() #Syc-api. - torrent_dict = {} - for id in torrent_ids: - async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id, TORRENT_KEYS ) - async_proxy.force_call(block=True) - - print "Async-list:",time.time() - start - print "\n".join(torrent_dict[torrent_ids[0]].keys()) - print torrent_dict[torrent_ids[0]] - -if False: - print proxy.get_config_value('download_location') - -if True: - torrent_id = proxy.get_session_state()[0] - print torrent_id - proxy.move_torrent([torrent_id],"/media/sdb1/test") \ No newline at end of file diff --git a/deluge/ui/webui/tests/test_all.py b/deluge/ui/webui/tests/test_all.py index c9f6127ab..63b9854e7 100644 --- a/deluge/ui/webui/tests/test_all.py +++ b/deluge/ui/webui/tests/test_all.py @@ -1,3 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright (C) Martijn Voncken 2008 +# +# 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, 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, write to: +# The Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor +# Boston, MA 02110-1301, USA. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the OpenSSL +# library. +# You must obey the GNU General Public License in all respects for all of +# the code used other than OpenSSL. If you modify file(s) with this +# exception, you may extend this exception to your version of the file(s), +# but you are not obligated to do so. If you do not wish to do so, delete +# this exception statement from your version. If you delete this exception +# statement from all source files in the program, then also delete it here. + """ Testing the REST api, not the units. unittest the right way feels so unpythonic :(