Require and use Python3

This commit is contained in:
Sunil Mohan Adapa 2014-10-01 11:31:51 +05:30
parent 5630a96b77
commit c9d8bb9d00
10 changed files with 30 additions and 31 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# -*- mode: python -*- # -*- mode: python -*-
# #
# This file is part of Plinth. # This file is part of Plinth.
@ -69,7 +69,7 @@ def subcommand_get_installed(_):
with open('/dev/null', 'w') as file_handle: with open('/dev/null', 'w') as file_handle:
status = subprocess.call(['which', 'firewalld'], stdout=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(_): def subcommand_get_status(_):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# -*- mode: python -*- # -*- mode: python -*-
# #
# This file is part of Plinth. # This file is part of Plinth.
@ -96,7 +96,7 @@ def subcommand_get_installed(_):
with open('/dev/null', 'w') as file_handle: with open('/dev/null', 'w') as file_handle:
status = subprocess.call(['which', 'pagekite'], stdout=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(_): def subcommand_start(_):
@ -116,7 +116,7 @@ def subcommand_stop(_):
def subcommand_get_status(_): def subcommand_get_status(_):
"""Print status of the pagekite service""" """Print status of the pagekite service"""
is_enabled = is_pagekite_enabled() is_enabled = is_pagekite_enabled()
print 'enabled' if is_enabled else 'disabled' print('enabled' if is_enabled else 'disabled')
def is_pagekite_enabled(): def is_pagekite_enabled():
@ -139,19 +139,19 @@ def subcommand_set_status(arguments):
enable = arguments.enable == 'enable' enable = arguments.enable == 'enable'
is_enabled = is_pagekite_enabled() is_enabled = is_pagekite_enabled()
if enable and is_enabled: if enable and is_enabled:
print 'already enabled' print('already enabled')
return return
if not enable and not is_enabled: if not enable and not is_enabled:
print 'already disabled' print('already disabled')
return return
if enable: if enable:
pagekite_enable() pagekite_enable()
print 'enabled' print('enabled')
else: else:
pagekite_disable() pagekite_disable()
print 'disabled' print('disabled')
def pagekite_enable(): def pagekite_enable():
@ -192,8 +192,8 @@ def subcommand_get_kite(_):
kite_secret = match.group(1) kite_secret = match.group(1)
continue continue
print kite_name print(kite_name)
print kite_secret print(kite_secret)
def subcommand_set_kite(arguments): 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') file_path_new = os.path.join(CONFIG_DIR, '10_account.rc.new')
with open(file_path, 'r') as read_file_object, \ with open(file_path, 'r') as read_file_object, \
os.fdopen(os.open(file_path_new, os.O_WRONLY | os.O_CREAT, 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: for line in read_file_object:
if re.match(r'[ \t]*kitename[ \t]*=.*', line): if re.match(r'[ \t]*kitename[ \t]*=.*', line):
write_file_object.write( write_file_object.write(
@ -225,7 +225,7 @@ def subcommand_set_kite(arguments):
def subcommand_get_service_status(arguments): def subcommand_get_service_status(arguments):
"""Print status of the pagekite service""" """Print status of the pagekite service"""
is_enabled = is_service_enabled(arguments.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): def is_service_enabled(service):
@ -253,19 +253,19 @@ def subcommand_set_service_status(arguments):
enable = arguments.enable == 'enable' enable = arguments.enable == 'enable'
is_enabled = is_service_enabled(arguments.service) is_enabled = is_service_enabled(arguments.service)
if enable and is_enabled: if enable and is_enabled:
print 'already enabled' print('already enabled')
return return
if not enable and not is_enabled: if not enable and not is_enabled:
print 'already disabled' print('already disabled')
return return
if enable: if enable:
service_enable(arguments.service) service_enable(arguments.service)
print 'enabled' print('enabled')
else: else:
service_disable(arguments.service) service_disable(arguments.service)
print 'disabled' print('disabled')
def service_enable(service_name): def service_enable(service_name):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# #
# This file is part of Plinth. # This file is part of Plinth.
# #

View File

@ -1,8 +1,7 @@
from plinth.menu import Menu import configparser
import os import os
import ConfigParser from plinth.menu import Menu
from ConfigParser import SafeConfigParser
product_name = None product_name = None
box_name = None box_name = None
@ -39,7 +38,7 @@ def read():
directory = os.path.join(directory, '..') directory = os.path.join(directory, '..')
CONFIG_FILE = os.path.join(directory, 'plinth.config') CONFIG_FILE = os.path.join(directory, 'plinth.config')
parser = SafeConfigParser( parser = configparser.SafeConfigParser(
defaults={ defaults={
'root': os.path.realpath(directory), 'root': os.path.realpath(directory),
}) })
@ -63,9 +62,9 @@ def read():
try: try:
value = parser.get(section, name) value = parser.get(section, name)
globals()[name] = value globals()[name] = value
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): except (configparser.NoSectionError, configparser.NoOptionError):
print ('Configuration does not contain the {}.{} option.' print('Configuration does not contain the {}.{} option.'
.format(section, name)) .format(section, name))
raise raise
global port # pylint: disable-msg=W0603 global port # pylint: disable-msg=W0603

View File

@ -60,7 +60,7 @@ def index(request):
return TemplateResponse( return TemplateResponse(
request, 'firewall.html', request, 'firewall.html',
{'title': _('Firewall'), {'title': _('Firewall'),
'services': service_module.SERVICES.values(), 'services': list(service_module.SERVICES.values()),
'internal_enabled_services': internal_enabled_services, 'internal_enabled_services': internal_enabled_services,
'external_enabled_services': external_enabled_services}) 'external_enabled_services': external_enabled_services})

View File

@ -52,7 +52,7 @@ class Santiago(PagePlugin):
admin['santiago']['address'] = "b5wycujkfh2jxfdo.onion" admin['santiago']['address'] = "b5wycujkfh2jxfdo.onion"
cfg.users['admin'] = admin cfg.users['admin'] = admin
return cfg.users['admin']['santiago']['address'] 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 "" return ""
def check_for_hidden_service(self): def check_for_hidden_service(self):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# #
# This file is part of Plinth. # This file is part of Plinth.
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# -*- mode: python; mode: auto-fill; fill-column: 80 -*- # -*- mode: python; mode: auto-fill; fill-column: 80 -*-
import os import os

2
run
View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# #
# This file is part of Plinth. # This file is part of Plinth.
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# #
# This file is part of Plinth. # This file is part of Plinth.
# #