From 7bb9c84863631006f4a464288dfa1b7de6b28cab Mon Sep 17 00:00:00 2001 From: fonfon Date: Wed, 3 Sep 2014 04:43:08 +0200 Subject: [PATCH 1/7] Fixed ImportError when running plinth as daemonized python package --- HACKING | 14 +++++--------- plinth/__init__.py | 2 ++ plinth/modules/first_boot/__init__.py | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/HACKING b/HACKING index 6dcc5321d..5d178d951 100644 --- a/HACKING +++ b/HACKING @@ -21,20 +21,16 @@ $ sudo python -m plinth --no-daemon --debug In this mode, Plinth runs in working directory without need for - installation. It uses a different config file (plinth.conf in working - directory) instead of the regular config file (/etc/plinth/plinth.conf). It - creates all that data and runtime files in data/var/*. To make Plinth - pickup the config file in working directory, simply delete - /etc/plinth/plinth.config. + installation. It uses the plinth.conf config file in the working + directory if no regular config file (/etc/plinth/plinth.conf) is found. + It creates all that data and runtime files in data/var/*. *Note:* This mode is supported only in a limited manner. The following are the unknown issues with it: - 1. It does not work without the --debug and --no-daemon flags. + 1. Help pages are also not built. Run 'make -C doc' manaully. - 2. Help pages are also not built. Run 'make -C doc' manaully. - - 3. Actions do not work when running as normal user without 'sudo' prefix. + 2. Actions do not work when running as normal user without 'sudo' prefix. You need to add 'actions' directory to be allowed for 'sudo' commands. See data/etc/sudoers.d/plinth for a hint. diff --git a/plinth/__init__.py b/plinth/__init__.py index 94f997920..6dfe195cb 100644 --- a/plinth/__init__.py +++ b/plinth/__init__.py @@ -19,4 +19,6 @@ Plinth package init file """ +from . import context_processors + __version__ = '0.3.2' diff --git a/plinth/modules/first_boot/__init__.py b/plinth/modules/first_boot/__init__.py index b9a2a74f5..fa89e3444 100644 --- a/plinth/modules/first_boot/__init__.py +++ b/plinth/modules/first_boot/__init__.py @@ -19,6 +19,6 @@ Plinth module for first boot wizard """ -from . import first_boot +from . import first_boot, middleware __all__ = ['first_boot'] From d27c3f69d1c785282b9713816738d5807e8c9914 Mon Sep 17 00:00:00 2001 From: fonfon Date: Wed, 3 Sep 2014 04:52:34 +0200 Subject: [PATCH 2/7] renamed get_group to get_or_create_group --- plinth/modules/expert_mode/expert_mode.py | 4 ++-- plinth/modules/lib/auth.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plinth/modules/expert_mode/expert_mode.py b/plinth/modules/expert_mode/expert_mode.py index b55992fa9..f7c40939c 100644 --- a/plinth/modules/expert_mode/expert_mode.py +++ b/plinth/modules/expert_mode/expert_mode.py @@ -5,7 +5,7 @@ from django.template.response import TemplateResponse from gettext import gettext as _ from plinth import cfg -from plinth.modules.lib.auth import get_group +from plinth.modules.lib.auth import get_or_create_group class ExpertsForm(forms.Form): # pylint: disable-msg=W0232 @@ -51,7 +51,7 @@ def _apply_changes(request, new_status): """Apply expert mode configuration""" message = (messages.info, _('Settings unchanged')) - expert_group = get_group('Expert') + expert_group = get_or_create_group('Expert') if new_status['expert_mode']: if not expert_group in request.user.groups.all(): request.user.groups.add(expert_group) diff --git a/plinth/modules/lib/auth.py b/plinth/modules/lib/auth.py index 0ff7bb82b..7b4c19ed2 100644 --- a/plinth/modules/lib/auth.py +++ b/plinth/modules/lib/auth.py @@ -15,10 +15,10 @@ def add_user(username, passphrase, name='', email='', expert=False): user.save() if expert: - user.groups.add(get_group('Expert')) + user.groups.add(get_or_create_group('Expert')) -def get_group(name): +def get_or_create_group(name): """Return an existing or newly created group with given name""" try: group = Group.objects.get(name__exact=name) From e1440a5ee54e4d3e5f84e2c705405ede58fed3e1 Mon Sep 17 00:00:00 2001 From: fonfon Date: Wed, 3 Sep 2014 04:56:31 +0200 Subject: [PATCH 3/7] formatting strings: %s automatically applies the str() method --- plinth/modules/config/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plinth/modules/config/config.py b/plinth/modules/config/config.py index 602a977c9..c7691332e 100644 --- a/plinth/modules/config/config.py +++ b/plinth/modules/config/config.py @@ -136,7 +136,7 @@ def _apply_changes(request, old_status, new_status): set_hostname(new_status['hostname']) except Exception as exception: messages.error(request, _('Error setting hostname: %s') % - str(exception)) + exception) else: messages.success(request, _('Hostname set')) else: @@ -147,7 +147,7 @@ def _apply_changes(request, old_status, new_status): actions.superuser_run('timezone-change', [new_status['time_zone']]) except Exception as exception: messages.error(request, _('Error setting time zone: %s') % - str(exception)) + exception) else: messages.success(request, _('Time zone set')) else: From d661b64a3325e7fc799a4eddd2372de6832f456d Mon Sep 17 00:00:00 2001 From: fonfon Date: Tue, 9 Sep 2014 16:20:35 +0200 Subject: [PATCH 4/7] fixed static dir of plinth-modules --- plinth/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plinth/__main__.py b/plinth/__main__.py index dcfc6cf0d..24e2214b2 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -99,7 +99,8 @@ def setup_server(): # our modules to Django apps instead of reinventing the wheel. # (we'll still have to serve the static files with cherrypy though) for module in module_loader.LOADED_MODULES: - static_dir = os.path.join(cfg.file_root, 'modules', module, 'static') + static_dir = os.path.join(cfg.file_root, 'plinth', 'modules', module, + 'static') if not os.path.isdir(static_dir): continue From 837d2d1d10195ccb6754cbb41e868b94b400283e Mon Sep 17 00:00:00 2001 From: fonfon Date: Tue, 9 Sep 2014 21:05:20 +0200 Subject: [PATCH 5/7] removed one relative import --- plinth/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plinth/__init__.py b/plinth/__init__.py index 6dfe195cb..16ada04f8 100644 --- a/plinth/__init__.py +++ b/plinth/__init__.py @@ -19,6 +19,6 @@ Plinth package init file """ -from . import context_processors +from plinth import context_processors __version__ = '0.3.2' From 43a614fca5623afb695a78925fe21a9536d9e19d Mon Sep 17 00:00:00 2001 From: fonfon Date: Thu, 11 Sep 2014 12:23:52 +0200 Subject: [PATCH 6/7] plinth should be run via './bin/plinth' now --- HACKING | 2 +- bin/plinth | 0 plinth/__init__.py | 2 -- plinth/modules/first_boot/__init__.py | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) mode change 100644 => 100755 bin/plinth diff --git a/HACKING b/HACKING index 5d178d951..2c21151fa 100644 --- a/HACKING +++ b/HACKING @@ -18,7 +18,7 @@ 2. Plinth also support running without installing (as much as possible). Simply run it as: - $ sudo python -m plinth --no-daemon --debug + $ sudo ./bin/plinth --no-daemon --debug In this mode, Plinth runs in working directory without need for installation. It uses the plinth.conf config file in the working diff --git a/bin/plinth b/bin/plinth old mode 100644 new mode 100755 diff --git a/plinth/__init__.py b/plinth/__init__.py index 16ada04f8..94f997920 100644 --- a/plinth/__init__.py +++ b/plinth/__init__.py @@ -19,6 +19,4 @@ Plinth package init file """ -from plinth import context_processors - __version__ = '0.3.2' diff --git a/plinth/modules/first_boot/__init__.py b/plinth/modules/first_boot/__init__.py index fa89e3444..b9a2a74f5 100644 --- a/plinth/modules/first_boot/__init__.py +++ b/plinth/modules/first_boot/__init__.py @@ -19,6 +19,6 @@ Plinth module for first boot wizard """ -from . import first_boot, middleware +from . import first_boot __all__ = ['first_boot'] From dde2614bebee7697e1c6aa5ab439d70b99e9d5f9 Mon Sep 17 00:00:00 2001 From: fonfon Date: Thu, 11 Sep 2014 15:34:35 +0200 Subject: [PATCH 7/7] use ./run instead of bin/plinth now for non-installed development --- HACKING | 2 +- run | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 run diff --git a/HACKING b/HACKING index 2c21151fa..fd7d461ed 100644 --- a/HACKING +++ b/HACKING @@ -18,7 +18,7 @@ 2. Plinth also support running without installing (as much as possible). Simply run it as: - $ sudo ./bin/plinth --no-daemon --debug + $ sudo ./run --no-daemon --debug In this mode, Plinth runs in working directory without need for installation. It uses the plinth.conf config file in the working diff --git a/run b/run new file mode 100755 index 000000000..03bbcbe9a --- /dev/null +++ b/run @@ -0,0 +1,21 @@ +#!/usr/bin/python +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +import plinth.__main__ + +plinth.__main__.main()