forked from openlp/openlp
Fixed OS specific string
Coding standard fixes
This commit is contained in:
parent
649494589a
commit
e56414e22c
@ -128,7 +128,7 @@ from openlp.core.common import AppLocation, Settings, translate
|
|||||||
from openlp.core.lib import Registry, PluginStatus, StringContent, image_to_byte
|
from openlp.core.lib import Registry, PluginStatus, StringContent, image_to_byte
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
file_types = {
|
FILE_TYPES = {
|
||||||
'.html': 'text/html',
|
'.html': 'text/html',
|
||||||
'.css': 'text/css',
|
'.css': 'text/css',
|
||||||
'.js': 'application/javascript',
|
'.js': 'application/javascript',
|
||||||
@ -361,8 +361,7 @@ class HttpRouter(object):
|
|||||||
try:
|
try:
|
||||||
if ext == '.html':
|
if ext == '.html':
|
||||||
variables = self.template_vars
|
variables = self.template_vars
|
||||||
content = Template(filename=path, input_encoding='utf-8',
|
content = Template(filename=path, input_encoding='utf-8', output_encoding='utf-8').render(**variables)
|
||||||
output_encoding='utf-8').render(**variables)
|
|
||||||
else:
|
else:
|
||||||
file_handle = open(path, 'rb')
|
file_handle = open(path, 'rb')
|
||||||
log.debug('Opened %s' % path)
|
log.debug('Opened %s' % path)
|
||||||
@ -386,7 +385,7 @@ class HttpRouter(object):
|
|||||||
"""
|
"""
|
||||||
content_type = 'text/plain'
|
content_type = 'text/plain'
|
||||||
ext = os.path.splitext(file_name)[1]
|
ext = os.path.splitext(file_name)[1]
|
||||||
content_type = file_types.get(ext, 'text/plain')
|
content_type = FILE_TYPES.get(ext, 'text/plain')
|
||||||
return ext, content_type
|
return ext, content_type
|
||||||
|
|
||||||
def poll(self):
|
def poll(self):
|
||||||
|
@ -37,7 +37,8 @@ from PyQt4 import QtGui
|
|||||||
|
|
||||||
from openlp.core.common import Settings
|
from openlp.core.common import Settings
|
||||||
from openlp.plugins.remotes.lib.httpserver import HttpRouter
|
from openlp.plugins.remotes.lib.httpserver import HttpRouter
|
||||||
from mock import MagicMock, patch, mock_open
|
from tests.functional import MagicMock, patch
|
||||||
|
from mock import mock_open
|
||||||
|
|
||||||
__default_settings__ = {
|
__default_settings__ = {
|
||||||
'remotes/twelve hour': True,
|
'remotes/twelve hour': True,
|
||||||
@ -50,6 +51,7 @@ __default_settings__ = {
|
|||||||
'remotes/ip address': '0.0.0.0'
|
'remotes/ip address': '0.0.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
class TestRouter(TestCase):
|
class TestRouter(TestCase):
|
||||||
"""
|
"""
|
||||||
@ -122,8 +124,7 @@ class TestRouter(TestCase):
|
|||||||
['test.gif', 'image/gif'], ['test.ico', 'image/x-icon'],
|
['test.gif', 'image/gif'], ['test.ico', 'image/x-icon'],
|
||||||
['test.png', 'image/png'], ['test.whatever', 'text/plain'],
|
['test.png', 'image/png'], ['test.whatever', 'text/plain'],
|
||||||
['test', 'text/plain'], ['', 'text/plain'],
|
['test', 'text/plain'], ['', 'text/plain'],
|
||||||
['/test/test.html', 'text/html'],
|
[os.path.join(TEST_PATH,'test.html'), 'text/html']]
|
||||||
['c:\\test\\test.html', 'text/html']]
|
|
||||||
# WHEN: calling each file type
|
# WHEN: calling each file type
|
||||||
for header in headers:
|
for header in headers:
|
||||||
ext, content_type = self.router.get_content_type(header[0])
|
ext, content_type = self.router.get_content_type(header[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user