avahi: Minor fixes

- PEP8 fixes.

- Don't need to disable .socket and .service.  Disabling .service will
  take care of disabling both.

- Update the introduction message.

- Add prefix to form so that it can potentially be mixed with other
  forms.
This commit is contained in:
Sunil Mohan Adapa 2015-10-07 01:06:27 +05:30
parent e6f7e6020f
commit 94cdd19070
6 changed files with 19 additions and 21 deletions

View File

@ -17,7 +17,7 @@
#
"""
Configuration helper for service discovery
Configuration helper for service discovery.
"""
import argparse
@ -38,14 +38,12 @@ def parse_arguments():
def subcommand_enable(_):
"""Start service."""
action_utils.service_enable('avahi-daemon.socket')
action_utils.service_enable('avahi-daemon.service')
action_utils.service_enable('avahi-daemon')
def subcommand_disable(_):
"""Stop service."""
action_utils.service_disable('avahi-daemon.service')
action_utils.service_disable('avahi-daemon.socket')
action_utils.service_disable('avahi-daemon')
def main():

View File

@ -16,7 +16,7 @@
#
"""
Plinth module for service discovery
Plinth module for service discovery.
"""
from gettext import gettext as _
@ -40,7 +40,7 @@ def init():
menu.add_urlname(_('Service Discovery'), 'glyphicon-lamp',
'avahi:index', 950)
global service # pylint: disable=W0603
global service # pylint: disable=W0603
service = service_module.Service(
'avahi', _('Service Discovery'), ['mdns'],
is_external=False, enabled=is_enabled())

View File

@ -16,7 +16,7 @@
#
"""
Plinth module for service discovery forms
Plinth module for service discovery forms.
"""
from django import forms

View File

@ -24,12 +24,12 @@
<h2>Service Discovery</h2>
<p>Service discovery is a program that can discover other machines and services
running on your local network. It can also helps those other machines find your
FreedomBox, and the services running on it. Service discovery is not required,
though. Some users decide to disable it to minimize the
<a href="https://en.wikipedia.org/wiki/Attack_surface">attack surface</a>
of their FreedomBox.
<p>Service discovery allows other machines on the network to discover
your FreedomBox and services running on it. It also allows
FreedomBox to discover other machines and services running on your
local network. Service discovery is not essential and works only on
internal networks. It may be disabled to improve security
especially when connecting to a hostile local network.</p>
<h3>Status</h3>

View File

@ -16,12 +16,12 @@
#
"""
URLs for the service discovery module
URLs for the service discovery module.
"""
from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable=C0103
urlpatterns = patterns( # pylint: disable=C0103
'plinth.modules.avahi.views',
url(r'^sys/avahi/$', 'index', name='index'),
)

View File

@ -16,7 +16,7 @@
#
"""
Plinth module for service discovery views
Plinth module for service discovery views.
"""
from django.contrib import messages
@ -30,7 +30,7 @@ from plinth import package
from plinth.modules import avahi
logger = logging.getLogger(__name__) # pylint: disable=C0103
logger = logging.getLogger(__name__) # pylint: disable=C0103
@package.required(['avahi-daemon'])
@ -41,13 +41,13 @@ def index(request):
form = None
if request.method == 'POST':
form = ServiceDiscoveryForm(request.POST)
form = ServiceDiscoveryForm(request.POST, prefix='avahi')
if form.is_valid():
_apply_changes(request, status, form.cleaned_data)
status = get_status()
form = ServiceDiscoveryForm(initial=status)
form = ServiceDiscoveryForm(initial=status, prefix='avahi')
else:
form = ServiceDiscoveryForm(initial=status)
form = ServiceDiscoveryForm(initial=status, prefix='avahi')
return TemplateResponse(request, 'avahi.html',
{'title': _('Service Discovery'),