From dfe3f077fd53be26c47918f31aa30cf61515e9e5 Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Mon, 13 Mar 2017 16:28:07 +0100 Subject: [PATCH] Replace std_err_override with logging.captureWarnings(True) in pypo The quite ugly hack with std_err_override seems to have been made for python < 2.7. Since all major distros have al least python 2.7 installed we can stop using the std_err_override hack. This removes it from pypo, media-monitor still uses the module and we can completely delete it when we have remove media-monitor after having maybe backported the watched folders feature to analyzer. --- python_apps/pypo/bin/pyponotify | 2 +- python_apps/pypo/pypo/__main__.py | 2 +- python_apps/pypo/pypo/pypofetch.py | 4 +--- python_apps/pypo/pypo/pypofile.py | 5 +---- python_apps/pypo/pypo/pypomessagehandler.py | 5 +---- python_apps/pypo/pypo/pypopush.py | 5 +---- 6 files changed, 6 insertions(+), 17 deletions(-) diff --git a/python_apps/pypo/bin/pyponotify b/python_apps/pypo/bin/pyponotify index bf316480a..9d8fe4ab8 100755 --- a/python_apps/pypo/bin/pyponotify +++ b/python_apps/pypo/bin/pyponotify @@ -28,7 +28,6 @@ from configobj import ConfigObj # custom imports #from util import * from api_clients import * -from std_err_override import LogWriter LOG_LEVEL = logging.INFO LOG_PATH = '/var/log/airtime/pypo/notify.log' @@ -54,6 +53,7 @@ parser.add_option("-n", "--liquidsoap-started", help="notify liquidsoap started" (options, args) = parser.parse_args() # Set up logging +logging.captureWarnings(True) logFormatter = logging.Formatter("%(asctime)s [%(module)s] [%(levelname)-5.5s] %(message)s") rootLogger = logging.getLogger() rootLogger.setLevel(LOG_LEVEL) diff --git a/python_apps/pypo/pypo/__main__.py b/python_apps/pypo/pypo/__main__.py index 498c13c5f..09f6abd1d 100644 --- a/python_apps/pypo/pypo/__main__.py +++ b/python_apps/pypo/pypo/__main__.py @@ -31,11 +31,11 @@ from configobj import ConfigObj # custom imports from api_clients import api_client -#from std_err_override import LogWriter import pure LOG_PATH = '/var/log/airtime/pypo/pypo.log' LOG_LEVEL = logging.INFO +logging.captureWarnings(True) # Set up command-line options parser = OptionParser() diff --git a/python_apps/pypo/pypo/pypofetch.py b/python_apps/pypo/pypo/pypofetch.py index 6406436ac..d9fa34616 100644 --- a/python_apps/pypo/pypo/pypofetch.py +++ b/python_apps/pypo/pypo/pypofetch.py @@ -18,7 +18,6 @@ from threading import Thread, Timer from subprocess import Popen, PIPE from api_clients import api_client -from std_err_override import LogWriter from timeout import ls_timeout @@ -28,8 +27,7 @@ def keyboardInterruptHandler(signum, frame): sys.exit(0) signal.signal(signal.SIGINT, keyboardInterruptHandler) -#need to wait for Python 2.7 for this.. -#logging.captureWarnings(True) +logging.captureWarnings(True) POLL_INTERVAL = 480 diff --git a/python_apps/pypo/pypo/pypofile.py b/python_apps/pypo/pypo/pypofile.py index 673a4fd72..8bb7a054e 100644 --- a/python_apps/pypo/pypo/pypofile.py +++ b/python_apps/pypo/pypo/pypofile.py @@ -16,12 +16,9 @@ import json import hashlib from requests.exceptions import ConnectionError, HTTPError, Timeout -from std_err_override import LogWriter - CONFIG_PATH = '/etc/airtime/airtime.conf' -#need to wait for Python 2.7 for this.. -#logging.captureWarnings(True) +logging.captureWarnings(True) class PypoFile(Thread): diff --git a/python_apps/pypo/pypo/pypomessagehandler.py b/python_apps/pypo/pypo/pypomessagehandler.py index 043cc6984..61caab976 100644 --- a/python_apps/pypo/pypo/pypomessagehandler.py +++ b/python_apps/pypo/pypo/pypomessagehandler.py @@ -13,10 +13,7 @@ from kombu.simple import SimpleQueue from amqp.exceptions import AMQPError import json -from std_err_override import LogWriter - -#need to wait for Python 2.7 for this.. -#logging.captureWarnings(True) +logging.captureWarnings(True) class PypoMessageHandler(Thread): diff --git a/python_apps/pypo/pypo/pypopush.py b/python_apps/pypo/pypo/pypopush.py index 9b280bac1..e9b809473 100644 --- a/python_apps/pypo/pypo/pypopush.py +++ b/python_apps/pypo/pypo/pypopush.py @@ -21,12 +21,9 @@ from Queue import Empty, Queue from threading import Thread from api_clients import api_client -from std_err_override import LogWriter from timeout import ls_timeout - -#need to wait for Python 2.7 for this.. -#logging.captureWarnings(True) +logging.captureWarnings(True) PUSH_INTERVAL = 2