minor fixes and move certificate location

This commit is contained in:
Tim Bentley 2013-03-29 20:58:06 +00:00
parent eb51590bec
commit efa7d8c8c0
5 changed files with 11 additions and 14 deletions

View File

@ -63,7 +63,6 @@ class AppLocation(object):
VersionDir = 5
CacheDir = 6
LanguageDir = 7
SharedData = 8
# Base path where data/config/cache dir is located
BaseDir = None
@ -150,18 +149,18 @@ def _get_os_dir_path(dir_type):
if sys.platform == u'win32':
if dir_type == AppLocation.DataDir:
return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp', u'data')
elif dir_type == AppLocation.LanguageDir or dir_type == AppLocation.SharedData:
elif dir_type == AppLocation.LanguageDir:
return os.path.split(openlp.__file__)[0]
return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp')
elif sys.platform == u'darwin':
if dir_type == AppLocation.DataDir:
return os.path.join(unicode(os.getenv(u'HOME'), encoding),
u'Library', u'Application Support', u'openlp', u'Data')
elif dir_type == AppLocation.LanguageDir or dir_type == AppLocation.SharedData:
elif dir_type == AppLocation.LanguageDir:
return os.path.split(openlp.__file__)[0]
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'Library', u'Application Support', u'openlp')
else:
if dir_type == AppLocation.LanguageDir or dir_type == AppLocation.SharedData:
if dir_type == AppLocation.LanguageDir:
prefixes = [u'/usr/local', u'/usr']
for prefix in prefixes:
directory = os.path.join(prefix, u'share', u'openlp')

View File

@ -190,11 +190,11 @@ class HttpServer(object):
if Settings().value(self.plugin.settings_section + u'/https enabled'):
port = Settings().value(self.plugin.settings_section + u'/https port')
address = Settings().value(self.plugin.settings_section + u'/ip address')
shared_data = AppLocation.get_directory(AppLocation.SharedData)
local_data = AppLocation.get_directory(AppLocation.DataDir)
cherrypy.config.update({u'server.socket_host': str(address),
u'server.socket_port': port,
u'server.ssl_certificate': os.path.join(shared_data, u'openlp.crt'),
u'server.ssl_private_key': os.path.join(shared_data, u'openlp.key')})
u'server.ssl_certificate': os.path.join(local_data, u'remotes', u'openlp.crt'),
u'server.ssl_private_key': os.path.join(local_data, u'remotes', u'openlp.key')})
else:
port = Settings().value(self.plugin.settings_section + u'/port')
address = Settings().value(self.plugin.settings_section + u'/ip address')

View File

@ -217,9 +217,9 @@ class RemoteTab(SettingsTab):
self.address_edit.setText(Settings().value(self.settings_section + u'/ip address'))
self.twelve_hour = Settings().value(self.settings_section + u'/twelve hour')
self.twelve_hour_check_box.setChecked(self.twelve_hour)
shared_data = AppLocation.get_directory(AppLocation.SharedData)
if not os.path.exists(os.path.join(shared_data, u'openlp.crt')) or \
not os.path.exists(os.path.join(shared_data, u'openlp.key')):
local_data = AppLocation.get_directory(AppLocation.DataDir)
if not os.path.exists(os.path.join(local_data, u'remotes', u'openlp.crt')) or \
not os.path.exists(os.path.join(local_data, u'remotes', u'openlp.key')):
self.https_settings_group_box.setChecked(False)
self.https_settings_group_box.setEnabled(False)
self.https_error_label.setVisible(True)

View File

@ -1 +0,0 @@
__author__ = 'tim'

View File

@ -5,7 +5,7 @@ import os
from unittest import TestCase
from tempfile import mkstemp
from mock import patch, MagicMock
from mock import MagicMock
from openlp.core.lib import Settings
from openlp.plugins.remotes.lib.httpserver import HttpRouter, fetch_password, sha_password_encrypter
@ -51,7 +51,6 @@ class TestRouter(TestCase):
# GIVEN: A default configuration
# WHEN: called with the defined userid
password = fetch_password(u'itwinkle')
print password
# THEN: the function should return None
self.assertEqual(password, None, u'The result for fetch_password should be None')
@ -75,7 +74,7 @@ class TestRouter(TestCase):
# GIVEN: A default configuration
# WHEN: called with the defined userid
required_password = sha_password_encrypter(u'password')
test_value = '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
test_value = u'5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
# THEN: the function should return the correct password
self.assertEqual(required_password, test_value,