From 51e6aa3df6bcf240140a389252202c8706f9c130 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 10 May 2015 10:08:06 +0530 Subject: [PATCH] deluge: Rename from bittorrent to deluge - There could be multiple applications for the same functions. Although in the interface we should we show generic names like 'BitTorrent', we could use specific names in the backend. - There is already a bittorrent client: Transmission. --- actions/{bittorrent => deluge} | 15 ++++++----- data/etc/plinth/modules-enabled/bittorrent | 1 - data/etc/plinth/modules-enabled/deluge | 1 + .../{bittorrent => deluge}/__init__.py | 4 +-- .../modules/{bittorrent => deluge}/forms.py | 8 +++--- .../templates/deluge.html} | 6 ++--- plinth/modules/{bittorrent => deluge}/urls.py | 10 +++---- .../modules/{bittorrent => deluge}/views.py | 26 +++++++++---------- 8 files changed, 37 insertions(+), 34 deletions(-) rename actions/{bittorrent => deluge} (94%) delete mode 100644 data/etc/plinth/modules-enabled/bittorrent create mode 100644 data/etc/plinth/modules-enabled/deluge rename plinth/modules/{bittorrent => deluge}/__init__.py (89%) rename plinth/modules/{bittorrent => deluge}/forms.py (82%) rename plinth/modules/{bittorrent/templates/bittorrent.html => deluge/templates/deluge.html} (89%) rename plinth/modules/{bittorrent => deluge}/urls.py (76%) rename plinth/modules/{bittorrent => deluge}/views.py (76%) diff --git a/actions/bittorrent b/actions/deluge similarity index 94% rename from actions/bittorrent rename to actions/deluge index 77f4ae4b1..4d71d0118 100755 --- a/actions/bittorrent +++ b/actions/deluge @@ -29,6 +29,12 @@ import subprocess SITE_CONF = '/etc/apache2/conf-available/deluge-web.conf' SITE_ENABLED = '/etc/apache2/conf-enabled/deluge-web.conf' +APACHE_CONF = ''' + + ProxyPass http://localhost:8112 + +''' + def parse_arguments(): """Return parsed command line arguments as dictionary.""" @@ -70,6 +76,7 @@ def subcommand_enable(_): """Enable deluge-web site and start deluge-web.""" if not os.path.isfile(SITE_CONF): setup() + subprocess.check_call(['a2enconf', 'deluge-web']) subprocess.check_call(['service', 'apache2', 'reload']) @@ -98,7 +105,7 @@ def subcommand_start(_): '--name', 'deluge-web', '--exec', '/usr/bin/deluge-web', '--chuid', 'debian-deluged', - '--', '--base=bittorrent']) + '--', '--base=deluge']) def subcommand_stop(_): @@ -109,11 +116,7 @@ def subcommand_stop(_): def setup(): """Perform initial setup for deluge-web site.""" with open(SITE_CONF, 'w') as conffile: - conffile.writelines([ - '\n', - ' ProxyPass http://localhost:8112\n', - '\n', - ]) + conffile.write(APACHE_CONF) def main(): diff --git a/data/etc/plinth/modules-enabled/bittorrent b/data/etc/plinth/modules-enabled/bittorrent deleted file mode 100644 index cb3cdd997..000000000 --- a/data/etc/plinth/modules-enabled/bittorrent +++ /dev/null @@ -1 +0,0 @@ -plinth.modules.bittorrent diff --git a/data/etc/plinth/modules-enabled/deluge b/data/etc/plinth/modules-enabled/deluge new file mode 100644 index 000000000..abaebc363 --- /dev/null +++ b/data/etc/plinth/modules-enabled/deluge @@ -0,0 +1 @@ +plinth.modules.deluge diff --git a/plinth/modules/bittorrent/__init__.py b/plinth/modules/deluge/__init__.py similarity index 89% rename from plinth/modules/bittorrent/__init__.py rename to plinth/modules/deluge/__init__.py index 6e9171f65..d05a08148 100644 --- a/plinth/modules/bittorrent/__init__.py +++ b/plinth/modules/deluge/__init__.py @@ -16,7 +16,7 @@ # """ -Plinth module to configure a BitTorrent web client (deluge-web) +Plinth module to configure a Deluge web client """ from gettext import gettext as _ @@ -31,4 +31,4 @@ def init(): """Initialize the BitTorrent module.""" menu = cfg.main_menu.get('apps:index') menu.add_urlname(_('BitTorrent (Deluge)'), 'glyphicon-magnet', - 'bittorrent:index', 60) + 'deluge:index', 60) diff --git a/plinth/modules/bittorrent/forms.py b/plinth/modules/deluge/forms.py similarity index 82% rename from plinth/modules/bittorrent/forms.py rename to plinth/modules/deluge/forms.py index 1cb12ece4..45e1995a5 100644 --- a/plinth/modules/bittorrent/forms.py +++ b/plinth/modules/deluge/forms.py @@ -16,15 +16,15 @@ # """ -Forms for configuring BitTorrent web client +Forms for configuring Deluge web client. """ from django import forms from gettext import gettext as _ -class BitTorrentForm(forms.Form): - """BitTorrent configuration form.""" +class DelugeForm(forms.Form): + """Deluge configuration form.""" enabled = forms.BooleanField( - label=_('Enable BitTorrent web client'), + label=_('Enable Deluge web client'), required=False) diff --git a/plinth/modules/bittorrent/templates/bittorrent.html b/plinth/modules/deluge/templates/deluge.html similarity index 89% rename from plinth/modules/bittorrent/templates/bittorrent.html rename to plinth/modules/deluge/templates/deluge.html index 4e0df584e..3405a1777 100644 --- a/plinth/modules/bittorrent/templates/bittorrent.html +++ b/plinth/modules/deluge/templates/deluge.html @@ -27,7 +27,7 @@

