fix formatting issues

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Alice Kile authored and James Valleroy committed 2019-12-07 13:08:35 -05:00
1 parent fa74a26042
commit eb83e00011
134 files changed
+598 -720

No files matched your search

+4 -4
View File
@@ -211,7 +211,6 @@ def webserver_disable(name, kind='config', apply_changes=True):
class WebserverChange(object):
"""Context to restart/reload Apache after configuration changes."""
def __init__(self):
"""Initialize the context object state."""
self.actions_required = set()
@@ -425,9 +424,10 @@ def diagnose_url_on_all(url, **kwargs):
def diagnose_netcat(host, port, input='', negate=False):
"""Run a diagnostic using netcat."""
try:
process = subprocess.Popen(
['nc', host, str(port)], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen(['nc', host, str(port)],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
process.communicate(input=input.encode())
if process.returncode != 0:
result = 'failed'
-1
View File
@@ -114,7 +114,6 @@ class Component:
def enable(self):
"""Run operations to enable the component."""
def disable(self):
"""Run operations to disable the component."""
-1
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Django context processors to provide common data to templates.
"""
-1
View File
@@ -23,7 +23,6 @@ from plinth import action_utils, actions, app
class Daemon(app.LeaderComponent):
"""Component to manage a background daemon or any systemd unit."""
def __init__(self, component_id, unit, strict_check=False):
"""Initialize a new daemon component.
-1
View File
@@ -83,7 +83,6 @@ class PackageHandler():
class DBusServer():
"""Abstraction over a connection to D-Bus."""
def __init__(self):
"""Initialize the server object."""
self.package_handler = None
+5 -7
View File
@@ -43,7 +43,6 @@ class DomainSelectionForm(forms.Form):
"""Form for selecting a domain name to be used for
distributed federated applications
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -84,9 +83,9 @@ class LanguageSelectionFormMixin:
plinth_dir = os.path.dirname(plinth.__file__)
if language_code == 'en' or os.path.exists(
os.path.join(plinth_dir, 'locale', locale_code)):
supported_languages.append((language_code,
_get_local_name(
language_code, language_name)))
supported_languages.append(
(language_code,
_get_local_name(language_code, language_name)))
self.fields['language'].choices = supported_languages
@@ -106,7 +105,6 @@ class CheckboxSelectMultipleWithReadOnly(forms.widgets.CheckboxSelectMultiple):
Derived from https://djangosnippets.org/snippets/2786/
"""
def render(self, name, value, attrs=None, choices=(), renderer=None):
if value is None:
value = []
@@ -114,8 +112,8 @@ class CheckboxSelectMultipleWithReadOnly(forms.widgets.CheckboxSelectMultiple):
output = [u'<ul>']
global_readonly = 'readonly' in final_attrs
str_values = set([v for v in value])
for i, (option_value, option_label) in enumerate(
chain(self.choices, choices)):
for i, (option_value,
option_label) in enumerate(chain(self.choices, choices)):
if not global_readonly and 'readonly' in final_attrs:
# If the entire group is readonly keep all options readonly
del final_attrs['readonly']
-1
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Simple key/value store using Django models
"""
+2 -5
View File
@@ -41,7 +41,6 @@ logger = logging.getLogger(__name__)
class SetupMiddleware(MiddlewareMixin):
"""Django middleware to show pre-setup message and setup progress."""
@staticmethod
def process_view(request, view_func, view_args, view_kwargs):
"""Handle a request as Django middleware request handler."""
@@ -77,8 +76,8 @@ class SetupMiddleware(MiddlewareMixin):
str(exception))
error_details = getattr(exception, 'error_details', '')
message = _('Error installing application: {string} '
'{details}').format(
string=error_string, details=error_details)
'{details}').format(string=error_string,
details=error_details)
else:
message = _('Error installing application: {error}') \
.format(error=exception)
@@ -96,7 +95,6 @@ class SetupMiddleware(MiddlewareMixin):
class AdminRequiredMiddleware(MiddlewareMixin):
"""Django middleware for authenticating requests for admin areas."""
@staticmethod
def process_view(request, view_func, view_args, view_kwargs):
"""Reject non-admin access to views that are private and not marked."""
@@ -110,7 +108,6 @@ class AdminRequiredMiddleware(MiddlewareMixin):
class FirstSetupMiddleware(MiddlewareMixin):
"""Django middleware to block all interactions before first setup."""
@staticmethod
def process_view(request, view_func, view_args, view_kwargs):
"""Block all user interactions when first setup is pending."""
+1 -3
View File
@@ -18,7 +18,6 @@
#
# Generated by Django 1.9 on 2015-12-04 07:27
#
"""
Initial Django migration for FreedomBox to create database tables.
"""
@@ -33,8 +32,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
]
dependencies = []
operations = [
migrations.CreateModel(
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Remove the deprecated KVStore entries 'setup_state' and 'firstboot_state',
and only use the new entry 'firstboot_completed' instead.
@@ -63,8 +62,8 @@ def merge_firstboot_finished_fields(apps, schema_editor):
firstboot_completed = _object.value
# Set new 'firstboot_completed' if needed
new_firstboot_completed = bool(firstboot_completed or setup_state or
firstboot_state)
new_firstboot_completed = bool(firstboot_completed or setup_state
or firstboot_state)
if new_firstboot_completed and not firstboot_completed:
obj, created = KVStore.objects.get_or_create(key='firstboot_completed')
obj.value = 1
+11 -8
View File
@@ -30,14 +30,17 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('language', models.CharField(default=None, max_length=32,
null=True)),
('user', models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
], ),
('id',
models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('language',
models.CharField(default=None, max_length=32, null=True)),
('user',
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
],
),
migrations.RunPython(code=insert_users,
reverse_code=truncate_user_profile),
]
+3 -3
View File
@@ -54,9 +54,9 @@ class ApacheApp(app_module.App):
freedombox_ports = Firewall(
'firewall-plinth',
format_lazy(
_('{box_name} Web Interface (Plinth)'), box_name=_(
cfg.box_name)), ports=['http', 'https'], is_external=True)
format_lazy(_('{box_name} Web Interface (Plinth)'),
box_name=_(cfg.box_name)), ports=['http', 'https'],
is_external=True)
self.add(freedombox_ports)
letsencrypt = LetsEncrypt('letsencrypt-apache', domains='*',
-2
View File
@@ -23,7 +23,6 @@ from plinth import action_utils, actions, app
class Webserver(app.LeaderComponent):
"""Component to enable/disable Apache configuration."""
def __init__(self, component_id, web_name, kind='config'):
"""Initialize the web server component.
@@ -62,7 +61,6 @@ class Webserver(app.LeaderComponent):
class Uwsgi(app.LeaderComponent):
"""Component to enable/disable uWSGI configuration."""
def __init__(self, component_id, uwsgi_name):
"""Initialize the uWSGI component.
+1 -3
View File
@@ -14,10 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the Apache module.
"""
urlpatterns = [
]
urlpatterns = []
+2 -3
View File
@@ -45,9 +45,8 @@ def shortcuts(request, **kwargs):
# XXX: Get the module (or module name) from shortcut properly.
username = str(request.user) if request.user.is_authenticated else None
response = get_shortcuts_as_json(username)
return HttpResponse(
json.dumps(response, cls=DjangoJSONEncoder),
content_type='application/json')
return HttpResponse(json.dumps(response, cls=DjangoJSONEncoder),
content_type='application/json')
def get_shortcuts_as_json(username=None):
+4 -3
View File
@@ -91,9 +91,10 @@ def init():
global app
app = AvahiApp()
if app.is_enabled():
domain_added.send_robust(
sender='avahi', domain_type='domain-type-local',
name=get_hostname() + '.local', services='__all__')
domain_added.send_robust(sender='avahi',
domain_type='domain-type-local',
name=get_hostname() + '.local',
services='__all__')
app.set_enabled(True)
post_hostname_change.connect(on_post_hostname_change)
+2 -3
View File
@@ -108,9 +108,8 @@ def _backup_handler(packet, encryption_passphrase=None):
arguments = ['create-archive', '--path', packet.path, '--paths'] + paths
input_data = ''
if encryption_passphrase:
input_data = json.dumps({
'encryption_passphrase': encryption_passphrase
})
input_data = json.dumps(
{'encryption_passphrase': encryption_passphrase})
actions.superuser_run('backups', arguments, input=input_data.encode())
-6
View File
@@ -82,7 +82,6 @@ def _validate_service(service):
class BackupError:
"""Represent an backup/restore operation error."""
def __init__(self, error_type, app, hook=None):
"""Initialize the error object."""
self.error_type = error_type
@@ -98,7 +97,6 @@ class BackupError:
class Packet:
"""Information passed to a handlers for backup/restore operations."""
def __init__(self, operation, scope, root, apps=None, path=None):
"""Initialize the packet.
@@ -240,7 +238,6 @@ def _install_apps_before_restore(apps):
class BackupApp:
"""A application that can be backed up and its manifest."""
def __init__(self, name, app):
"""Initialize object and load manfiest."""
self.name = name
@@ -365,7 +362,6 @@ def _switch_to_subvolume(subvolume):
class ServiceHandler:
"""Abstraction to help with service shutdown/restart."""
@staticmethod
def create(backup_app, service):
service_type = 'system'
@@ -400,7 +396,6 @@ class ServiceHandler:
class SystemServiceHandler(ServiceHandler):
"""Handle starting and stopping of system services for backup."""
def __init__(self, backup_app, service):
"""Initialize the object."""
super().__init__(backup_app, service)
@@ -420,7 +415,6 @@ class SystemServiceHandler(ServiceHandler):
class ApacheServiceHandler(ServiceHandler):
"""Handle starting and stopping of Apache services for backup."""
def __init__(self, backup_app, service):
"""Initialize the object."""
super().__init__(backup_app, service)
-1
View File
@@ -30,7 +30,6 @@ def delete_tmp_backup_file(function):
XXX: Implement a better way to delete uploaded files.
"""
@functools.wraps(function)
def wrapper(request, *args, **kwargs):
path = request.session.get(SESSION_PATH_VARIABLE, None)
+2 -7
View File
@@ -59,10 +59,8 @@ KNOWN_ERRORS = [
'errors': [
'not a valid repository', 'does not exist', 'FileNotFoundError'
],
'message':
_('Repository not found'),
'raise_as':
errors.BorgRepositoryDoesNotExistError,
'message': _('Repository not found'),
'raise_as': errors.BorgRepositoryDoesNotExistError,
},
{
'errors': ['passphrase supplied in .* is incorrect'],
@@ -176,7 +174,6 @@ class BaseBorgRepository(abc.ABC):
def remove(self):
"""Remove a borg repository"""
def list_archives(self):
"""Return list of archives in this repository."""
output = self.run(['list-repo', '--path', self.borg_path])
@@ -241,7 +238,6 @@ class BaseBorgRepository(abc.ABC):
def get_download_stream(self, archive_name):
"""Return an stream of .tar.gz binary data for a backup archive."""
class BufferedReader(io.BufferedReader):
"""Improve performance of buffered binary streaming.
@@ -255,7 +251,6 @@ class BaseBorgRepository(abc.ABC):
binary data.
"""
def __next__(self):
"""Override to call read() instead of readline()."""
chunk = self.read(io.DEFAULT_BUFFER_SIZE)
-3
View File
@@ -57,7 +57,6 @@ def _get_backup_app(name):
class TestBackupApp:
"""Test the BackupApp class."""
@staticmethod
def test_run_hook():
"""Test running a hook on an application."""
@@ -82,7 +81,6 @@ class TestBackupApp:
@pytest.mark.usefixtures('load_cfg')
class TestBackupProcesses:
"""Test cases for backup processes"""
@staticmethod
def test_packet_process_manifests():
"""Test that directories/files are collected from manifests."""
@@ -239,7 +237,6 @@ class TestBackupProcesses:
class TestBackupModule:
"""Tests of the backups django module, like views or forms."""
@staticmethod
def test_file_upload():
# posting a video should fail
+2 -2
View File
@@ -27,8 +27,8 @@ CONFIG_FILE = '/etc/cockpit/cockpit.conf'
def load_augeas():
"""Initialize Augeas."""
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/inifile/lens', 'Puppet.lns')
aug.set('/augeas/load/inifile/incl[last() + 1]', CONFIG_FILE)
aug.load()
+2 -2
View File
@@ -81,8 +81,8 @@ def get_hostname():
def _get_home_page_url():
"""Get the default application for the domain."""
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
conf_file = APACHE_HOMEPAGE_CONFIG if os.path.exists(
APACHE_HOMEPAGE_CONFIG) else FREEDOMBOX_APACHE_CONFIG
+10 -11
View File
@@ -67,11 +67,10 @@ class ConfigurationForm(forms.Form):
'end with an alphabet or a digit and have as interior '
'characters only alphabets, digits and hyphens. Total '
'length must be 63 characters or less.'),
box_name=ugettext_lazy(cfg.box_name)),
validators=[
validators.RegexValidator(HOSTNAME_REGEX,
ugettext_lazy('Invalid hostname'))
], strip=True)
box_name=ugettext_lazy(cfg.box_name)), validators=[
validators.RegexValidator(HOSTNAME_REGEX,
ugettext_lazy('Invalid hostname'))
], strip=True)
domainname = forms.CharField(
label=ugettext_lazy('Domain Name'), help_text=format_lazy(
@@ -83,12 +82,12 @@ class ConfigurationForm(forms.Form):
'only alphabets, digits and hyphens. Length of each label '
'must be 63 characters or less. Total length of domain name '
'must be 253 characters or less.'),
box_name=ugettext_lazy(cfg.box_name)),
required=False, validators=[
validators.RegexValidator(
r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$',
ugettext_lazy('Invalid domain name')), domain_label_validator
], strip=True)
box_name=ugettext_lazy(cfg.box_name)), required=False, validators=[
validators.RegexValidator(
r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$',
ugettext_lazy('Invalid domain name')),
domain_label_validator
], strip=True)
homepage = forms.ChoiceField(
label=ugettext_lazy('Webserver Home Page'), help_text=format_lazy(
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the Diagnostics module
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import diagnostics as views
urlpatterns = [
url(r'^sys/diagnostics/$', views.index, name='index'),
url(r'^sys/diagnostics/(?P<module_name>[1-9a-z\-]+)/$', views.module,
+6 -6
View File
@@ -89,9 +89,10 @@ class DiasporaApp(app_module.App):
parent_url_name='apps')
self.add(menu_item)
shortcut = Shortcut(
'shortcut-diaspora', name, short_description=short_description,
icon='diaspora', url=None, clients=clients, login_required=True)
shortcut = Shortcut('shortcut-diaspora', name,
short_description=short_description,
icon='diaspora', url=None, clients=clients,
login_required=True)
self.add(shortcut)
firewall = Firewall('firewall-diaspora', name, ports=['http', 'https'],
@@ -107,7 +108,6 @@ class DiasporaApp(app_module.App):
class Shortcut(frontpage.Shortcut):
"""Frontpage shortcut to use configured domain name for URL."""
def enable(self):
"""Set the proper shortcut URL when enabled."""
super().enable()
@@ -179,8 +179,8 @@ def generate_apache_configuration(conf_file, domain_name):
diaspora_domain_name = ".".join(["diaspora", domain_name])
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
aug.set('/augeas/load/Httpd/incl[last() + 1]', conf_file)
+4 -3
View File
@@ -40,8 +40,9 @@ clients = validate([{
'type':
'web',
'url':
format_lazy('https://diaspora.{host}',
host=diaspora.get_configured_domain_name() if
diaspora.is_setup() else "<please-setup-domain-name>")
format_lazy(
'https://diaspora.{host}',
host=diaspora.get_configured_domain_name()
if diaspora.is_setup() else "<please-setup-domain-name>")
}]
}])
+4 -3
View File
@@ -86,9 +86,10 @@ def init():
app = DynamicDNSApp()
current_status = get_status()
if current_status['enabled']:
domain_added.send_robust(
sender='dynamicdns', domain_type='domain-type-dynamic',
name=current_status['dynamicdns_domain'], services='__all__')
domain_added.send_robust(sender='dynamicdns',
domain_type='domain-type-dynamic',
name=current_status['dynamicdns_domain'],
services='__all__')
app.set_enabled(True)
+15 -16
View File
@@ -28,7 +28,6 @@ from plinth.utils import format_lazy
class TrimmedCharField(forms.CharField):
"""Trim the contents of a CharField."""
def clean(self, value):
"""Clean and validate the field value"""
if value:
@@ -81,12 +80,12 @@ class ConfigureForm(forms.Form):
'freedns.afraid.org'),
('other', 'other update URL'))
enabled = forms.BooleanField(
label=ugettext_lazy('Enable Dynamic DNS'), required=False)
enabled = forms.BooleanField(label=ugettext_lazy('Enable Dynamic DNS'),
required=False)
service_type = forms.ChoiceField(
label=ugettext_lazy('Service Type'), help_text=help_services,
choices=provider_choices)
service_type = forms.ChoiceField(label=ugettext_lazy('Service Type'),
help_text=help_services,
choices=provider_choices)
dynamicdns_server = TrimmedCharField(
label=ugettext_lazy('GnuDIP Server Address'), required=False,
@@ -95,9 +94,9 @@ class ConfigureForm(forms.Form):
ugettext_lazy('Invalid server name'))
])
dynamicdns_update_url = TrimmedCharField(
label=ugettext_lazy('Update URL'), required=False,
help_text=help_update_url)
dynamicdns_update_url = TrimmedCharField(label=ugettext_lazy('Update URL'),
required=False,
help_text=help_update_url)
disable_SSL_cert_check = forms.BooleanField(
label=ugettext_lazy('Accept all SSL certificates'),
@@ -114,15 +113,15 @@ class ConfigureForm(forms.Form):
ugettext_lazy('Invalid domain name'))
])
dynamicdns_user = TrimmedCharField(
label=ugettext_lazy('Username'), required=False, help_text=help_user)
dynamicdns_user = TrimmedCharField(label=ugettext_lazy('Username'),
required=False, help_text=help_user)
dynamicdns_secret = TrimmedCharField(
label=ugettext_lazy('Password'), widget=forms.PasswordInput(),
required=False, help_text=help_secret)
dynamicdns_secret = TrimmedCharField(label=ugettext_lazy('Password'),
widget=forms.PasswordInput(),
required=False, help_text=help_secret)
showpw = forms.BooleanField(
label=ugettext_lazy('Show password'), required=False)
showpw = forms.BooleanField(label=ugettext_lazy('Show password'),
required=False)
dynamicdns_ipurl = TrimmedCharField(
label=ugettext_lazy('URL to look up public IP'), required=False,
+11 -12
View File
@@ -39,15 +39,13 @@ EMPTYSTRING = 'none'
subsubmenu = [{
'url': reverse_lazy('dynamicdns:index'),
'text': ugettext_lazy('About')
},
{
'url': reverse_lazy('dynamicdns:configure'),
'text': ugettext_lazy('Configure')
},
{
'url': reverse_lazy('dynamicdns:statuspage'),
'text': ugettext_lazy('Status')
}]
}, {
'url': reverse_lazy('dynamicdns:configure'),
'text': ugettext_lazy('Configure')
}, {
'url': reverse_lazy('dynamicdns:statuspage'),
'text': ugettext_lazy('Status')
}]
def index(request):
@@ -164,9 +162,10 @@ def _apply_changes(request, old_status, new_status):
_run(['stop'])
if new_status['enabled']:
domain_added.send_robust(
sender='dynamicdns', domain_type='domain-type-dynamic',
name=new_status['dynamicdns_domain'], services='__all__')
domain_added.send_robust(sender='dynamicdns',
domain_type='domain-type-dynamic',
name=new_status['dynamicdns_domain'],
services='__all__')
_run(['start'])
messages.success(request, _('Configuration updated'))
@@ -77,7 +77,6 @@ def test_port_details(get_port_details):
@patch('plinth.modules.firewall.get_enabled_services')
def test_enable(get_enabled_services, add_service):
"""Test enabling a firewall component."""
def get_enabled_services_side_effect(zone):
return {'internal': ['test-port1'], 'external': ['test-port2']}[zone]
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the Firewall module
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/firewall/$', views.index, name='index'),
]
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Django middleware to redirect to firstboot wizard if it has not be run
yet.
@@ -34,7 +33,6 @@ LOGGER = logging.getLogger(__name__)
class FirstBootMiddleware(MiddlewareMixin):
"""Forward to firstboot page if firstboot isn't finished yet."""
@staticmethod
def process_request(request):
"""Handle a request as Django middleware request handler."""
+5 -5
View File
@@ -78,10 +78,11 @@ class GitwebApp(app_module.App):
'gitweb:index', parent_url_name='apps')
self.add(menu_item)
shortcut = frontpage.Shortcut(
'shortcut-gitweb', name, short_description=short_description,
icon=icon_filename, url='/gitweb/', clients=clients,
login_required=True, allowed_groups=[group[0]])
shortcut = frontpage.Shortcut('shortcut-gitweb', name,
short_description=short_description,
icon=icon_filename, url='/gitweb/',
clients=clients, login_required=True,
allowed_groups=[group[0]])
self.add(shortcut)
firewall = Firewall('firewall-gitweb', name, ports=['http', 'https'],
@@ -154,7 +155,6 @@ class GitwebApp(app_module.App):
class GitwebWebserverAuth(Webserver):
"""Component to handle Gitweb authentication webserver configuration."""
def is_conf_enabled(self):
"""Check whether Gitweb authentication configuration is enabled."""
return super().is_enabled()
+3 -3
View File
@@ -83,9 +83,9 @@ class CreateRepoForm(forms.Form):
label=_('Description of the repository'), strip=True, required=False,
help_text=_('Optional, for displaying on Gitweb.'))
owner = forms.CharField(
label=_('Repository\'s owner name'), strip=True, required=False,
help_text=_('Optional, for displaying on Gitweb.'))
owner = forms.CharField(label=_('Repository\'s owner name'), strip=True,
required=False,
help_text=_('Optional, for displaying on Gitweb.'))
is_private = forms.BooleanField(
label=_('Private repository'), required=False,
+2 -3
View File
@@ -30,8 +30,8 @@ from django.forms import ValidationError
def _action_file():
"""Return the path to the 'gitweb' actions file."""
current_directory = pathlib.Path(__file__).parent
return str(
current_directory / '..' / '..' / '..' / '..' / 'actions' / 'gitweb')
return str(current_directory / '..' / '..' / '..' / '..' / 'actions' /
'gitweb')
gitweb_actions = imp.load_source('gitweb', _action_file())
@@ -40,7 +40,6 @@ gitweb_actions = imp.load_source('gitweb', _action_file())
@pytest.fixture(name='call_action')
def fixture_call_action(tmpdir, capsys):
"""Run actions with custom repo root path."""
def _call_action(args, **kwargs):
gitweb_actions.GIT_REPO_PATH = str(tmpdir)
with patch('argparse._sys.argv', ['gitweb'] + args):
+5 -4
View File
@@ -89,10 +89,11 @@ class I2PApp(app_module.App):
'i2p:index', parent_url_name='apps')
self.add(menu_item)
shortcut = frontpage.Shortcut(
'shortcut-i2p', name, short_description=short_description,
icon=icon_filename, url='/i2p/', clients=clients, login_required=True,
allowed_groups=[group[0]])
shortcut = frontpage.Shortcut('shortcut-i2p', name,
short_description=short_description,
icon=icon_filename, url='/i2p/',
clients=clients, login_required=True,
allowed_groups=[group[0]])
self.add(shortcut)
firewall = Firewall('firewall-i2p-web', name, ports=['http', 'https'],
+4 -5
View File
@@ -35,7 +35,6 @@ class TunnelEditor():
:type aug: augeas.Augeas
"""
def __init__(self, conf_filename=None, idx=None):
self.conf_filename = conf_filename or FILE_TUNNEL_CONF
self.idx = idx
@@ -55,8 +54,8 @@ class TunnelEditor():
Chainable method.
"""
self.aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
self.aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
self.aug.set('/augeas/load/Properties/lens', 'Properties.lns')
self.aug.set('/augeas/load/Properties/incl[last() + 1]',
self.conf_filename)
@@ -160,8 +159,8 @@ class RouterEditor():
Chainable method.
"""
self.aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
self.aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
self.aug.set('/augeas/load/Properties/lens', 'Properties.lns')
self.aug.set('/augeas/load/Properties/incl[last() + 1]',
self.conf_filename)
+86 -104
View File
@@ -18,110 +18,92 @@
Pre-defined list of favorites for I2P and some additional favorites.
"""
DEFAULT_FAVORITES = [
{
'name': 'anoncoin.i2p',
'description': 'The Anoncoin project',
'icon': '/themes/console/images/anoncoin_32.png',
'url': 'http://anoncoin.i2p/'
},
{
'name': 'Dev Builds',
'description': 'Development builds of I2P',
'icon': '/themes/console/images/script_gear.png',
'url': 'http://bobthebuilder.i2p/'
},
{
'name': 'Dev Forum',
'description': 'Development forum',
'icon': '/themes/console/images/group_gear.png',
'url': 'http://zzz.i2p/'
},
{
'name': 'echelon.i2p',
'description': 'I2P Applications',
'icon': '/themes/console/images/box_open.png',
'url': 'http://echelon.i2p/'
},
{
'name': 'exchanged.i2p',
'description': 'Anonymous cryptocurrency exchange',
'icon': '/themes/console/images/exchanged.png',
'url': 'http://exchanged.i2p/'
},
{
'name': 'I2P Bug Reports',
'description': 'Bug tracker',
'icon': '/themes/console/images/bug.png',
'url': 'http://trac.i2p2.i2p/report/1'
},
{
'name': 'I2P FAQ',
'description': 'Frequently Asked Questions',
'icon': '/themes/console/images/question.png',
'url': 'http://i2p-projekt.i2p/faq'
},
{
'name': 'I2P Forum',
'description': 'Community forum',
'icon': '/themes/console/images/group.png',
'url': 'http://i2pforum.i2p/'
},
{
'name': 'I2P Plugins',
'description': 'Add-on directory',
'icon': '/themes/console/images/info/plugin_link.png',
'url': 'http://i2pwiki.i2p/index.php?title=Plugins'
},
{
'name': 'I2P Technical Docs',
'description': 'Technical documentation',
'icon': '/themes/console/images/education.png',
'url': 'http://i2p-projekt.i2p/how'
},
{
'name': 'I2P Wiki',
'description': 'Anonymous wiki - share the knowledge',
'icon': '/themes/console/images/i2pwiki_logo.png',
'url': 'http://i2pwiki.i2p/'
},
{
'name': 'Planet I2P',
'description': 'I2P News',
'icon': '/themes/console/images/world.png',
'url': 'http://planet.i2p/'
},
{
'name': 'PrivateBin',
'description': 'Encrypted I2P Pastebin',
'icon': '/themes/console/images/paste_plain.png',
'url': 'http://paste.crypthost.i2p/'
},
{
'name': 'Project Website',
'description': 'I2P home page',
'icon': '/themes/console/images/info_rhombus.png',
'url': 'http://i2p-projekt.i2p/'
},
{
'name': 'stats.i2p',
'description': 'I2P Network Statistics',
'icon': '/themes/console/images/chart_line.png',
'url': 'http://stats.i2p/cgi-bin/dashboard.cgi'
},
{
'name': 'The Tin Hat',
'description': 'Privacy guides and tutorials',
'icon': '/themes/console/images/thetinhat.png',
'url': 'http://secure.thetinhat.i2p/'
},
{
'name': 'Trac Wiki',
'description': '',
'icon': '/themes/console/images/billiard_marker.png',
'url': 'http://trac.i2p2.i2p/'
}
]
DEFAULT_FAVORITES = [{
'name': 'anoncoin.i2p',
'description': 'The Anoncoin project',
'icon': '/themes/console/images/anoncoin_32.png',
'url': 'http://anoncoin.i2p/'
}, {
'name': 'Dev Builds',
'description': 'Development builds of I2P',
'icon': '/themes/console/images/script_gear.png',
'url': 'http://bobthebuilder.i2p/'
}, {
'name': 'Dev Forum',
'description': 'Development forum',
'icon': '/themes/console/images/group_gear.png',
'url': 'http://zzz.i2p/'
}, {
'name': 'echelon.i2p',
'description': 'I2P Applications',
'icon': '/themes/console/images/box_open.png',
'url': 'http://echelon.i2p/'
}, {
'name': 'exchanged.i2p',
'description': 'Anonymous cryptocurrency exchange',
'icon': '/themes/console/images/exchanged.png',
'url': 'http://exchanged.i2p/'
}, {
'name': 'I2P Bug Reports',
'description': 'Bug tracker',
'icon': '/themes/console/images/bug.png',
'url': 'http://trac.i2p2.i2p/report/1'
}, {
'name': 'I2P FAQ',
'description': 'Frequently Asked Questions',
'icon': '/themes/console/images/question.png',
'url': 'http://i2p-projekt.i2p/faq'
}, {
'name': 'I2P Forum',
'description': 'Community forum',
'icon': '/themes/console/images/group.png',
'url': 'http://i2pforum.i2p/'
}, {
'name': 'I2P Plugins',
'description': 'Add-on directory',
'icon': '/themes/console/images/info/plugin_link.png',
'url': 'http://i2pwiki.i2p/index.php?title=Plugins'
}, {
'name': 'I2P Technical Docs',
'description': 'Technical documentation',
'icon': '/themes/console/images/education.png',
'url': 'http://i2p-projekt.i2p/how'
}, {
'name': 'I2P Wiki',
'description': 'Anonymous wiki - share the knowledge',
'icon': '/themes/console/images/i2pwiki_logo.png',
'url': 'http://i2pwiki.i2p/'
}, {
'name': 'Planet I2P',
'description': 'I2P News',
'icon': '/themes/console/images/world.png',
'url': 'http://planet.i2p/'
}, {
'name': 'PrivateBin',
'description': 'Encrypted I2P Pastebin',
'icon': '/themes/console/images/paste_plain.png',
'url': 'http://paste.crypthost.i2p/'
}, {
'name': 'Project Website',
'description': 'I2P home page',
'icon': '/themes/console/images/info_rhombus.png',
'url': 'http://i2p-projekt.i2p/'
}, {
'name': 'stats.i2p',
'description': 'I2P Network Statistics',
'icon': '/themes/console/images/chart_line.png',
'url': 'http://stats.i2p/cgi-bin/dashboard.cgi'
}, {
'name': 'The Tin Hat',
'description': 'Privacy guides and tutorials',
'icon': '/themes/console/images/thetinhat.png',
'url': 'http://secure.thetinhat.i2p/'
}, {
'name': 'Trac Wiki',
'description': '',
'icon': '/themes/console/images/billiard_marker.png',
'url': 'http://trac.i2p2.i2p/'
}]
ADDITIONAL_FAVORITES = [
{
'name': 'Searx instance',
+4 -5
View File
@@ -32,11 +32,10 @@ subsubmenu = [{
}, {
'url': reverse_lazy('i2p:tunnels'),
'text': ugettext_lazy('Proxies')
},
{
'url': reverse_lazy('i2p:torrents'),
'text': ugettext_lazy('Anonymous torrents')
}]
}, {
'url': reverse_lazy('i2p:torrents'),
'text': ugettext_lazy('Anonymous torrents')
}]
class I2PAppView(AppView):
+1 -2
View File
@@ -92,8 +92,7 @@ class IkiwikiApp(app_module.App):
"""Add an ikiwiki shortcut to frontpage."""
shortcut = frontpage.Shortcut('shortcut-ikiwiki-' + site, title,
icon=icon_filename,
url='/ikiwiki/' + site,
clients=clients)
url='/ikiwiki/' + site, clients=clients)
self.add(shortcut)
return shortcut
+4 -7
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Forms for configuring ikiwiki
"""
@@ -25,14 +24,12 @@ from django.utils.translation import ugettext_lazy as _
class IkiwikiCreateForm(forms.Form):
"""Form to create a wiki or blog."""
site_type = forms.ChoiceField(
label=_('Type'),
choices=[('wiki', 'Wiki'), ('blog', 'Blog')])
site_type = forms.ChoiceField(label=_('Type'), choices=[('wiki', 'Wiki'),
('blog', 'Blog')])
name = forms.CharField(label=_('Name'))
admin_name = forms.CharField(label=_('Admin Account Name'))
admin_password = forms.CharField(
label=_('Admin Account Password'),
widget=forms.PasswordInput())
admin_password = forms.CharField(label=_('Admin Account Password'),
widget=forms.PasswordInput())
+3 -4
View File
@@ -28,8 +28,7 @@ clients = validate([{
}]
}])
backup = validate_backup({
'data': {
backup = validate_backup(
{'data': {
'directories': ['/var/lib/ikiwiki/', '/var/www/ikiwiki/']
}
})
}})
+5 -4
View File
@@ -63,10 +63,11 @@ class JSXCApp(app_module.App):
'jsxc:index', parent_url_name='apps')
self.add(menu_item)
shortcut = frontpage.Shortcut(
'shortcut-jsxc', name=name, short_description=short_description,
icon=icon_filename,
url=reverse_lazy('jsxc:jsxc'), clients=clients)
shortcut = frontpage.Shortcut('shortcut-jsxc', name=name,
short_description=short_description,
icon=icon_filename,
url=reverse_lazy('jsxc:jsxc'),
clients=clients)
self.add(shortcut)
firewall = Firewall('firewall-jsxc', name, ports=['http', 'https'],
+6 -5
View File
@@ -326,9 +326,10 @@ class LetsEncrypt(app.FollowerComponent):
source_certificate_path,
private_key_path, certificate_path)
else:
self._copy_certificate(
source_private_key_path, source_certificate_path,
self.private_key_path, self.certificate_path)
self._copy_certificate(source_private_key_path,
source_certificate_path,
self.private_key_path,
self.certificate_path)
def _copy_certificate(self, source_private_key_path,
source_certificate_path, private_key_path,
@@ -374,8 +375,8 @@ def on_certificate_event(event, domains, lineage):
certificate changes.
"""
threading.Thread(target=on_certificate_event_sync, args=(event, domains,
lineage)).start()
threading.Thread(target=on_certificate_event_sync,
args=(event, domains, lineage)).start()
def on_certificate_event_sync(event, domains, lineage):
+2 -3
View File
@@ -108,9 +108,8 @@ class MatrixSynapseApp(app_module.App):
self.add(webserver)
letsencrypt = LetsEncrypt(
'letsencrypt-matrixsynapse', domains=get_domains, daemons=[
managed_services[0]
], should_copy_certificates=True,
'letsencrypt-matrixsynapse', domains=get_domains,
daemons=[managed_services[0]], should_copy_certificates=True,
private_key_path='/etc/matrix-synapse/homeserver.tls.key',
certificate_path='/etc/matrix-synapse/homeserver.tls.crt',
user_owner='matrix-synapse', group_owner='nogroup',
-1
View File
@@ -101,7 +101,6 @@ class MediaWikiApp(app_module.App):
class Shortcut(frontpage.Shortcut):
"""Frontpage shortcut for only logged users when in private mode."""
def enable(self):
"""When enabled, check if MediaWiki is in private mode."""
super().enable()
+2 -2
View File
@@ -132,8 +132,8 @@ def diagnose():
def load_augeas():
"""Initialize Augeas."""
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Php/lens', 'Php.lns')
aug.set('/augeas/load/Php/incl[last() + 1]', CONFIG_FILE)
aug.load()
+3 -3
View File
@@ -28,9 +28,9 @@ class MinetestForm(AppForm):
"""Minetest configuration form"""
max_players = forms.IntegerField(
label=_('Maximum number of players'), required=True, min_value=1,
max_value=100, help_text=_(
'You can change the maximum number of players playing '
'minetest at a single instance of time.'))
max_value=100,
help_text=_('You can change the maximum number of players playing '
'minetest at a single instance of time.'))
creative_mode = forms.BooleanField(
label=_('Enable creative mode'), required=False,
+5 -4
View File
@@ -80,10 +80,11 @@ class MLDonkeyApp(app_module.App):
parent_url_name='apps')
self.add(menu_item)
shortcuts = frontpage.Shortcut(
'shortcut-mldonkey', name, short_description=short_description,
icon=icon_filename, url='/mldonkey/', login_required=True,
clients=clients, allowed_groups=[group[0]])
shortcuts = frontpage.Shortcut('shortcut-mldonkey', name,
short_description=short_description,
icon=icon_filename, url='/mldonkey/',
login_required=True, clients=clients,
allowed_groups=[group[0]])
self.add(shortcuts)
firewall = Firewall('firewall-mldonkey', name, ports=['http', 'https'],
+6 -12
View File
@@ -55,24 +55,18 @@ clients = validate([{
backup = validate_backup({
'config': {
'files': [
'/var/lib/mldonkey/bittorrent.ini',
'/var/lib/mldonkey/bt_dht.ini',
'/var/lib/mldonkey/bittorrent.ini', '/var/lib/mldonkey/bt_dht.ini',
'/var/lib/mldonkey/directconnect.ini',
'/var/lib/mldonkey/donkey.ini',
'/var/lib/mldonkey/downloads.ini',
'/var/lib/mldonkey/donkey.ini', '/var/lib/mldonkey/downloads.ini',
'/var/lib/mldonkey/files.ini',
'/var/lib/mldonkey/file_sources.ini',
'/var/lib/mldonkey/fileTP.ini',
'/var/lib/mldonkey/friends.ini',
'/var/lib/mldonkey/searches.ini',
'/var/lib/mldonkey/servers.ini',
'/var/lib/mldonkey/fileTP.ini', '/var/lib/mldonkey/friends.ini',
'/var/lib/mldonkey/searches.ini', '/var/lib/mldonkey/servers.ini',
'/var/lib/mldonkey/shared_files.ini',
'/var/lib/mldonkey/shared_files_new.ini',
'/var/lib/mldonkey/statistics.ini',
'/var/lib/mldonkey/stats_bt.ini',
'/var/lib/mldonkey/stats.ini',
'/var/lib/mldonkey/stats_mod.ini',
'/var/lib/mldonkey/users.ini'
'/var/lib/mldonkey/stats_bt.ini', '/var/lib/mldonkey/stats.ini',
'/var/lib/mldonkey/stats_mod.ini', '/var/lib/mldonkey/users.ini'
]
},
'services': ['mldonkey-server']
+6 -6
View File
@@ -26,10 +26,10 @@ from plinth.views import AppView
urlpatterns = [
url(
r'^apps/mldonkey/$',
AppView.as_view(
app_id='mldonkey', name=mldonkey.name,
diagnostics_module_name='mldonkey',
description=mldonkey.description, clients=mldonkey.clients,
manual_page=mldonkey.manual_page, show_status_block=True),
name='index'),
AppView.as_view(app_id='mldonkey', name=mldonkey.name,
diagnostics_module_name='mldonkey',
description=mldonkey.description,
clients=mldonkey.clients,
manual_page=mldonkey.manual_page,
show_status_block=True), name='index'),
]
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the monkeysphere module.
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/monkeysphere/$', views.index, name='index'),
url(r'^sys/monkeysphere/(?P<ssh_fingerprint>[0-9A-Za-z:+/]+)/import/$',
+1 -5
View File
@@ -72,8 +72,4 @@ clients = validate([{
}]
}])
backup = validate_backup({
'data': {
'directories': ['/var/lib/mumble-server']
}
})
backup = validate_backup({'data': {'directories': ['/var/lib/mumble-server']}})
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the name services module
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/names/$', views.index, name='index'),
]
+4 -4
View File
@@ -84,10 +84,10 @@ def diagnose():
addresses = _get_interface_addresses(interfaces)
for address in addresses:
results.append(
action_utils.diagnose_port_listening(53, 'tcp', address))
results.append(
action_utils.diagnose_port_listening(53, 'udp', address))
results.append(action_utils.diagnose_port_listening(
53, 'tcp', address))
results.append(action_utils.diagnose_port_listening(
53, 'udp', address))
results.append(_diagnose_dnssec('4'))
results.append(_diagnose_dnssec('6'))
+48 -77
View File
@@ -34,17 +34,15 @@ class ConnectionTypeSelectForm(forms.Form):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['connection_type'].widget.attrs.update({
'autofocus': 'autofocus'
})
self.fields['connection_type'].widget.attrs.update(
{'autofocus': 'autofocus'})
class ConnectionForm(forms.Form):
"""Base form to create/edit a connection."""
name = forms.CharField(label=_('Connection Name'))
interface = forms.ChoiceField(
label=_('Physical Interface'),
choices=(),
label=_('Physical Interface'), choices=(),
help_text=_('The network device that this connection should be bound '
'to.'))
zone = forms.ChoiceField(
@@ -52,90 +50,70 @@ class ConnectionForm(forms.Form):
help_text=_('The firewall zone will control which services are '
'available over this interfaces. Select Internal only '
'for trusted networks.'),
choices=[('external', _('External')),
('internal', _('Internal'))])
choices=[('external', _('External')), ('internal', _('Internal'))])
ipv4_method = forms.ChoiceField(
label=_('IPv4 Addressing Method'),
help_text=format_lazy(
label=_('IPv4 Addressing Method'), help_text=format_lazy(
ugettext_lazy(
'"Automatic" method will make {box_name} acquire '
'configuration from this network making it a client. "Shared" '
'method will make {box_name} act as a router, configure '
'clients on this network and share its Internet connection.'),
box_name=ugettext_lazy(cfg.box_name)),
choices=[('auto', _('Automatic (DHCP)')),
('shared', _('Shared')),
('manual', _('Manual')),
('disabled', _('Disabled'))])
choices=[('auto', _('Automatic (DHCP)')), ('shared', _('Shared')),
('manual', _('Manual')), ('disabled', _('Disabled'))])
ipv4_address = forms.CharField(
label=_('Address'),
validators=[validators.validate_ipv4_address],
label=_('Address'), validators=[validators.validate_ipv4_address],
required=False)
ipv4_netmask = forms.CharField(
label=_('Netmask'),
help_text=_('Optional value. If left blank, a default netmask '
'based on the address will be used.'),
validators=[validators.validate_ipv4_address],
required=False)
validators=[validators.validate_ipv4_address], required=False)
ipv4_gateway = forms.CharField(
label=_('Gateway'),
help_text=_('Optional value.'),
validators=[validators.validate_ipv4_address],
required=False)
label=_('Gateway'), help_text=_('Optional value.'),
validators=[validators.validate_ipv4_address], required=False)
ipv4_dns = forms.CharField(
label=_('DNS Server'),
help_text=_('Optional value. If this value is given and IPv4 '
'addressing method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv4_address],
required=False)
validators=[validators.validate_ipv4_address], required=False)
ipv4_second_dns = forms.CharField(
label=_('Second DNS Server'),
help_text=_('Optional value. If this value is given and IPv4 '
'Addressing Method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv4_address],
required=False)
validators=[validators.validate_ipv4_address], required=False)
ipv6_method = forms.ChoiceField(
label=_('IPv6 Addressing Method'),
help_text=format_lazy(
label=_('IPv6 Addressing Method'), help_text=format_lazy(
ugettext_lazy(
'"Automatic" methods will make {box_name} acquire '
'configuration from this network making it a client.'),
box_name=ugettext_lazy(cfg.box_name)),
choices=[('auto', _('Automatic')),
('dhcp', _('Automatic, DHCP only')),
('manual', _('Manual')),
('ignore', _('Ignore'))])
choices=[('auto', _('Automatic')), ('dhcp', _('Automatic, DHCP only')),
('manual', _('Manual')), ('ignore', _('Ignore'))])
ipv6_address = forms.CharField(
label=_('Address'),
validators=[validators.validate_ipv6_address],
required=False)
ipv6_prefix = forms.IntegerField(
label=_('Prefix'),
help_text=_('Value between 1 and 128.'),
min_value=1,
max_value=128,
label=_('Address'), validators=[validators.validate_ipv6_address],
required=False)
ipv6_prefix = forms.IntegerField(label=_('Prefix'),
help_text=_('Value between 1 and 128.'),
min_value=1, max_value=128,
required=False)
ipv6_gateway = forms.CharField(
label=_('Gateway'),
help_text=_('Optional value.'),
validators=[validators.validate_ipv6_address],
required=False)
label=_('Gateway'), help_text=_('Optional value.'),
validators=[validators.validate_ipv6_address], required=False)
ipv6_dns = forms.CharField(
label=_('DNS Server'),
help_text=_('Optional value. If this value is given and IPv6 '
'addressing method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv6_address],
required=False)
validators=[validators.validate_ipv6_address], required=False)
ipv6_second_dns = forms.CharField(
label=_('Second DNS Server'),
help_text=_('Optional value. If this value is given and IPv6 '
'Addressing Method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv6_address],
required=False)
validators=[validators.validate_ipv6_address], required=False)
@staticmethod
def _get_interface_choices(device_type):
@@ -143,8 +121,8 @@ class ConnectionForm(forms.Form):
interfaces = network.get_interface_list(device_type)
choices = [('', _('-- select --'))]
for interface, mac in interfaces.items():
display_string = '{interface} ({mac})'.format(interface=interface,
mac=mac)
display_string = '{interface} ({mac})'.format(
interface=interface, mac=mac)
choices.append((interface, display_string))
return choices
@@ -258,33 +236,29 @@ class PPPoEForm(EthernetForm):
class WifiForm(ConnectionForm):
"""Form to create/edit a Wi-Fi connection."""
field_order = ['name', 'interface', 'zone', 'ssid', 'mode', 'band',
'channel', 'bssid', 'auth_mode', 'passphrase',
'ipv4_method', 'ipv4_address', 'ipv4_netmask',
'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns',
'ipv6_method', 'ipv6_address', 'ipv6_prefix',
'ipv6_gateway', 'ipv6_dns', 'ipv6_second_dns']
field_order = [
'name', 'interface', 'zone', 'ssid', 'mode', 'band', 'channel',
'bssid', 'auth_mode', 'passphrase', 'ipv4_method', 'ipv4_address',
'ipv4_netmask', 'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns',
'ipv6_method', 'ipv6_address', 'ipv6_prefix', 'ipv6_gateway',
'ipv6_dns', 'ipv6_second_dns'
]
ssid = forms.CharField(
label=_('SSID'),
help_text=_('The visible name of the network.'))
ssid = forms.CharField(label=_('SSID'),
help_text=_('The visible name of the network.'))
mode = forms.ChoiceField(
label=_('Mode'),
choices=[('infrastructure', _('Infrastructure')),
('ap', _('Access Point')),
('adhoc', _('Ad-hoc'))])
label=_('Mode'), choices=[('infrastructure', _('Infrastructure')),
('ap', _('Access Point')),
('adhoc', _('Ad-hoc'))])
band = forms.ChoiceField(
label=_('Frequency Band'),
choices=[('auto', _('Automatic')),
('a', _('A (5 GHz)')),
('bg', _('B/G (2.4 GHz)'))])
label=_('Frequency Band'), choices=[('auto', _('Automatic')),
('a', _('A (5 GHz)')),
('bg', _('B/G (2.4 GHz)'))])
channel = forms.IntegerField(
label=_('Channel'),
help_text=_('Optional value. Wireless channel in the selected '
'frequency band to restrict to. Blank or 0 value means '
'automatic selection.'),
min_value=0,
max_value=255,
'automatic selection.'), min_value=0, max_value=255,
required=False)
bssid = forms.RegexField(
label=_('BSSID'),
@@ -292,18 +266,15 @@ class WifiForm(ConnectionForm):
'When connecting to an access point, connect only if the '
'BSSID of the access point matches the one provided. '
'Example: 00:11:22:aa:bb:cc.'),
regex=r'^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$',
required=False)
regex=r'^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$', required=False)
auth_mode = forms.ChoiceField(
label=_('Authentication Mode'),
help_text=_('Select WPA if the wireless network is secured and \
requires clients to have the password to connect.'),
choices=[('wpa', _('WPA')),
('open', _('Open'))])
passphrase = forms.CharField(
label=_('Passphrase'),
validators=[validators.MinLengthValidator(8)],
required=False)
choices=[('wpa', _('WPA')), ('open', _('Open'))])
passphrase = forms.CharField(label=_('Passphrase'),
validators=[validators.MinLengthValidator(8)],
required=False)
def __init__(self, *args, **kwargs):
"""Initialize the form, populate interface choices."""
+3 -5
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the Network module
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import networks as views
urlpatterns = [
url(r'^sys/networks/$', views.index, name='index'),
url(r'^sys/networks/(?P<uuid>[\w.@+-]+)/show/$', views.show, name='show'),
@@ -38,9 +36,9 @@ urlpatterns = [
url(r'^sys/networks/add/ethernet/$', views.add_ethernet,
name='add_ethernet'),
url(r'^sys/networks/add/pppoe/$', views.add_pppoe, name='add_pppoe'),
url(r'^sys/networks/add/wifi/(?:(?P<ssid>[^/]+)/'
r'(?P<interface_name>[^/]+)/)?$',
views.add_wifi, name='add_wifi'),
url(
r'^sys/networks/add/wifi/(?:(?P<ssid>[^/]+)/'
r'(?P<interface_name>[^/]+)/)?$', views.add_wifi, name='add_wifi'),
url(r'^sys/networks/(?P<uuid>[\w.@+-]+)/delete/$', views.delete,
name='delete'),
]
+2 -3
View File
@@ -24,6 +24,5 @@ from django.utils.translation import ugettext_lazy as _
class OpenVpnForm(forms.Form): # pylint: disable=W0232
"""OpenVPN configuration form."""
enabled = forms.BooleanField(
label=_('Enable OpenVPN server'),
required=False)
enabled = forms.BooleanField(label=_('Enable OpenVPN server'),
required=False)
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the OpenVPN module.
"""
@@ -24,7 +23,6 @@ from django.conf.urls import url
from plinth.utils import non_admin_view
from . import views
urlpatterns = [
url(r'^apps/openvpn/$', views.index, name='index'),
url(r'^apps/openvpn/setup/$', views.setup, name='setup'),
+21 -15
View File
@@ -14,36 +14,42 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Test modules for Pagekite functions.
"""
from plinth.modules.pagekite import utils
_tests = [
{
'line': 'https/8080:*.@kitename:localhost:8080:@kitesecret',
'params': {'kitename': '*.@kitename', 'backend_host': 'localhost',
'secret': '@kitesecret', 'protocol': 'https/8080',
'backend_port': '8080'}
'params': {
'kitename': '*.@kitename',
'backend_host': 'localhost',
'secret': '@kitesecret',
'protocol': 'https/8080',
'backend_port': '8080'
}
},
{
'line': 'https:*.@kitename:localhost:80:@kitesecret',
'params': {'protocol': 'https',
'kitename': '*.@kitename',
'backend_port': '80',
'backend_host': 'localhost',
'secret': '@kitesecret'}
'params': {
'protocol': 'https',
'kitename': '*.@kitename',
'backend_port': '80',
'backend_host': 'localhost',
'secret': '@kitesecret'
}
},
{
'line': 'raw/22:@kitename:localhost:22:@kitesecret',
'params': {'protocol': 'raw/22',
'kitename': '@kitename',
'backend_port': '22',
'backend_host': 'localhost',
'secret': '@kitesecret'}
'params': {
'protocol': 'raw/22',
'kitename': '@kitename',
'backend_port': '22',
'backend_host': 'localhost',
'secret': '@kitesecret'
}
},
]
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the power module.
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/power/$', views.index, name='index'),
url(r'^sys/power/restart$', views.restart, name='restart'),
+2 -5
View File
@@ -110,7 +110,6 @@ class RadicaleApp(app_module.App):
class RadicaleWebserver(Webserver):
"""Webserver enable/disable behavior specific for radicale."""
@property
def web_name(self):
"""Return web configuration name based on radicale version."""
@@ -127,7 +126,6 @@ class RadicaleWebserver(Webserver):
class RadicaleUwsgi(Uwsgi):
"""uWSGI enable/disable behavior specific for radicale."""
def is_enabled(self):
"""Return whether the uWSGI configuration is enabled if version>=2."""
package_version = get_package_version()
@@ -152,7 +150,6 @@ class RadicaleUwsgi(Uwsgi):
class RadicaleDaemon(Daemon):
"""Daemon enable/disable behavior specific for radicale."""
@staticmethod
def _is_old_radicale():
"""Return whether radicale is less than version 2."""
@@ -251,8 +248,8 @@ def disable():
def load_augeas():
"""Prepares the augeas."""
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
# INI file lens
aug.set('/augeas/load/Puppet/lens', 'Puppet.lns')
+1 -2
View File
@@ -87,8 +87,7 @@ clients = validate([{
'name': 'evolution'
}]
}, {
'name':
_('Radicale'),
'name': _('Radicale'),
'platforms': [{
'type': 'web',
'url': '/radicale/'
+1 -2
View File
@@ -80,8 +80,7 @@ class RoundcubeApp(app_module.App):
shortcut = frontpage.Shortcut('shortcut-roundcube', name,
short_description=short_description,
icon=icon_filename,
url='/roundcube/',
icon=icon_filename, url='/roundcube/',
clients=clients, login_required=True)
self.add(shortcut)
+1 -2
View File
@@ -29,7 +29,7 @@ from plinth.modules.apache.components import Uwsgi, Webserver
from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from .manifest import PUBLIC_ACCESS_SETTING_FILE, backup, clients # noqa, pylint: disable=unused-import
from .manifest import PUBLIC_ACCESS_SETTING_FILE, backup, clients # noqa, pylint: disable=unused-import
clients = clients
@@ -99,7 +99,6 @@ class SearxApp(app_module.App):
class SearxWebserverAuth(Webserver):
"""Component to handle Searx authentication webserver configuration."""
def is_enabled(self):
"""Return if configuration is enabled or public access is enabled."""
return is_public_access_enabled() or super().is_enabled()
-1
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Forms for security module
"""
+3 -4
View File
@@ -20,8 +20,7 @@ Application manifest for security.
from plinth.modules.backups.api import validate as validate_backup
backup = validate_backup({
'config': {
backup = validate_backup(
{'config': {
'files': ['/etc/security/access.d/50freedombox.conf']
}
})
}})
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the security module
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/security/$', views.index, name='index'),
url(r'^sys/security/report$', views.report, name='report'),
+5 -9
View File
@@ -43,15 +43,11 @@ def index(request):
else:
form = SecurityForm(initial=status, prefix='security')
return TemplateResponse(
request, 'security.html', {
'name':
_('Security'),
'manual_page':
security.manual_page,
'form':
form,
})
return TemplateResponse(request, 'security.html', {
'name': _('Security'),
'manual_page': security.manual_page,
'form': form,
})
def get_status(request):
+5 -6
View File
@@ -39,7 +39,6 @@ METHODS = [('chacha20-ietf-poly1305',
class TrimmedCharField(forms.CharField):
"""Trim the contents of a CharField"""
def clean(self, value):
"""Clean and validate the field value"""
if value:
@@ -50,12 +49,12 @@ class TrimmedCharField(forms.CharField):
class ShadowsocksForm(AppForm):
"""Shadowsocks configuration form"""
server = TrimmedCharField(
label=_('Server'), help_text=_('Server hostname or IP address'))
server = TrimmedCharField(label=_('Server'),
help_text=_('Server hostname or IP address'))
server_port = forms.IntegerField(
label=_('Server port'), min_value=0, max_value=65535,
help_text=_('Server port number'))
server_port = forms.IntegerField(label=_('Server port'), min_value=0,
max_value=65535,
help_text=_('Server port number'))
password = forms.CharField(
label=_('Password'), help_text=_('Password used to encrypt data. '
+2 -2
View File
@@ -100,8 +100,8 @@ def setup(helper, old_version=None):
def load_augeas():
"""Initialize Augeas."""
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
# shell-script config file lens
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
+4 -3
View File
@@ -38,9 +38,10 @@ class SnapshotForm(forms.Form):
choices=[('yes', 'Enabled'), ('no', 'Disabled')])
enable_software_snapshots = forms.ChoiceField(
label=_('Software Installation Snapshots'), help_text=_(
'Enable or disable snapshots before and after software '
'installation'), choices=[('yes', 'Enabled'), ('no', 'Disabled')])
label=_('Software Installation Snapshots'),
help_text=_('Enable or disable snapshots before and after software '
'installation'), choices=[('yes', 'Enabled'),
('no', 'Disabled')])
hourly_limit = forms.IntegerField(
label=_('Hourly Snapshots Limit'), min_value=0,
+3 -3
View File
@@ -121,7 +121,6 @@ def manage(request):
def update_configuration(request, old_status, new_status):
"""Update configuration of snapshots."""
def make_config(args):
key, stamp = args[0], args[1]
if old_status[key] != new_status[key]:
@@ -158,8 +157,9 @@ def update_configuration(request, old_status, new_status):
except ActionError as exception:
messages.error(
request,
_('Action error: {0} [{1}] [{2}]').format(
exception.args[0], exception.args[1], exception.args[2]))
_('Action error: {0} [{1}] [{2}]').format(exception.args[0],
exception.args[1],
exception.args[2]))
def delete_selected(request):
+2 -4
View File
@@ -23,11 +23,9 @@ from plinth.modules.backups.api import validate as validate_backup
backup = validate_backup({
'secrets': {
'files': [
'/etc/ssh/ssh_host_ecdsa_key',
'/etc/ssh/ssh_host_ecdsa_key.pub',
'/etc/ssh/ssh_host_ecdsa_key', '/etc/ssh/ssh_host_ecdsa_key.pub',
'/etc/ssh/ssh_host_ed25519_key',
'/etc/ssh/ssh_host_ed25519_key.pub',
'/etc/ssh/ssh_host_rsa_key',
'/etc/ssh/ssh_host_ed25519_key.pub', '/etc/ssh/ssh_host_rsa_key',
'/etc/ssh/ssh_host_rsa_key.pub'
]
}
+4 -1
View File
@@ -30,7 +30,10 @@ depends = ['security', 'apache']
name = _('Single Sign On')
managed_packages = [
'libapache2-mod-auth-pubtkt', 'openssl', 'python3-openssl', 'flite',
'libapache2-mod-auth-pubtkt',
'openssl',
'python3-openssl',
'flite',
]
+2 -2
View File
@@ -25,8 +25,8 @@ from stronghold.decorators import public
from plinth.utils import non_admin_view
urlpatterns = [
url(r'^accounts/sso/login/$',
public(SSOLoginView.as_view()), name='sso-login'),
url(r'^accounts/sso/login/$', public(SSOLoginView.as_view()),
name='sso-login'),
url(r'^accounts/sso/refresh/$', non_admin_view(refresh),
name='sso-refresh'),
]
+2 -2
View File
@@ -82,8 +82,8 @@ class CaptchaLoginView(LoginView):
form_class = AuthenticationForm
def dispatch(self, request, *args, **kwargs):
response = super(CaptchaLoginView, self).dispatch(
request, *args, **kwargs)
response = super(CaptchaLoginView,
self).dispatch(request, *args, **kwargs)
if not request.POST:
return response
+3 -2
View File
@@ -193,8 +193,9 @@ def is_expandable(device):
return False
try:
output = actions.superuser_run(
'storage', ['is-partition-expandable', device], log_error=False)
output = actions.superuser_run('storage',
['is-partition-expandable', device],
log_error=False)
except actions.ActionError:
return False
@@ -36,7 +36,6 @@ def _get_partition_device(device, partition_number):
class Disk():
"""Context manager to create/destroy a disk."""
def __init__(self, test_case, size, disk_info, file_system_info=None):
"""Initialize the context manager object."""
self.size = size
@@ -120,7 +119,6 @@ class Disk():
class TestActions:
"""Test all actions related to storage."""
@pytest.mark.usefixtures('needs_root')
def test_simple_case(self):
"""Test a simple with no complications"""
+6 -6
View File
@@ -26,10 +26,10 @@ from plinth.views import AppView
urlpatterns = [
url(
r'^apps/syncthing/$',
AppView.as_view(
app_id='syncthing', name=syncthing.name,
diagnostics_module_name='syncthing',
description=syncthing.description, clients=syncthing.clients,
manual_page=syncthing.manual_page, show_status_block=True),
name='index'),
AppView.as_view(app_id='syncthing', name=syncthing.name,
diagnostics_module_name='syncthing',
description=syncthing.description,
clients=syncthing.clients,
manual_page=syncthing.manual_page,
show_status_block=True), name='index'),
]
+4 -4
View File
@@ -76,9 +76,10 @@ class TahoeApp(app_module.App):
parent_url_name='apps', advanced=True)
self.add(menu_item)
shortcut = frontpage.Shortcut(
'shortcut-tahoe', name, short_description=short_description,
icon=icon_filename, url=None, login_required=True)
shortcut = frontpage.Shortcut('shortcut-tahoe', name,
short_description=short_description,
icon=icon_filename, url=None,
login_required=True)
self.add(shortcut)
firewall = Firewall('firewall-tahoe', name, ports=['tahoe-plinth'],
@@ -94,7 +95,6 @@ class TahoeApp(app_module.App):
class Shortcut(frontpage.Shortcut):
"""Frontpage shortcut to use configured domain name for URL."""
def enable(self):
"""Set the proper shortcut URL when enabled."""
super().enable()
-1
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Errors for Tahoe-LAFS module
"""
+27 -37
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Forms for configuring Tor.
"""
@@ -86,55 +85,44 @@ def bridges_validator(bridges):
class TorForm(forms.Form): # pylint: disable=W0232
"""Tor configuration form."""
enabled = forms.BooleanField(
label=_('Enable Tor'),
required=False)
enabled = forms.BooleanField(label=_('Enable Tor'), required=False)
use_upstream_bridges = forms.BooleanField(
label=_('Use upstream bridges to connect to Tor network'),
required=False,
help_text=_(
required=False, help_text=_(
'When enabled, the bridges configured below will be used to '
'connect to the Tor network. Use this option if your Internet '
'Service Provider (ISP) blocks or censors connections to the '
'Tor Network. This will disable relay modes.'))
upstream_bridges = TrimmedCharField(
widget=widgets.Textarea,
label=_('Upstream bridges'),
required=False,
widget=widgets.Textarea, label=_('Upstream bridges'), required=False,
help_text=_(
'You can get some bridges from <a '
'href="https://bridges.torproject.org/">'
'https://bridges.torproject.org/</a> and copy/paste the bridge '
'information here. Currently supported transports are none, '
'obfs3, obfs4 and scamblesuit.'),
validators=[bridges_validator])
'obfs3, obfs4 and scamblesuit.'), validators=[bridges_validator])
relay_enabled = forms.BooleanField(
label=_('Enable Tor relay'),
required=False,
help_text=format_lazy(_(
'When enabled, your {box_name} will run a Tor relay and donate '
'bandwidth to the Tor network. Do this if you have more than '
'2 megabits/s of upload and download bandwidth.'),
box_name=_(cfg.box_name)))
label=_('Enable Tor relay'), required=False, help_text=format_lazy(
_('When enabled, your {box_name} will run a Tor relay and donate '
'bandwidth to the Tor network. Do this if you have more than '
'2 megabits/s of upload and download bandwidth.'),
box_name=_(cfg.box_name)))
bridge_relay_enabled = forms.BooleanField(
label=_('Enable Tor bridge relay'),
required=False,
help_text=format_lazy(_(
'When enabled, relay information is published in the Tor bridge '
'database instead of public Tor relay database making it harder '
'to censor this node. This helps others circumvent censorship.'),
box_name=_(cfg.box_name)))
label=_('Enable Tor bridge relay'), required=False,
help_text=format_lazy(
_('When enabled, relay information is published in the Tor bridge '
'database instead of public Tor relay database making it harder '
'to censor this node. This helps others circumvent censorship.'),
box_name=_(cfg.box_name)))
hs_enabled = forms.BooleanField(
label=_('Enable Tor Onion Service'),
required=False,
help_text=format_lazy(_(
'An onion service will allow {box_name} to provide selected '
'services (such as wiki or chat) without revealing its '
'location. Do not use this for strong anonymity yet.'),
box_name=_(cfg.box_name)))
label=_('Enable Tor Hidden Service'), required=False,
help_text=format_lazy(
_('A hidden service will allow {box_name} to provide selected '
'services (such as wiki or chat) without revealing its '
'location. Do not use this for strong anonymity yet.'),
box_name=_(cfg.box_name)))
apt_transport_tor_enabled = forms.BooleanField(
label=_('Download software packages over Tor'),
required=False,
label=_('Download software packages over Tor'), required=False,
help_text=_('When enabled, software will be downloaded over the Tor '
'network for installations and upgrades. This adds a '
'degree of privacy and security during software '
@@ -147,8 +135,10 @@ class TorForm(forms.Form): # pylint: disable=W0232
upstream_bridges = cleaned_data.get('upstream_bridges')
if use_upstream_bridges and not upstream_bridges:
self.add_error('upstream_bridges', ValidationError(_(
'Specify at least one upstream bridge to use upstream '
'bridges.'), code='invalid'))
self.add_error(
'upstream_bridges',
ValidationError(
_('Specify at least one upstream bridge to use upstream '
'bridges.'), code='invalid'))
return cleaned_data
-2
View File
@@ -28,7 +28,6 @@ from plinth.modules.tor import forms, utils
class TestTor:
"""Test cases for testing the Tor module."""
@staticmethod
@pytest.mark.usefixtures('needs_root')
def test_is_apt_transport_tor_enabled():
@@ -51,7 +50,6 @@ class TestTor:
class TestTorForm:
"""Test whether Tor configration form works."""
@staticmethod
def test_bridge_validator():
"""Test upstream bridges' form field validator."""
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the Tor module.
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^apps/tor/$', views.index, name='index'),
]
+2 -2
View File
@@ -104,8 +104,8 @@ def get_real_apt_uri_path(aug, path):
def get_augeas():
"""Return an instance of Augeaus for processing APT configuration."""
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Aptsources/lens', 'Aptsources.lns')
aug.set('/augeas/load/Aptsources/incl[last() + 1]',
'/etc/apt/sources.list')
+1 -3
View File
@@ -50,9 +50,7 @@ class TransmissionAppView(views.AppView):
['get-configuration'])
configuration = json.loads(configuration)
status.update({
key.translate(str.maketrans({
'-': '_'
})): value
key.translate(str.maketrans({'-': '_'})): value
for key, value in configuration.items()
})
status['hostname'] = socket.gethostname()
+3 -4
View File
@@ -20,8 +20,7 @@ Application manifest for upgrades.
from plinth.modules.backups.api import validate as validate_backup
backup = validate_backup({
'config': {
backup = validate_backup(
{'config': {
'files': ['/etc/apt/apt.conf.d/20auto-upgrades']
}
})
}})
-2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
URLs for the upgrades module
"""
@@ -23,7 +22,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^sys/upgrades/$', views.UpgradesConfigurationView.as_view(),
name='index'),
+6 -12
View File
@@ -47,14 +47,13 @@ def get_group_choices():
class ValidNewUsernameCheckMixin(object):
"""Mixin to check if a username is valid for created new user."""
def clean_username(self):
"""Check for username collisions with system users."""
username = self.cleaned_data['username']
if self.instance.username != username and \
not self.is_valid_new_username():
raise ValidationError(
_('Username is taken or is reserved.'), code='invalid')
raise ValidationError(_('Username is taken or is reserved.'),
code='invalid')
return username
@@ -147,10 +146,8 @@ class UserUpdateForm(ValidNewUsernameCheckMixin,
plinth.forms.LanguageSelectionFormMixin, forms.ModelForm):
"""When user info is changed, also updates LDAP user."""
ssh_keys = forms.CharField(
label=ugettext_lazy('Authorized SSH Keys'),
required=False,
widget=forms.Textarea,
help_text=ugettext_lazy(
label=ugettext_lazy('Authorized SSH Keys'), required=False,
widget=forms.Textarea, help_text=ugettext_lazy(
'Setting an SSH public key will allow this user to '
'securely log in to the system without using a '
'password. You may enter multiple keys, one on each '
@@ -283,14 +280,12 @@ class UserUpdateForm(ValidNewUsernameCheckMixin,
class UserChangePasswordForm(SetPasswordForm):
"""Custom form that also updates password for LDAP users."""
def __init__(self, request, *args, **kwargs):
"""Initialize the form with extra request argument."""
self.request = request
super(UserChangePasswordForm, self).__init__(*args, **kwargs)
self.fields['new_password1'].widget.attrs.update({
'autofocus': 'autofocus'
})
self.fields['new_password1'].widget.attrs.update(
{'autofocus': 'autofocus'})
def save(self, commit=True):
"""Save the user model and change LDAP password as well."""
@@ -310,7 +305,6 @@ class UserChangePasswordForm(SetPasswordForm):
class FirstBootForm(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
"""User module first boot step: create a new admin user."""
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
+2 -2
View File
@@ -81,8 +81,8 @@ def _try_login_to_ssh(username, password, returncode=0):
def _action_file():
"""Return the path to the 'users' actions file."""
current_directory = pathlib.Path(__file__).parent
return str(
current_directory / '..' / '..' / '..' / '..' / 'actions' / 'users')
return str(current_directory / '..' / '..' / '..' / '..' / 'actions' /
'users')
@pytest.fixture(name='disable_restricted_access', autouse=True)
-1
View File
@@ -40,7 +40,6 @@ from .forms import (CreateUserForm, FirstBootForm, UserChangePasswordForm,
class ContextMixin(object):
"""Mixin to add 'title' to the template context."""
def get_context_data(self, **kwargs):
"""Add self.title to template context."""
context = super(ContextMixin, self).get_context_data(**kwargs)
+33 -19
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Helper functions for working with network manager.
"""
@@ -103,9 +102,8 @@ def get_status_from_connection(connection):
primary_connection = nm.Client.new(None).get_primary_connection()
status['primary'] = (
primary_connection and
primary_connection.get_uuid() == connection.get_uuid()
)
primary_connection
and primary_connection.get_uuid() == connection.get_uuid())
return status
@@ -131,18 +129,20 @@ def get_status_from_device(device):
ip4_config = device.get_ip4_config()
if ip4_config:
addresses = ip4_config.get_addresses()
status['ip4']['addresses'] = [{'address': address.get_address(),
'prefix': address.get_prefix()}
for address in addresses]
status['ip4']['addresses'] = [{
'address': address.get_address(),
'prefix': address.get_prefix()
} for address in addresses]
status['ip4']['gateway'] = ip4_config.get_gateway()
status['ip4']['nameservers'] = ip4_config.get_nameservers()
ip6_config = device.get_ip6_config()
if ip6_config:
addresses = ip6_config.get_addresses()
status['ip6']['addresses'] = [{'address': address.get_address(),
'prefix': address.get_prefix()}
for address in addresses]
status['ip6']['addresses'] = [{
'address': address.get_address(),
'prefix': address.get_prefix()
} for address in addresses]
status['ip6']['gateway'] = ip6_config.get_gateway()
status['ip6']['nameservers'] = ip6_config.get_nameservers()
@@ -188,8 +188,19 @@ def _get_wifi_channel_from_frequency(frequency):
# channel numbers. Search for a better solution! Even 5GHz is
# not included yet. Only the plain frequency will show up on 5GHz
# AP's.
channel_map = {2412: 1, 2417: 2, 2422: 3, 2427: 4, 2432: 5, 2437: 6,
2442: 7, 2447: 8, 2452: 9, 2457: 10, 2462: 11}
channel_map = {
2412: 1,
2417: 2,
2422: 3,
2427: 4,
2432: 5,
2437: 6,
2442: 7,
2447: 8,
2452: 9,
2457: 10,
2462: 11
}
try:
return channel_map[frequency]
except KeyError:
@@ -207,8 +218,8 @@ def get_connection_list():
for connection in client.get_connections():
# Display a friendly type name if known.
connection_type = connection.get_connection_type()
connection_type_name = CONNECTION_TYPE_NAMES.get(connection_type,
connection_type)
connection_type_name = CONNECTION_TYPE_NAMES.get(
connection_type, connection_type)
settings_connection = connection.get_setting_connection()
zone = settings_connection.get_zone()
@@ -250,8 +261,10 @@ def get_active_connection(connection_uuid):
found.
"""
connections = nm.Client.new(None).get_active_connections()
connections = {connection.get_uuid(): connection
for connection in connections}
connections = {
connection.get_uuid(): connection
for connection in connections
}
try:
return connections[connection_uuid]
except KeyError:
@@ -458,8 +471,8 @@ def activate_connection(connection_uuid):
client = nm.Client.new(None)
for device in client.get_devices():
if device.get_iface() == interface:
client.activate_connection_async(
connection, device, '/', None, _callback, None)
client.activate_connection_async(connection, device, '/', None,
_callback, None)
break
else:
raise DeviceNotFound(connection)
@@ -502,6 +515,7 @@ def wifi_scan():
access_points.append({
'interface_name': device.get_iface(),
'ssid': ssid_string,
'strength': access_point.get_strength()})
'strength': access_point.get_strength()
})
return access_points
-2
View File
@@ -32,7 +32,6 @@ logger = logging.getLogger(__name__)
class PackageException(Exception):
"""A package operation has failed."""
def __init__(self, error_string=None, error_details=None, *args, **kwargs):
"""Store apt-get error string and details."""
super(PackageException, self).__init__(*args, **kwargs)
@@ -48,7 +47,6 @@ class PackageException(Exception):
class Transaction(object):
"""Information about an ongoing transaction."""
def __init__(self, module_name, package_names):
"""Initialize transaction object.
-3
View File
@@ -43,7 +43,6 @@ _force_upgrader = None
class Helper(object):
"""Helper routines for modules to show progress."""
def __init__(self, module_name, module):
"""Initialize the object."""
self.module_name = module_name
@@ -421,11 +420,9 @@ class ForceUpgrader():
class TemporaryFailure(Exception):
"""Raised when upgrade fails but can be tried again immediately."""
class PermanentFailure(Exception):
"""Raised when upgrade fails and there is nothing more we wish to do.
"""
def __init__(self):
"""Initialize the force upgrader."""
if plinth.cfg.develop:
+1 -2
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Test module for custom context processors.
"""
@@ -37,7 +36,7 @@ def fixture_menu():
def test_common():
"""Verify that the common() function returns the correct values."""
cfg.read() # initialize config settings
cfg.read() # initialize config settings
request = HttpRequest()
request.path = '/aaa/bbb/ccc/'
+2 -2
View File
@@ -65,8 +65,8 @@ def test_shortcuts_api_with_empty_custom_shortcuts_list():
def test_shortcuts_api_with_custom_nextcloud_shortcut():
shortcuts = get_shortcuts_as_json()
assert len(shortcuts['shortcuts']) >= 1
assert any(
shortcut['name'] == 'NextCloud' for shortcut in shortcuts['shortcuts'])
assert any(shortcut['name'] == 'NextCloud'
for shortcut in shortcuts['shortcuts'])
@pytest.mark.usefixtures('nextcloud_shortcut')
+9 -3
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Test module for key/value store.
"""
@@ -38,8 +37,15 @@ def test_get_set():
def test_get_set_complex_structures():
"""Verify that complex structures can be stored and retrieved."""
key = 'compex_structure'
expected_value = {'k1': 1, 'k2': [2, 3], 'k3': 4.5, 'k4': 'Hello',
'k5': {'a': 'b'}}
expected_value = {
'k1': 1,
'k2': [2, 3],
'k3': 4.5,
'k4': 'Hello',
'k5': {
'a': 'b'
}
}
kvstore.set(key, expected_value)
actual_value = kvstore.get(key)
assert expected_value == actual_value
-2
View File
@@ -42,7 +42,6 @@ def fixture_kwargs():
class TestSetupMiddleware:
"""Test cases for setup middleware."""
@staticmethod
@pytest.fixture(name='middleware')
def fixture_middleware(load_cfg):
@@ -135,7 +134,6 @@ class TestSetupMiddleware:
class TestAdminMiddleware:
"""Test cases for admin middleware."""
@staticmethod
@pytest.fixture(name='middleware')
def fixture_middleware(load_cfg):
Loaded 100 of 134 files, more files were not shown because too many files have changed in this diff. Show more