mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
removed default frontend stuff from actions
it's all handled via get-frontend and set-frontend now. and there are now some doctests in actions/pagekite_util.py
This commit is contained in:
1 parent
e0fa113a9c
commit
99bfda3b69
5 files changed
+33
-50
No files matched your search
+13
-27
@@ -60,15 +60,6 @@ def parse_arguments():
|
||||
subparsers.add_parser('enable', help='Enable PageKite service')
|
||||
subparsers.add_parser('disable', help='Disable PageKite service')
|
||||
|
||||
|
||||
# get/set using the default pagekite.net frontend
|
||||
subparsers.add_parser('get-pagekitenet-frontend-status',
|
||||
help='Get whether pagekite.net frontend is enabled')
|
||||
subparsers.add_parser('enable-pagekitenet-frontend',
|
||||
help='Enable using default pagekite.net frontend')
|
||||
subparsers.add_parser('disable-pagekitenet-frontend',
|
||||
help='Disable default pagekite.net frontend')
|
||||
|
||||
# Frontend
|
||||
subparsers.add_parser('get-frontend', help='Get pagekite frontend')
|
||||
set_frontend = subparsers.add_parser('set-frontend',
|
||||
@@ -130,23 +121,24 @@ def subcommand_disable(_):
|
||||
|
||||
def subcommand_get_frontend(_):
|
||||
"""Get pagekite frontend url"""
|
||||
url = aug.get(PATHS['frontend'])
|
||||
print url if url else ""
|
||||
if aug.match(PATHS['defaults']):
|
||||
print "pagekite.net"
|
||||
else:
|
||||
url = aug.get(PATHS['frontend'])
|
||||
print url if url else ""
|
||||
|
||||
|
||||
def subcommand_set_frontend(arguments):
|
||||
"""Set pagekite frontend url and disable default pagekite.net frontend"""
|
||||
aug.remove(PATHS['defaults'])
|
||||
aug.set(PATHS['frontend'], arguments.url)
|
||||
aug.save()
|
||||
"""Set pagekite frontend url, taking care of defaults and pagekite.net"""
|
||||
if arguments.url in ('pagekite.net', 'defaults', 'default'):
|
||||
enable_pagekitenet_frontend()
|
||||
else:
|
||||
aug.remove(PATHS['defaults'])
|
||||
aug.set(PATHS['frontend'], arguments.url)
|
||||
aug.save()
|
||||
|
||||
|
||||
def subcommand_get_pagekitenet_frontend_status(_):
|
||||
match = aug.match(PATHS['defaults'])
|
||||
print "enabled" if match else "disabled"
|
||||
|
||||
|
||||
def subcommand_enable_pagekitenet_frontend(_):
|
||||
def enable_pagekitenet_frontend():
|
||||
"""Enable using default pageket.net frontend
|
||||
|
||||
This disables any other frontends.
|
||||
@@ -157,12 +149,6 @@ def subcommand_enable_pagekitenet_frontend(_):
|
||||
print "enabled"
|
||||
|
||||
|
||||
def subcommand_disable_pagekitenet_frontend(_):
|
||||
aug.remove(PATHS['defaults'])
|
||||
aug.save()
|
||||
print "disabled"
|
||||
|
||||
|
||||
def pagekite_enable():
|
||||
"""Enable the pagekite daemon"""
|
||||
aug.remove(PATHS['abort_not_configured'])
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
#
|
||||
|
||||
"""
|
||||
Utilities for configuring PageKite.
|
||||
|
||||
The variables/functions defined here are used by both the action script
|
||||
and the plinth pagekite module.
|
||||
|
||||
For example the functionality to convert pagekite service_on strings like
|
||||
"http:@kitename:localhost:80:@kitestring"
|
||||
into parameter dictionaries and the other way round. And functions that we want
|
||||
to be covered by tests.
|
||||
"""
|
||||
# ATTENTION: This file has to be both python2 and python3 compatible
|
||||
|
||||
@@ -37,7 +34,11 @@ SERVICE_PARAMS = ['protocol', 'kitename', 'backend_host', 'backend_port',
|
||||
|
||||
|
||||
def convert_to_service(service_string):
|
||||
""" Convert a service string into a service parameter dictionary"""
|
||||
""" Convert a service string into a service parameter dictionary
|
||||
>>> convert_to_service('https/443:@kitename:localhost:443:@kitesecret')
|
||||
{'kitename': '@kitename', 'backend_host': 'localhost', \
|
||||
'secret': '@kitesecret', 'protocol': 'https/443', 'backend_port': '443'}
|
||||
"""
|
||||
# The actions.py uses shlex.quote() to escape/quote malicious user input.
|
||||
# That affects '*.@kitename', so the params string gets quoted.
|
||||
# If the string is escaped and contains '*.@kitename', look whether shlex
|
||||
@@ -75,7 +76,13 @@ def convert_to_service(service_string):
|
||||
|
||||
|
||||
def convert_service_to_string(service):
|
||||
""" Convert service dict into a ":"-separated parameter string """
|
||||
""" Convert service dict into a ":"-separated parameter string
|
||||
|
||||
>>> convert_service_to_string({'kitename': '@kitename', \
|
||||
'backend_host': 'localhost', 'secret': '@kitesecret', \
|
||||
'protocol': 'https/443', 'backend_port': '443'})
|
||||
'https/443:@kitename:localhost:443:@kitesecret'
|
||||
"""
|
||||
try:
|
||||
service_string = ":".join([str(service[param]) for param in
|
||||
SERVICE_PARAMS])
|
||||
|
||||
Reference in new issue
Block a user