Deluge is a BitTorrent client that features a Web UI.

When enabled, the Deluge web client will be available from - /bittorrent path on the web server. The default + /deluge path on the web server. The default password is 'deluge', but you should log in and change it immediately after enabling this service.

@@ -50,7 +50,7 @@

{% if status.is_running %} deluge-web is running -

+ {% csrf_token %} @@ -58,7 +58,7 @@ {% else %} deluge-web is not running - + {% csrf_token %} diff --git a/plinth/modules/bittorrent/urls.py b/plinth/modules/deluge/urls.py similarity index 76% rename from plinth/modules/bittorrent/urls.py rename to plinth/modules/deluge/urls.py index 4b6ff949d..e02079c96 100644 --- a/plinth/modules/bittorrent/urls.py +++ b/plinth/modules/deluge/urls.py @@ -16,15 +16,15 @@ # """ -URLs for the BitTorrent module +URLs for the Deluge module. """ from django.conf.urls import patterns, url urlpatterns = patterns( - 'plinth.modules.bittorrent.views', - url(r'^apps/bittorrent/$', 'index', name='index'), - url(r'^apps/bittorrent/start/$', 'start', name='start'), - url(r'^apps/bittorrent/stop/$', 'stop', name='stop'), + 'plinth.modules.deluge.views', + url(r'^apps/deluge/$', 'index', name='index'), + url(r'^apps/deluge/start/$', 'start', name='start'), + url(r'^apps/deluge/stop/$', 'stop', name='stop'), ) diff --git a/plinth/modules/bittorrent/views.py b/plinth/modules/deluge/views.py similarity index 76% rename from plinth/modules/bittorrent/views.py rename to plinth/modules/deluge/views.py index c0400286d..f732f33f2 100644 --- a/plinth/modules/bittorrent/views.py +++ b/plinth/modules/deluge/views.py @@ -16,7 +16,7 @@ # """ -Plinth module to configure a BitTorrent web client (deluge-web) +Plinth module to configure a Deluge web client. """ from django.contrib import messages @@ -27,7 +27,7 @@ from django.template.response import TemplateResponse from django.views.decorators.http import require_POST from gettext import gettext as _ -from .forms import BitTorrentForm +from .forms import DelugeForm from plinth import actions from plinth import package @@ -41,16 +41,16 @@ def index(request): form = None if request.method == 'POST': - form = BitTorrentForm(request.POST, prefix='bittorrent') + form = DelugeForm(request.POST, prefix='deluge') # pylint: disable=E1101 if form.is_valid(): _apply_changes(request, status, form.cleaned_data) status = get_status() - form = BitTorrentForm(initial=status, prefix='bittorrent') + form = DelugeForm(initial=status, prefix='deluge') else: - form = BitTorrentForm(initial=status, prefix='bittorrent') + form = DelugeForm(initial=status, prefix='deluge') - return TemplateResponse(request, 'bittorrent.html', + return TemplateResponse(request, 'deluge.html', {'title': _('BitTorrent (Deluge)'), 'status': status, 'form': form}) @@ -60,24 +60,24 @@ def index(request): @require_POST def start(request): """Start deluge-web.""" - actions.run('bittorrent', ['start']) - return redirect(reverse_lazy('bittorrent:index')) + actions.run('deluge', ['start']) + return redirect(reverse_lazy('deluge:index')) @login_required @require_POST def stop(request): """Stop deluge-web.""" - actions.run('bittorrent', ['stop']) - return redirect(reverse_lazy('bittorrent:index')) + actions.run('deluge', ['stop']) + return redirect(reverse_lazy('deluge:index')) def get_status(): """Get the current settings.""" - output = actions.run('bittorrent', ['get-enabled']) + output = actions.run('deluge', ['get-enabled']) enabled = (output.strip() == 'yes') - output = actions.run('bittorrent', ['is-running']) + output = actions.run('deluge', ['is-running']) is_running = ('yes' in output.strip()) status = {'enabled': enabled, @@ -92,7 +92,7 @@ def _apply_changes(request, old_status, new_status): if old_status['enabled'] != new_status['enabled']: sub_command = 'enable' if new_status['enabled'] else 'disable' - actions.superuser_run('bittorrent', [sub_command]) + actions.superuser_run('deluge', [sub_command]) modified = True if modified: