convert print statements to py3
This commit is contained in:
parent
2aa4392a38
commit
632ba9acfe
15 changed files with 54 additions and 40 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
def read_config_file(config_path):
|
def read_config_file(config_path):
|
||||||
|
@ -6,10 +7,10 @@ def read_config_file(config_path):
|
||||||
try:
|
try:
|
||||||
config.readfp(open(config_path))
|
config.readfp(open(config_path))
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Failed to open config file at " + config_path + ": " + e.strerror
|
print("Failed to open config file at {}: {}".format(config_path, e.strerror))
|
||||||
exit(-1)
|
exit(-1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e.strerror
|
print(e.strerror)
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"""Runs the airtime_analyzer application.
|
"""Runs the airtime_analyzer application.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import daemon
|
import daemon
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
@ -14,7 +15,7 @@ DEFAULT_HTTP_RETRY_PATH = '/tmp/airtime_analyzer_http_retries'
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
'''Entry-point for this application'''
|
'''Entry-point for this application'''
|
||||||
print "Airtime Analyzer " + VERSION
|
print("Airtime Analyzer {}".format(VERSION))
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-d", "--daemon", help="run as a daemon", action="store_true")
|
parser.add_argument("-d", "--daemon", help="run as a daemon", action="store_true")
|
||||||
parser.add_argument("--debug", help="log full debugging output", action="store_true")
|
parser.add_argument("--debug", help="log full debugging output", action="store_true")
|
||||||
|
@ -57,8 +58,8 @@ def check_if_media_monitor_is_running():
|
||||||
try:
|
try:
|
||||||
process_name = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
|
process_name = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
|
||||||
if 'media_monitor.py' in process_name:
|
if 'media_monitor.py' in process_name:
|
||||||
print "Error: This process conflicts with media_monitor, and media_monitor is running."
|
print("Error: This process conflicts with media_monitor, and media_monitor is running.")
|
||||||
print " Please terminate the running media_monitor.py process and try again."
|
print(" Please terminate the running media_monitor.py process and try again.")
|
||||||
exit(1)
|
exit(1)
|
||||||
except IOError: # proc has already terminated
|
except IOError: # proc has already terminated
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import sys
|
import sys
|
||||||
|
@ -5,7 +6,7 @@ import os
|
||||||
|
|
||||||
# Change directory since setuptools uses relative paths
|
# Change directory since setuptools uses relative paths
|
||||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
print script_path
|
print(script_path)
|
||||||
os.chdir(script_path)
|
os.chdir(script_path)
|
||||||
|
|
||||||
# Allows us to avoid installing the upstart init script when deploying airtime_analyzer
|
# Allows us to avoid installing the upstart init script when deploying airtime_analyzer
|
||||||
|
@ -16,7 +17,7 @@ if '--no-init-script' in sys.argv:
|
||||||
else:
|
else:
|
||||||
data_files = [('/etc/init', ['install/upstart/airtime_analyzer.conf']),
|
data_files = [('/etc/init', ['install/upstart/airtime_analyzer.conf']),
|
||||||
('/etc/init.d', ['install/sysvinit/airtime_analyzer'])]
|
('/etc/init.d', ['install/sysvinit/airtime_analyzer'])]
|
||||||
print data_files
|
print(data_files)
|
||||||
|
|
||||||
setup(name='airtime_analyzer',
|
setup(name='airtime_analyzer',
|
||||||
version='0.1',
|
version='0.1',
|
||||||
|
@ -49,8 +50,8 @@ setup(name='airtime_analyzer',
|
||||||
|
|
||||||
# Remind users to reload the initctl config so that "service start airtime_analyzer" works
|
# Remind users to reload the initctl config so that "service start airtime_analyzer" works
|
||||||
if data_files:
|
if data_files:
|
||||||
print "Remember to reload the initctl configuration"
|
print("Remember to reload the initctl configuration")
|
||||||
print "Run \"sudo initctl reload-configuration; sudo service airtime_analyzer restart\" now."
|
print("Run \"sudo initctl reload-configuration; sudo service airtime_analyzer restart\" now.")
|
||||||
print "Or on Ubuntu Xenial (16.04)"
|
print("Or on Ubuntu Xenial (16.04)")
|
||||||
print "Remember to reload the systemd configuration"
|
print("Remember to reload the systemd configuration")
|
||||||
print "Run \"sudo systemctl daemon-reload; sudo service airtime_analyzer restart\" now."
|
print("Run \"sudo systemctl daemon-reload; sudo service airtime_analyzer restart\" now.")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
import datetime
|
import datetime
|
||||||
import mutagen
|
import mutagen
|
||||||
import mock
|
import mock
|
||||||
|
@ -79,8 +80,8 @@ def test_ogg_stereo():
|
||||||
''' faac and avconv can't seem to create a proper mono AAC file... ugh
|
''' faac and avconv can't seem to create a proper mono AAC file... ugh
|
||||||
def test_aac_mono():
|
def test_aac_mono():
|
||||||
metadata = MetadataAnalyzer.analyze(u'tests/test_data/44100Hz-16bit-mono.m4a')
|
metadata = MetadataAnalyzer.analyze(u'tests/test_data/44100Hz-16bit-mono.m4a')
|
||||||
print "Mono AAC metadata:"
|
print("Mono AAC metadata:")
|
||||||
print metadata
|
print(metadata)
|
||||||
check_default_metadata(metadata)
|
check_default_metadata(metadata)
|
||||||
assert metadata['channels'] == 1
|
assert metadata['channels'] == 1
|
||||||
assert metadata['bit_rate'] == 80000
|
assert metadata['bit_rate'] == 80000
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from nose.tools import *
|
from nose.tools import *
|
||||||
from airtime_analyzer.replaygain_analyzer import ReplayGainAnalyzer
|
from airtime_analyzer.replaygain_analyzer import ReplayGainAnalyzer
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ def check_default_metadata(metadata):
|
||||||
'''
|
'''
|
||||||
tolerance = 0.30
|
tolerance = 0.30
|
||||||
expected_replaygain = 5.0
|
expected_replaygain = 5.0
|
||||||
print metadata['replay_gain']
|
print(metadata['replay_gain'])
|
||||||
assert abs(metadata['replay_gain'] - expected_replaygain) < tolerance
|
assert abs(metadata['replay_gain'] - expected_replaygain) < tolerance
|
||||||
|
|
||||||
def test_missing_replaygain():
|
def test_missing_replaygain():
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
from __future__ import print_function
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
print script_path
|
print(script_path)
|
||||||
os.chdir(script_path)
|
os.chdir(script_path)
|
||||||
|
|
||||||
setup(name='api_clients',
|
setup(name='api_clients',
|
||||||
|
@ -30,4 +31,4 @@ setup(name='api_clients',
|
||||||
# 'wsgiref'
|
# 'wsgiref'
|
||||||
],
|
],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
data_files=[])
|
data_files=[])
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print "Please run this as root."
|
print("Please run this as root.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def get_current_script_dir():
|
def get_current_script_dir():
|
||||||
|
@ -18,5 +19,5 @@ try:
|
||||||
shutil.copy(current_script_dir+"/../airtime-icecast-status.xsl", "/usr/share/icecast2/web")
|
shutil.copy(current_script_dir+"/../airtime-icecast-status.xsl", "/usr/share/icecast2/web")
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "exception: %s" % e
|
print("exception: {}".format(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -133,21 +134,20 @@ class Notify:
|
||||||
elif options.liquidsoap_started:
|
elif options.liquidsoap_started:
|
||||||
self.notify_liquidsoap_started()
|
self.notify_liquidsoap_started()
|
||||||
else:
|
else:
|
||||||
logger.debug("Unrecognized option in options(%s). Doing nothing" \
|
logger.debug("Unrecognized option in options({}). Doing nothing".format(options))
|
||||||
% str(options))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print
|
print()
|
||||||
print '#########################################'
|
print('#########################################')
|
||||||
print '# *** pypo *** #'
|
print('# *** pypo *** #')
|
||||||
print '# pypo notification gateway #'
|
print('# pypo notification gateway #')
|
||||||
print '#########################################'
|
print('#########################################')
|
||||||
|
|
||||||
# initialize
|
# initialize
|
||||||
try:
|
try:
|
||||||
n = Notify()
|
n = Notify()
|
||||||
n.run_with_options(options)
|
n.run_with_options(options)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print( traceback.format_exc() )
|
print(traceback.format_exc())
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
""" Runs Airtime liquidsoap
|
""" Runs Airtime liquidsoap
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import generate_liquidsoap_cfg
|
import generate_liquidsoap_cfg
|
||||||
|
@ -11,7 +12,7 @@ PYPO_HOME = '/var/tmp/airtime/pypo/'
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
'''Entry-point for this application'''
|
'''Entry-point for this application'''
|
||||||
print "Airtime Liquidsoap"
|
print("Airtime Liquidsoap")
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-d", "--debug", help="run in debug mode", action="store_true")
|
parser.add_argument("-d", "--debug", help="run in debug mode", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -49,7 +50,7 @@ def run():
|
||||||
generate_liquidsoap_config(ss)
|
generate_liquidsoap_config(ss)
|
||||||
successful = True
|
successful = True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "Unable to connect to the Airtime server."
|
print("Unable to connect to the Airtime server.")
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
logging.error("traceback: %s", traceback.format_exc())
|
logging.error("traceback: %s", traceback.format_exc())
|
||||||
if attempts == max_attempts:
|
if attempts == max_attempts:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from api_clients import *
|
from api_clients import *
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -16,8 +17,8 @@ elif dj_type == '--dj':
|
||||||
response = api_clients.check_live_stream_auth(username, password, source_type)
|
response = api_clients.check_live_stream_auth(username, password, source_type)
|
||||||
|
|
||||||
if 'msg' in response and response['msg'] == True:
|
if 'msg' in response and response['msg'] == True:
|
||||||
print response['msg']
|
print(response['msg'])
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print False
|
print(False)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
@ -36,7 +37,7 @@ def api_client(logger):
|
||||||
try:
|
try:
|
||||||
config = ConfigObj('/etc/airtime/airtime.conf')
|
config = ConfigObj('/etc/airtime/airtime.conf')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print ('Error loading config file: %s', e)
|
print('Error loading config file: %s', e)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# TODO : add docstrings everywhere in this module
|
# TODO : add docstrings everywhere in this module
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
import telnetlib
|
import telnetlib
|
||||||
from timeout import ls_timeout
|
from timeout import ls_timeout
|
||||||
|
|
||||||
|
@ -302,7 +303,7 @@ class DummyTelnetLiquidsoap:
|
||||||
|
|
||||||
self.logger.info("Pushing %s to queue %s" % (media_item, queue_id))
|
self.logger.info("Pushing %s to queue %s" % (media_item, queue_id))
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
print "Time now: %s" % datetime.utcnow()
|
print("Time now: {:s}".format(datetime.utcnow()))
|
||||||
|
|
||||||
annotation = create_liquidsoap_annotation(media_item)
|
annotation = create_liquidsoap_annotation(media_item)
|
||||||
self.liquidsoap_mock_queues[queue_id].append(annotation)
|
self.liquidsoap_mock_queues[queue_id].append(annotation)
|
||||||
|
@ -318,7 +319,7 @@ class DummyTelnetLiquidsoap:
|
||||||
|
|
||||||
self.logger.info("Purging queue %s" % queue_id)
|
self.logger.info("Purging queue %s" % queue_id)
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
print "Time now: %s" % datetime.utcnow()
|
print("Time now: {:s}".format(datetime.utcnow()))
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from pypoliqqueue import PypoLiqQueue
|
from pypoliqqueue import PypoLiqQueue
|
||||||
from telnetliquidsoap import DummyTelnetLiquidsoap, TelnetLiquidsoap
|
from telnetliquidsoap import DummyTelnetLiquidsoap, TelnetLiquidsoap
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ plq.daemon = True
|
||||||
plq.start()
|
plq.start()
|
||||||
|
|
||||||
|
|
||||||
print "Time now: %s" % datetime.utcnow()
|
print("Time now: {:s}".format(datetime.utcnow()))
|
||||||
|
|
||||||
media_schedule = {}
|
media_schedule = {}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
from __future__ import print_function
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
print script_path
|
print(script_path)
|
||||||
os.chdir(script_path)
|
os.chdir(script_path)
|
||||||
|
|
||||||
# Allows us to avoid installing the upstart init script when deploying on Airtime Pro:
|
# Allows us to avoid installing the upstart init script when deploying on Airtime Pro:
|
||||||
|
@ -29,7 +30,7 @@ else:
|
||||||
('/var/tmp/airtime/pypo/files', []),
|
('/var/tmp/airtime/pypo/files', []),
|
||||||
('/var/tmp/airtime/pypo/tmp', []),
|
('/var/tmp/airtime/pypo/tmp', []),
|
||||||
]
|
]
|
||||||
print data_files
|
print(data_files)
|
||||||
|
|
||||||
setup(name='airtime-playout',
|
setup(name='airtime-playout',
|
||||||
version='1.0',
|
version='1.0',
|
||||||
|
@ -67,6 +68,6 @@ setup(name='airtime-playout',
|
||||||
|
|
||||||
# Reload the initctl config so that playout services works
|
# Reload the initctl config so that playout services works
|
||||||
if data_files:
|
if data_files:
|
||||||
print "Reloading initctl configuration"
|
print("Reloading initctl configuration")
|
||||||
#call(['initctl', 'reload-configuration'])
|
#call(['initctl', 'reload-configuration'])
|
||||||
print "Run \"sudo service airtime-playout start\" and \"sudo service airtime-liquidsoap start\""
|
print("Run \"sudo service airtime-playout start\" and \"sudo service airtime-liquidsoap start\"")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue