Fix running apps
This commit is contained in:
parent
e8a0783139
commit
5923dee839
|
@ -45,7 +45,7 @@ setup(
|
|||
author_email="duncan.sommerville@sourcefabric.org",
|
||||
license="MIT",
|
||||
packages=["airtime-celery"],
|
||||
install_requires=["soundcloud", "celery < 4", "kombu < 3.1", "configobj"],
|
||||
install_requires=["soundcloud", "celery", "kombu", "configobj"],
|
||||
zip_safe=False,
|
||||
data_files=data_files,
|
||||
)
|
||||
|
|
|
@ -122,7 +122,7 @@ class ApiRequest(object):
|
|||
try:
|
||||
req = urllib.request.Request(final_url, _post_data)
|
||||
f = urllib.request.urlopen(req, timeout=ApiRequest.API_HTTP_REQUEST_TIMEOUT)
|
||||
content_type = f.info().getheader('Content-Type')
|
||||
content_type = f.info().get_content_type()
|
||||
response = f.read()
|
||||
#Everything that calls an ApiRequest should be catching URLError explicitly
|
||||
#(according to the other comments in this file and a cursory grep through the code)
|
||||
|
|
|
@ -4,7 +4,7 @@ from mock import MagicMock, patch
|
|||
from api_clients.api_client import ApcUrl, ApiRequest
|
||||
|
||||
class ResponseInfo:
|
||||
def getheader(self, name):
|
||||
def get_content_type(self):
|
||||
return 'application/json'
|
||||
|
||||
class TestApiRequest(unittest.TestCase):
|
||||
|
|
|
@ -123,59 +123,6 @@ except Exception as e:
|
|||
print("Couldn't configure logging: {}".format(e))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def configure_locale():
|
||||
"""
|
||||
Silly hacks to force Python 2.x to run in UTF-8 mode. Not portable at all,
|
||||
however serves our purpose at the moment.
|
||||
|
||||
More information available here:
|
||||
http://stackoverflow.com/questions/3828723/why-we-need-sys-setdefaultencodingutf-8-in-a-py-script
|
||||
"""
|
||||
logger.debug("Before %s", locale.nl_langinfo(locale.CODESET))
|
||||
current_locale = locale.getlocale()
|
||||
|
||||
if current_locale[1] is None:
|
||||
logger.debug("No locale currently set. Attempting to get default locale.")
|
||||
default_locale = locale.getdefaultlocale()
|
||||
|
||||
if default_locale[1] is None:
|
||||
logger.debug(
|
||||
"No default locale exists. Let's try loading from \
|
||||
/etc/default/locale"
|
||||
)
|
||||
if os.path.exists("/etc/default/locale"):
|
||||
locale_config = ConfigObj("/etc/default/locale")
|
||||
lang = locale_config.get("LANG")
|
||||
new_locale = lang
|
||||
else:
|
||||
logger.error(
|
||||
"/etc/default/locale could not be found! Please \
|
||||
run 'sudo update-locale' from command-line."
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
new_locale = default_locale
|
||||
|
||||
logger.info(
|
||||
"New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale)
|
||||
)
|
||||
|
||||
importlib.reload(sys)
|
||||
sys.setdefaultencoding("UTF-8")
|
||||
current_locale_encoding = locale.getlocale()[1].lower()
|
||||
logger.debug("sys default encoding %s", sys.getdefaultencoding())
|
||||
logger.debug("After %s", locale.nl_langinfo(locale.CODESET))
|
||||
|
||||
if current_locale_encoding not in ["utf-8", "utf8"]:
|
||||
logger.error(
|
||||
"Need a UTF-8 locale. Currently '%s'. Exiting..." % current_locale_encoding
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
configure_locale()
|
||||
|
||||
# loading config file
|
||||
try:
|
||||
config = ConfigObj("/etc/airtime/airtime.conf")
|
||||
|
|
|
@ -15,9 +15,6 @@ import re
|
|||
|
||||
from configobj import ConfigObj
|
||||
|
||||
from poster.encode import multipart_encode
|
||||
from poster.streaminghttp import register_openers
|
||||
|
||||
from subprocess import Popen
|
||||
from subprocess import PIPE
|
||||
from threading import Thread
|
||||
|
@ -127,9 +124,6 @@ class ShowRecorder(Thread):
|
|||
|
||||
filename = os.path.split(filepath)[1]
|
||||
|
||||
# Register the streaming http handlers with urllib2
|
||||
register_openers()
|
||||
|
||||
# files is what requests actually expects
|
||||
files = {'file': open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance}
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ setup(name='airtime-playout',
|
|||
'future',
|
||||
'kombu',
|
||||
'mutagen',
|
||||
'poster3',
|
||||
'PyDispatcher',
|
||||
'pyinotify',
|
||||
'pytz',
|
||||
|
|
Loading…
Reference in New Issue