diff --git a/actions/firewall b/actions/firewall index 520115c24..98d40fe8d 100755 --- a/actions/firewall +++ b/actions/firewall @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- mode: python -*- # # This file is part of Plinth. @@ -69,7 +69,7 @@ def subcommand_get_installed(_): with open('/dev/null', 'w') as file_handle: status = subprocess.call(['which', 'firewalld'], stdout=file_handle) - print 'installed' if not status else 'not installed' + print('installed' if not status else 'not installed') def subcommand_get_status(_): diff --git a/actions/pagekite-configure b/actions/pagekite-configure index 229c0532c..8a22142a5 100755 --- a/actions/pagekite-configure +++ b/actions/pagekite-configure @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- mode: python -*- # # This file is part of Plinth. @@ -96,7 +96,7 @@ def subcommand_get_installed(_): with open('/dev/null', 'w') as file_handle: status = subprocess.call(['which', 'pagekite'], stdout=file_handle) - print 'installed' if not status else 'not installed' + print('installed' if not status else 'not installed') def subcommand_start(_): @@ -116,7 +116,7 @@ def subcommand_stop(_): def subcommand_get_status(_): """Print status of the pagekite service""" is_enabled = is_pagekite_enabled() - print 'enabled' if is_enabled else 'disabled' + print('enabled' if is_enabled else 'disabled') def is_pagekite_enabled(): @@ -139,19 +139,19 @@ def subcommand_set_status(arguments): enable = arguments.enable == 'enable' is_enabled = is_pagekite_enabled() if enable and is_enabled: - print 'already enabled' + print('already enabled') return if not enable and not is_enabled: - print 'already disabled' + print('already disabled') return if enable: pagekite_enable() - print 'enabled' + print('enabled') else: pagekite_disable() - print 'disabled' + print('disabled') def pagekite_enable(): @@ -192,8 +192,8 @@ def subcommand_get_kite(_): kite_secret = match.group(1) continue - print kite_name - print kite_secret + print(kite_name) + print(kite_secret) def subcommand_set_kite(arguments): @@ -205,7 +205,7 @@ def subcommand_set_kite(arguments): file_path_new = os.path.join(CONFIG_DIR, '10_account.rc.new') with open(file_path, 'r') as read_file_object, \ os.fdopen(os.open(file_path_new, os.O_WRONLY | os.O_CREAT, - 0400), 'w') as write_file_object: + 0o400), 'w') as write_file_object: for line in read_file_object: if re.match(r'[ \t]*kitename[ \t]*=.*', line): write_file_object.write( @@ -225,7 +225,7 @@ def subcommand_set_kite(arguments): def subcommand_get_service_status(arguments): """Print status of the pagekite service""" is_enabled = is_service_enabled(arguments.service) - print 'enabled' if is_enabled else 'disabled' + print('enabled' if is_enabled else 'disabled') def is_service_enabled(service): @@ -253,19 +253,19 @@ def subcommand_set_service_status(arguments): enable = arguments.enable == 'enable' is_enabled = is_service_enabled(arguments.service) if enable and is_enabled: - print 'already enabled' + print('already enabled') return if not enable and not is_enabled: - print 'already disabled' + print('already disabled') return if enable: service_enable(arguments.service) - print 'enabled' + print('enabled') else: service_disable(arguments.service) - print 'disabled' + print('disabled') def service_enable(service_name): diff --git a/bin/plinth b/bin/plinth index 03bbcbe9a..14b6f3419 100755 --- a/bin/plinth +++ b/bin/plinth @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # This file is part of Plinth. # diff --git a/plinth/cfg.py b/plinth/cfg.py index c816f52ac..cbe47d897 100644 --- a/plinth/cfg.py +++ b/plinth/cfg.py @@ -1,8 +1,7 @@ -from plinth.menu import Menu +import configparser import os -import ConfigParser -from ConfigParser import SafeConfigParser +from plinth.menu import Menu product_name = None box_name = None @@ -39,7 +38,7 @@ def read(): directory = os.path.join(directory, '..') CONFIG_FILE = os.path.join(directory, 'plinth.config') - parser = SafeConfigParser( + parser = configparser.SafeConfigParser( defaults={ 'root': os.path.realpath(directory), }) @@ -63,9 +62,9 @@ def read(): try: value = parser.get(section, name) globals()[name] = value - except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): - print ('Configuration does not contain the {}.{} option.' - .format(section, name)) + except (configparser.NoSectionError, configparser.NoOptionError): + print('Configuration does not contain the {}.{} option.' + .format(section, name)) raise global port # pylint: disable-msg=W0603 diff --git a/plinth/modules/firewall/firewall.py b/plinth/modules/firewall/firewall.py index 633f2d665..0af54691b 100644 --- a/plinth/modules/firewall/firewall.py +++ b/plinth/modules/firewall/firewall.py @@ -60,7 +60,7 @@ def index(request): return TemplateResponse( request, 'firewall.html', {'title': _('Firewall'), - 'services': service_module.SERVICES.values(), + 'services': list(service_module.SERVICES.values()), 'internal_enabled_services': internal_enabled_services, 'external_enabled_services': external_enabled_services}) diff --git a/plinth/modules/santiago/santiago.py b/plinth/modules/santiago/santiago.py index d07b713a2..2291d6ee6 100644 --- a/plinth/modules/santiago/santiago.py +++ b/plinth/modules/santiago/santiago.py @@ -52,7 +52,7 @@ class Santiago(PagePlugin): admin['santiago']['address'] = "b5wycujkfh2jxfdo.onion" cfg.users['admin'] = admin return cfg.users['admin']['santiago']['address'] - print "Need to add these two lines to /etc/torrc:\n%s" % hidden_service_config + print("Need to add these two lines to /etc/torrc:\n%s" % hidden_service_config) return "" def check_for_hidden_service(self): diff --git a/plinth/tests/__init__.py b/plinth/tests/__init__.py index 656350883..d883d7658 100644 --- a/plinth/tests/__init__.py +++ b/plinth/tests/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # This file is part of Plinth. # diff --git a/plinth/tests/test_actions.py b/plinth/tests/test_actions.py index 613afa8c4..11995a935 100644 --- a/plinth/tests/test_actions.py +++ b/plinth/tests/test_actions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- mode: python; mode: auto-fill; fill-column: 80 -*- import os diff --git a/run b/run index 03bbcbe9a..14b6f3419 100755 --- a/run +++ b/run @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # This file is part of Plinth. # diff --git a/setup.py b/setup.py index 41967fad5..7f545d4ba 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # This file is part of Plinth. #