pagekite: Fix issue with setting port

- When the current configuration does not contain a port and we try to
  set the port for the frontend server, it fails.  This patch fixes
  that.

- Minor styling and spelling fixes.

- Make sure that if port is not set for frontend, it will be set on
  saving the form.
This commit is contained in:
Sunil Mohan Adapa 2015-10-11 17:17:44 +05:30
parent aad69deb6e
commit 670be77b9a
2 changed files with 13 additions and 9 deletions

View File

@ -53,7 +53,7 @@ def parse_arguments():
subparsers.add_parser('stop-and-disable', help='Disable PageKite service')
subparsers.add_parser('restart', help='Restart PageKite service')
subparsers.add_parser('is-disabled',
help=('Wether PageKite is disabled in the file '
help=('Whether PageKite is disabled in the file '
'/etc/pagekite.d/10_accounts.rc'))
# Frontend

View File

@ -94,7 +94,7 @@ def get_pagekite_config():
# To enable PageKite two things are necessary:
# 1) pagekite not being disabled in /etc/pagekite.d/10_account.rc
# 2) the pagekite service running
is_disabled = run(['is-disabled']).strip()=='true'
is_disabled = (run(['is-disabled']).strip() == 'true')
service_running = action_utils.service_is_running('pagekite')
status['enabled'] = service_running and not is_disabled
@ -102,16 +102,20 @@ def get_pagekite_config():
status.update(get_kite_details())
# PageKite frontend server
server = run(['get-frontend'])
# Frontend-Entries are only considered valid if there's a ':' in them
# otherwise, pagekite refuses to work, and we only set values with ':'.
server = run(['get-frontend']).strip()
# Frontend entries are only considered valid if there's a ':' in
# them otherwise, pagekite refuses to work, and we only set values
# with ':'.
if ':' in server:
server_domain, server_port = server.strip().split(':')
server_domain, server_port = server.split(':')
status['server_domain'] = server_domain
status['server_port'] = server_port
status['server_port'] = int(server_port)
else:
# no valid entry exists, default to port 80
status['server_port'] = 80
status['server_domain'] = server
# No valid entry exists, default to port 80. Hack: Return
# string instead of int to force setting port on save
status['server_port'] = '80'
return status