Merge saas-dev into soundcloud
This commit is contained in:
commit
459f9494c3
373 changed files with 6577 additions and 10376 deletions
|
@ -1,12 +0,0 @@
|
|||
bin_dir = "/usr/lib/airtime/api_clients"
|
||||
|
||||
# Value needed to access the API
|
||||
api_key = 'AAA'
|
||||
|
||||
# Path to the base of the API
|
||||
api_base = 'api'
|
||||
|
||||
# Hostname
|
||||
host = 'localhost'
|
||||
base_port = 80
|
||||
base_dir = '/'
|
|
@ -83,6 +83,8 @@ api_config['push_stream_stats'] = 'push-stream-stats/api_key/%%api_key%%/format/
|
|||
api_config['update_stream_setting_table'] = 'update-stream-setting-table/api_key/%%api_key%%/format/json'
|
||||
api_config['get_files_without_silan_value'] = 'get-files-without-silan-value/api_key/%%api_key%%'
|
||||
api_config['update_cue_values_by_silan'] = 'update-cue-values-by-silan/api_key/%%api_key%%'
|
||||
api_config['api_base'] = 'api'
|
||||
api_config['bin_dir'] = '/usr/lib/airtime/api_clients/'
|
||||
api_config['update_metadata_on_tunein'] = 'update-metadata-on-tunein/api_key/%%api_key%%'
|
||||
|
||||
|
||||
|
@ -182,17 +184,17 @@ class RequestProvider(object):
|
|||
def __init__(self, cfg):
|
||||
self.config = cfg
|
||||
self.requests = {}
|
||||
if self.config["base_dir"].startswith("/"):
|
||||
self.config["base_dir"] = self.config["base_dir"][1:]
|
||||
if self.config["general"]["base_dir"].startswith("/"):
|
||||
self.config["general"]["base_dir"] = self.config["general"]["base_dir"][1:]
|
||||
self.url = ApcUrl("http://%s:%s/%s%s/%s" \
|
||||
% (self.config["host"], str(self.config["base_port"]),
|
||||
self.config["base_dir"], self.config["api_base"],
|
||||
% (self.config["general"]["base_url"], str(self.config["general"]["base_port"]),
|
||||
self.config["general"]["base_dir"], self.config["api_base"],
|
||||
'%%action%%'))
|
||||
# Now we must discover the possible actions
|
||||
actions = dict( (k,v) for k,v in cfg.iteritems() if '%%api_key%%' in v)
|
||||
for action_name, action_value in actions.iteritems():
|
||||
new_url = self.url.params(action=action_value).params(
|
||||
api_key=self.config['api_key'])
|
||||
api_key=self.config["general"]['api_key'])
|
||||
self.requests[action_name] = ApiRequest(action_name, new_url)
|
||||
|
||||
def available_requests(self) : return self.requests.keys()
|
||||
|
@ -204,7 +206,7 @@ class RequestProvider(object):
|
|||
|
||||
|
||||
class AirtimeApiClient(object):
|
||||
def __init__(self, logger=None,config_path='/etc/airtime/api_client.cfg'):
|
||||
def __init__(self, logger=None,config_path='/etc/airtime/airtime.conf'):
|
||||
if logger is None: self.logger = logging
|
||||
else: self.logger = logger
|
||||
|
||||
|
@ -319,13 +321,13 @@ class AirtimeApiClient(object):
|
|||
def construct_url(self,config_action_key):
|
||||
"""Constructs the base url for every request"""
|
||||
# TODO : Make other methods in this class use this this method.
|
||||
if self.config["base_dir"].startswith("/"):
|
||||
self.config["base_dir"] = self.config["base_dir"][1:]
|
||||
if self.config["general"]["base_dir"].startswith("/"):
|
||||
self.config["general"]["base_dir"] = self.config["general"]["base_dir"][1:]
|
||||
url = "http://%s:%s/%s%s/%s" % \
|
||||
(self.config["host"], str(self.config["base_port"]),
|
||||
self.config["base_dir"], self.config["api_base"],
|
||||
(self.config["general"]["base_url"], str(self.config["general"]["base_port"]),
|
||||
self.config["general"]["base_dir"], self.config["api_base"],
|
||||
self.config[config_action_key])
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
url = url.replace("%%api_key%%", self.config["general"]["api_key"])
|
||||
return url
|
||||
|
||||
"""
|
|
@ -1,31 +0,0 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from configobj import ConfigObj
|
||||
|
||||
def get_current_script_dir():
|
||||
return os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
def copy_dir(src_dir, dest_dir):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
shutil.rmtree(dest_dir)
|
||||
if not (os.path.exists(dest_dir)):
|
||||
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||
shutil.copytree(src_dir, dest_dir)
|
||||
|
||||
PATH_INI_FILE = '/etc/airtime/api_client.cfg'
|
||||
|
||||
current_script_dir = get_current_script_dir()
|
||||
|
||||
if not os.path.exists(PATH_INI_FILE):
|
||||
shutil.copy('%s/../api_client.cfg'%current_script_dir, PATH_INI_FILE)
|
||||
|
||||
"""load config file"""
|
||||
try:
|
||||
config = ConfigObj("%s/../api_client.cfg" % current_script_dir)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
#copy python files
|
||||
copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"])
|
|
@ -1,21 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
from configobj import ConfigObj
|
||||
|
||||
def remove_path(path):
|
||||
os.system('rm -rf "%s"' % path)
|
||||
|
||||
def get_current_script_dir():
|
||||
return os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
current_script_dir = get_current_script_dir()
|
||||
|
||||
"""load config file"""
|
||||
try:
|
||||
config = ConfigObj("%s/../api_client.cfg" % current_script_dir)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
print " * Removing API Client files"
|
||||
remove_path(config["bin_dir"])
|
33
python_apps/api_clients/setup.py
Normal file
33
python_apps/api_clients/setup.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from setuptools import setup
|
||||
from subprocess import call
|
||||
import sys
|
||||
import os
|
||||
|
||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||
print script_path
|
||||
os.chdir(script_path)
|
||||
|
||||
setup(name='api_clients',
|
||||
version='1.0',
|
||||
description='Airtime API Client',
|
||||
url='http://github.com/sourcefabric/Airtime',
|
||||
author='sourcefabric',
|
||||
license='AGPLv3',
|
||||
packages=['api_clients'],
|
||||
scripts=[],
|
||||
install_requires=[
|
||||
# 'amqplib',
|
||||
# 'anyjson',
|
||||
# 'argparse',
|
||||
'configobj'
|
||||
# 'docopt',
|
||||
# 'kombu',
|
||||
# 'mutagen',
|
||||
# 'poster',
|
||||
# 'PyDispatcher',
|
||||
# 'pyinotify',
|
||||
# 'pytz',
|
||||
# 'wsgiref'
|
||||
],
|
||||
zip_safe=False,
|
||||
data_files=[])
|
|
@ -1,32 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
|
||||
def create_user(username):
|
||||
print "* Checking for user "+username
|
||||
|
||||
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
output = p.stdout.read()
|
||||
|
||||
if (output[0:3] != "uid"):
|
||||
# Make the pypo user
|
||||
print " * Creating user "+username
|
||||
os.system("adduser --system --quiet --group "+username)
|
||||
else:
|
||||
print "User already exists."
|
||||
#add pypo to audio group
|
||||
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
|
||||
#add pypo to www-data group
|
||||
os.system("adduser " + username + " www-data 1>/dev/null 2>&1")
|
||||
#add pypo to pulse group
|
||||
os.system("adduser " + username + " pulse 1>/dev/null 2>&1")
|
||||
#add pypo to pulse-access group
|
||||
os.system("adduser " + username + " pulse-access 1>/dev/null 2>&1")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
sys.exit(1)
|
||||
|
||||
create_user("pypo")
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Location of pypo_cli.py Python script
|
||||
|
||||
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
|
||||
. ${virtualenv_bin}activate
|
||||
|
||||
media_monitor_path="/usr/lib/airtime/media-monitor/"
|
||||
media_monitor_script="media_monitor.py"
|
||||
|
||||
api_client_path="/usr/lib/airtime/:/usr/lib/airtime/media-monitor/mm2/"
|
||||
|
||||
cd ${media_monitor_path}
|
||||
|
||||
exec 2>&1
|
||||
|
||||
set +e
|
||||
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
|
||||
set -e
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/media-monitor/error.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PYTHONPATH=${api_client_path}
|
||||
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
|
||||
|
||||
exec python ${media_monitor_path}${media_monitor_script} > /var/log/airtime/media-monitor/py-interpreter.log 2>&1
|
||||
|
||||
# EOF
|
17
python_apps/media-monitor/bin/airtime-media-monitor
Executable file
17
python_apps/media-monitor/bin/airtime-media-monitor
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/python
|
||||
import logging
|
||||
import locale
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import mm2.mm2 as mm2
|
||||
from std_err_override import LogWriter
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
def run():
|
||||
global_cfg = '/etc/airtime/airtime.conf'
|
||||
logging_cfg = '/etc/airtime/media_monitor_logging.cfg'
|
||||
|
||||
mm2.main( global_cfg, logging_cfg )
|
||||
|
||||
run()
|
|
@ -1,70 +0,0 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
import random
|
||||
import string
|
||||
from configobj import ConfigObj
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
sys.exit(1)
|
||||
|
||||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
return current_script_dir[0:index]
|
||||
|
||||
def copy_dir(src_dir, dest_dir):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
shutil.rmtree(dest_dir)
|
||||
if not (os.path.exists(dest_dir)):
|
||||
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||
shutil.copytree(src_dir, dest_dir)
|
||||
|
||||
def create_dir(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
# TODO : fix this, at least print the error
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
def get_rand_string(length=10):
|
||||
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
||||
|
||||
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
|
||||
|
||||
try:
|
||||
# Absolute path this script is in
|
||||
current_script_dir = get_current_script_dir()
|
||||
|
||||
if not os.path.exists(PATH_INI_FILE):
|
||||
shutil.copy('%s/../media-monitor.cfg'%current_script_dir, PATH_INI_FILE)
|
||||
|
||||
# load config file
|
||||
try:
|
||||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
#copy monit files
|
||||
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True)
|
||||
shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||
|
||||
#create log dir
|
||||
create_dir(config['log_dir'])
|
||||
|
||||
#copy python files
|
||||
copy_dir("%s/.."%current_script_dir, config["bin_dir"])
|
||||
# mm2
|
||||
mm2_source = os.path.realpath(os.path.join(current_script_dir,
|
||||
"../../media-monitor2"))
|
||||
copy_dir(mm2_source, os.path.join( config["bin_dir"], "mm2" ))
|
||||
|
||||
#copy init.d script
|
||||
shutil.copy(config["bin_dir"]+"/airtime-media-monitor-init-d", "/etc/init.d/airtime-media-monitor")
|
||||
|
||||
except Exception, e:
|
||||
print e
|
|
@ -1,21 +0,0 @@
|
|||
import subprocess
|
||||
import os
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
#create media-monitor dir under /var/tmp/airtime
|
||||
if not os.path.exists("/var/tmp/airtime/media-monitor"):
|
||||
os.makedirs("/var/tmp/airtime/media-monitor")
|
||||
|
||||
#update-rc.d init script
|
||||
subprocess.call("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
|
||||
|
||||
#Start media-monitor daemon
|
||||
if "airtime_service_start" in os.environ and os.environ["airtime_service_start"] == "t":
|
||||
print "* Waiting for media-monitor processes to start..."
|
||||
subprocess.call("invoke-rc.d airtime-media-monitor start", shell=True)
|
||||
except Exception, e:
|
||||
print e
|
|
@ -1,44 +0,0 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from configobj import ConfigObj
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
sys.exit(1)
|
||||
|
||||
def remove_file(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
|
||||
|
||||
# load config file
|
||||
try:
|
||||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
#remove init.d script
|
||||
print " * Removing Media-Monitor init.d Script"
|
||||
remove_file("/etc/init.d/airtime-media-monitor")
|
||||
|
||||
#remove bin dir
|
||||
print " * Removing Media-Monitor Program Directory"
|
||||
shutil.rmtree(config['bin_dir'], ignore_errors=True)
|
||||
|
||||
#remove log dir
|
||||
print " * Removing Media-Monitor Log Directory"
|
||||
shutil.rmtree(config['log_dir'], ignore_errors=True)
|
||||
|
||||
#remove monit files
|
||||
print " * Removing Media-Monitor Monit Files"
|
||||
remove_file("/etc/monit/conf.d/monit-airtime-media-monitor.cfg")
|
||||
remove_file("/etc/monit/conf.d/monit-airtime-generic.cfg")
|
||||
|
||||
except Exception, e:
|
||||
print e
|
|
@ -1,19 +0,0 @@
|
|||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
print "Waiting for media-monitor processes to stop...",
|
||||
if (os.path.exists('/etc/init.d/airtime-media-monitor')):
|
||||
subprocess.call("invoke-rc.d airtime-media-monitor stop", shell=True)
|
||||
print "OK"
|
||||
else:
|
||||
print "Wasn't running"
|
||||
|
||||
subprocess.call("update-rc.d -f airtime-media-monitor remove".split(" "))
|
||||
except Exception, e:
|
||||
print e
|
|
@ -1,50 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
from configobj import ConfigObj
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
sys.exit(1)
|
||||
|
||||
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
|
||||
|
||||
def remove_path(path):
|
||||
os.system('rm -rf "%s"' % path)
|
||||
|
||||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
return current_script_dir[0:index]
|
||||
|
||||
def remove_monit_file():
|
||||
os.system("rm -f /etc/monit/conf.d/monit-airtime-media-monitor.cfg")
|
||||
|
||||
try:
|
||||
# load config file
|
||||
try:
|
||||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
os.system("invoke-rc.d airtime-media-monitor stop")
|
||||
os.system("rm -f /etc/init.d/airtime-media-monitor")
|
||||
os.system("update-rc.d -f airtime-media-monitor remove >/dev/null 2>&1")
|
||||
|
||||
print "Removing monit file"
|
||||
remove_monit_file()
|
||||
|
||||
print "Removing log directories"
|
||||
remove_path(config["log_dir"])
|
||||
|
||||
print "Removing symlinks"
|
||||
os.system("rm -f /usr/bin/airtime-media-monitor")
|
||||
|
||||
print "Removing application files"
|
||||
remove_path(config["bin_dir"])
|
||||
|
||||
print "Uninstall complete."
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
|
@ -9,12 +9,26 @@
|
|||
# Short-Description: Manage airtime-media-monitor daemon
|
||||
### END INIT INFO
|
||||
|
||||
USERID=root
|
||||
USERID=www-data
|
||||
GROUPID=www-data
|
||||
NAME=Airtime\ Media\ Monitor
|
||||
NAME=airtime-media-monitor
|
||||
|
||||
DAEMON=/usr/lib/airtime/media-monitor/airtime-media-monitor
|
||||
PIDFILE=/var/run/airtime-media-monitor.pid
|
||||
DAEMON=/usr/bin/$NAME
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
start () {
|
||||
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
|
||||
|
@ -27,17 +41,6 @@ stop () {
|
|||
rm -f $PIDFILE
|
||||
}
|
||||
|
||||
start_with_monit() {
|
||||
start
|
||||
monit monitor airtime-media-monitor >/dev/null 2>&1
|
||||
}
|
||||
|
||||
stop_with_monit() {
|
||||
monit unmonitor airtime-media-monitor >/dev/null 2>&1
|
||||
stop
|
||||
}
|
||||
|
||||
|
||||
case "${1:-''}" in
|
||||
'start')
|
||||
# start commands here
|
||||
|
@ -58,21 +61,15 @@ case "${1:-''}" in
|
|||
start
|
||||
echo "Done."
|
||||
;;
|
||||
'start-with-monit')
|
||||
# restart commands here
|
||||
echo -n "Starting $NAME: "
|
||||
start_with_monit
|
||||
echo "Done."
|
||||
;;
|
||||
'stop-with-monit')
|
||||
# restart commands here
|
||||
echo -n "Stopping $NAME: "
|
||||
stop_with_monit
|
||||
'force-reload')
|
||||
# reload commands here
|
||||
echo -n "Reloading $NAME: "
|
||||
stop
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
'status')
|
||||
# status commands here
|
||||
/usr/bin/airtime-check-system
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
*) # no parameter specified
|
||||
echo "Usage: $SELF start|stop|restart|status"
|
|
@ -0,0 +1,15 @@
|
|||
description "Airtime Media Monitor"
|
||||
author "help@sourcefabric.org"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [!2345]
|
||||
|
||||
respawn
|
||||
|
||||
setuid WEB_USER
|
||||
setgid WEB_USER
|
||||
|
||||
env LANG='en_US.UTF-8'
|
||||
env LC_ALL='en_US.UTF-8'
|
||||
|
||||
exec airtime-media-monitor
|
|
@ -1,31 +0,0 @@
|
|||
api_client = "airtime"
|
||||
|
||||
# where the binary files live
|
||||
bin_dir = '/usr/lib/airtime/media-monitor'
|
||||
|
||||
# where the logging files live
|
||||
log_dir = '/var/log/airtime/media-monitor'
|
||||
|
||||
|
||||
############################################
|
||||
# RabbitMQ settings #
|
||||
############################################
|
||||
rabbitmq_host = 'localhost'
|
||||
rabbitmq_user = 'guest'
|
||||
rabbitmq_password = 'guest'
|
||||
rabbitmq_vhost = '/'
|
||||
|
||||
############################################
|
||||
# Media-Monitor preferences #
|
||||
############################################
|
||||
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
|
||||
check_airtime_events = 30 #how long to queue metadata input from airtime.
|
||||
|
||||
# MM2 only:
|
||||
touch_interval = 5
|
||||
chunking_number = 450
|
||||
request_max_wait = 3.0
|
||||
rmq_event_wait = 0.1
|
||||
logpath = '/var/log/airtime/media-monitor/media-monitor.log'
|
||||
index_path = '/var/tmp/airtime/media-monitor/last_index'
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import logging
|
||||
import time
|
||||
import sys
|
||||
import mm2.mm2 as mm2
|
||||
from std_err_override import LogWriter
|
||||
|
||||
global_cfg = '/etc/airtime/media-monitor.cfg'
|
||||
api_client_cfg = '/etc/airtime/api_client.cfg'
|
||||
logging_cfg = '/usr/lib/airtime/media-monitor/logging.cfg'
|
||||
|
||||
mm2.main( global_cfg, api_client_cfg, logging_cfg )
|
16
python_apps/media-monitor/media_monitor/__main__.py
Normal file
16
python_apps/media-monitor/media_monitor/__main__.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import logging
|
||||
import locale
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import mm2.mm2 as mm2
|
||||
from std_err_override import LogWriter
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
def run():
|
||||
global_cfg = '/etc/airtime/airtime.conf'
|
||||
logging_cfg = os.path.join(os.path.dirname(__file__), 'logging.cfg')
|
||||
|
||||
mm2.main( global_cfg, logging_cfg )
|
||||
|
||||
run()
|
|
@ -45,7 +45,7 @@ class AirtimeNotifier(Notifier):
|
|||
try:
|
||||
schedule_exchange = Exchange("airtime-media-monitor", "direct", durable=True, auto_delete=True)
|
||||
schedule_queue = Queue("media-monitor", exchange=schedule_exchange, key="filesystem")
|
||||
self.connection = BrokerConnection(self.config.cfg["rabbitmq_host"], self.config.cfg["rabbitmq_user"], self.config.cfg["rabbitmq_password"], self.config.cfg["rabbitmq_vhost"])
|
||||
self.connection = BrokerConnection(self.config.cfg["rabbitmq"]["rabbitmq_host"], self.config.cfg["rabbitmq"]["rabbitmq_user"], self.config.cfg["rabbitmq"]["rabbitmq_password"], self.config.cfg["rabbitmq"]["rabbitmq_vhost"])
|
||||
channel = self.connection.channel()
|
||||
consumer = Consumer(channel, schedule_queue)
|
||||
consumer.register_callback(self.handle_message)
|
|
@ -16,7 +16,7 @@ class AirtimeMediaConfig:
|
|||
|
||||
# loading config file
|
||||
try:
|
||||
config = ConfigObj('/etc/airtime/media-monitor.cfg')
|
||||
config = ConfigObj('/etc/airtime/airtime.conf')
|
||||
self.cfg = config
|
||||
except Exception, e:
|
||||
logger.info('Error loading config: ', e)
|
|
@ -61,7 +61,7 @@ def configure_locale():
|
|||
|
||||
# configure logging
|
||||
try:
|
||||
logging.config.fileConfig("logging.cfg")
|
||||
logging.config.fileConfig("%s/logging.cfg" % os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
#need to wait for Python 2.7 for this..
|
||||
#logging.captureWarnings(True)
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import media.metadata.process as md
|
||||
import process as md
|
||||
import re
|
||||
from os.path import normpath
|
||||
from media.monitor.pure import format_length, file_md5, is_airtime_recorded, \
|
||||
from ..monitor.pure import format_length, file_md5, is_airtime_recorded, \
|
||||
no_extension_basename
|
||||
|
||||
defs_loaded = False
|
|
@ -1,11 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from contextlib import contextmanager
|
||||
from media.monitor.pure import truncate_to_value, truncate_to_length, toposort
|
||||
from os.path import normpath
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.log import Loggable
|
||||
import media.monitor.pure as mmp
|
||||
from collections import namedtuple
|
||||
from contextlib import contextmanager
|
||||
from ..monitor.pure import truncate_to_value, truncate_to_length, toposort
|
||||
from os.path import normpath
|
||||
from ..monitor.exceptions import BadSongFile
|
||||
from ..monitor.log import Loggable
|
||||
from ..monitor import pure as mmp
|
||||
from collections import namedtuple
|
||||
import mutagen
|
||||
import subprocess
|
||||
import json
|
|
@ -1,22 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from kombu.messaging import Exchange, Queue, Consumer
|
||||
from kombu.connection import BrokerConnection
|
||||
from kombu.simple import SimpleQueue
|
||||
from os.path import normpath
|
||||
from kombu.messaging import Exchange, Queue, Consumer
|
||||
from kombu.connection import BrokerConnection
|
||||
from kombu.simple import SimpleQueue
|
||||
from os.path import normpath
|
||||
|
||||
import json
|
||||
import os
|
||||
import copy
|
||||
import time
|
||||
|
||||
from media.monitor.exceptions import BadSongFile, InvalidMetadataElement
|
||||
from media.monitor.metadata import Metadata
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.syncdb import AirtimeDB
|
||||
from media.monitor.exceptions import DirectoryIsNotListed
|
||||
from media.monitor.bootstrap import Bootstrapper
|
||||
from exceptions import BadSongFile, InvalidMetadataElement, DirectoryIsNotListed
|
||||
from metadata import Metadata
|
||||
from log import Loggable
|
||||
from syncdb import AirtimeDB
|
||||
from bootstrap import Bootstrapper
|
||||
|
||||
from media.saas.thread import apc, user
|
||||
from ..saas.thread import apc, user
|
||||
|
||||
class AirtimeNotifier(Loggable):
|
||||
"""
|
||||
|
@ -38,9 +37,9 @@ class AirtimeNotifier(Loggable):
|
|||
durable=True, auto_delete=True)
|
||||
schedule_queue = Queue("media-monitor", exchange=schedule_exchange,
|
||||
key="filesystem")
|
||||
self.connection = BrokerConnection(self.cfg["rabbitmq_host"],
|
||||
self.cfg["rabbitmq_user"], self.cfg["rabbitmq_password"],
|
||||
self.cfg["rabbitmq_vhost"])
|
||||
self.connection = BrokerConnection(self.cfg["rabbitmq"]["host"],
|
||||
self.cfg["rabbitmq"]["user"], self.cfg["rabbitmq"]["password"],
|
||||
self.cfg["rabbitmq"]["vhost"])
|
||||
channel = self.connection.channel()
|
||||
|
||||
self.simple_queue = SimpleQueue(channel, schedule_queue)
|
|
@ -1,9 +1,9 @@
|
|||
import os
|
||||
from pydispatch import dispatcher
|
||||
from media.monitor.events import NewFile, DeleteFile, ModifyFile
|
||||
from media.monitor.log import Loggable
|
||||
from media.saas.thread import getsig
|
||||
import media.monitor.pure as mmp
|
||||
from pydispatch import dispatcher
|
||||
from events import NewFile, DeleteFile, ModifyFile
|
||||
from log import Loggable
|
||||
from ..saas.thread import getsig
|
||||
import pure as mmp
|
||||
|
||||
class Bootstrapper(Loggable):
|
||||
"""
|
|
@ -3,8 +3,8 @@ import os
|
|||
import copy
|
||||
from configobj import ConfigObj
|
||||
|
||||
from media.monitor.exceptions import NoConfigFile, ConfigAccessViolation
|
||||
import media.monitor.pure as mmp
|
||||
from exceptions import NoConfigFile, ConfigAccessViolation
|
||||
import pure as mmp
|
||||
|
||||
class MMConfig(object):
|
||||
def __init__(self, path):
|
||||
|
@ -28,5 +28,5 @@ class MMConfig(object):
|
|||
def last_ran(self):
|
||||
""" Returns the last time media monitor was ran by looking at
|
||||
the time when the file at 'index_path' was modified """
|
||||
return mmp.last_modified(self.cfg['index_path'])
|
||||
return mmp.last_modified(self.cfg['media-monitor']['index_path'])
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from media.monitor.log import Loggable
|
||||
from media.monitor.events import DeleteFile
|
||||
from log import Loggable
|
||||
from events import DeleteFile
|
||||
|
||||
class EventContractor(Loggable):
|
||||
def __init__(self):
|
|
@ -1,7 +1,7 @@
|
|||
import socket
|
||||
import time
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.toucher import RepeatTimer
|
||||
from log import Loggable
|
||||
from toucher import RepeatTimer
|
||||
from amqplib.client_0_8.exceptions import AMQPConnectionException
|
||||
|
||||
class EventDrainer(Loggable):
|
|
@ -2,12 +2,12 @@
|
|||
import os
|
||||
import abc
|
||||
import re
|
||||
import media.monitor.pure as mmp
|
||||
from media.monitor.pure import LazyProperty
|
||||
from media.monitor.metadata import Metadata
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.saas.thread import getsig, user
|
||||
import pure as mmp
|
||||
from pure import LazyProperty
|
||||
from metadata import Metadata
|
||||
from log import Loggable
|
||||
from exceptions import BadSongFile
|
||||
from ..saas.thread import getsig, user
|
||||
|
||||
class PathChannel(object):
|
||||
""" Simple struct to hold a 'signal' string and a related 'path'.
|
|
@ -2,9 +2,9 @@
|
|||
from pydispatch import dispatcher
|
||||
import abc
|
||||
|
||||
from media.monitor.log import Loggable
|
||||
from media.saas.thread import getsig
|
||||
import media.monitor.pure as mmp
|
||||
from log import Loggable
|
||||
from ..saas.thread import getsig
|
||||
import pure as mmp
|
||||
|
||||
# Defines the handle interface
|
||||
class Handles(object):
|
|
@ -3,13 +3,13 @@ import pyinotify
|
|||
from pydispatch import dispatcher
|
||||
from functools import wraps
|
||||
|
||||
import media.monitor.pure as mmp
|
||||
from media.monitor.pure import IncludeOnly
|
||||
from media.monitor.events import OrganizeFile, NewFile, MoveFile, DeleteFile, \
|
||||
import pure as mmp
|
||||
from pure import IncludeOnly
|
||||
from events import OrganizeFile, NewFile, MoveFile, DeleteFile, \
|
||||
DeleteDir, MoveDir,\
|
||||
DeleteDirWatch
|
||||
from media.monitor.log import Loggable
|
||||
from media.saas.thread import getsig, user
|
||||
from log import Loggable
|
||||
from ..saas.thread import getsig, user
|
||||
# Note: Because of the way classes that inherit from pyinotify.ProcessEvent
|
||||
# interact with constructors. you should only instantiate objects from them
|
||||
# using keyword arguments. For example:
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import abc
|
||||
import traceback
|
||||
from media.monitor.pure import LazyProperty
|
||||
from pure import LazyProperty
|
||||
|
||||
appname = 'root'
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
import pyinotify
|
||||
import time
|
||||
import os
|
||||
from pydispatch import dispatcher
|
||||
from pydispatch import dispatcher
|
||||
|
||||
from os.path import normpath
|
||||
from media.monitor.events import PathChannel
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.listeners import StoreWatchListener, OrganizeListener
|
||||
from media.monitor.handler import ProblemFileHandler
|
||||
from media.monitor.organizer import Organizer
|
||||
from media.saas.thread import InstanceInheritingThread, getsig
|
||||
import media.monitor.pure as mmp
|
||||
from os.path import normpath
|
||||
from events import PathChannel
|
||||
from log import Loggable
|
||||
from listeners import StoreWatchListener, OrganizeListener
|
||||
from handler import ProblemFileHandler
|
||||
from organizer import Organizer
|
||||
from ..saas.thread import InstanceInheritingThread, getsig
|
||||
import pure as mmp
|
||||
|
||||
|
||||
class ManagerTimeout(InstanceInheritingThread,Loggable):
|
|
@ -2,17 +2,17 @@
|
|||
import mutagen
|
||||
import os
|
||||
import copy
|
||||
from mutagen.easymp4 import EasyMP4KeyError
|
||||
from mutagen.easyid3 import EasyID3KeyError
|
||||
from mutagen.easymp4 import EasyMP4KeyError
|
||||
from mutagen.easyid3 import EasyID3KeyError
|
||||
|
||||
from media.monitor.exceptions import BadSongFile, InvalidMetadataElement
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.pure import format_length
|
||||
import media.monitor.pure as mmp
|
||||
from exceptions import BadSongFile, InvalidMetadataElement
|
||||
from log import Loggable
|
||||
from pure import format_length
|
||||
import pure as mmp
|
||||
|
||||
# emf related stuff
|
||||
from media.metadata.process import global_reader
|
||||
import media.metadata.definitions as defs
|
||||
from ..metadata.process import global_reader
|
||||
from ..metadata import definitions as defs
|
||||
defs.load_definitions()
|
||||
|
||||
"""
|
|
@ -1,12 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import media.monitor.pure as mmp
|
||||
from media.monitor.handler import ReportHandler
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.events import OrganizeFile
|
||||
from pydispatch import dispatcher
|
||||
from os.path import dirname
|
||||
from media.saas.thread import getsig, user
|
||||
import pure as mmp
|
||||
from handler import ReportHandler
|
||||
from log import Loggable
|
||||
from exceptions import BadSongFile
|
||||
from events import OrganizeFile
|
||||
from pydispatch import dispatcher
|
||||
from os.path import dirname
|
||||
from ..saas.thread import getsig, user
|
||||
import os.path
|
||||
|
||||
class Organizer(ReportHandler,Loggable):
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from media.monitor.log import Loggable
|
||||
from log import Loggable
|
||||
|
||||
class Owner(Loggable):
|
||||
def __init__(self):
|
|
@ -21,7 +21,7 @@ try: from functools import reduce
|
|||
except: pass
|
||||
from configobj import ConfigObj
|
||||
|
||||
from media.monitor.exceptions import FailedToSetLocale, FailedToCreateDir
|
||||
from exceptions import FailedToSetLocale, FailedToCreateDir
|
||||
|
||||
supported_extensions = [u"mp3", u"ogg", u"oga", u"flac", u"wav",
|
||||
u'm4a', u'mp4', 'opus']
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.log import Loggable
|
||||
from media.saas.thread import apc, InstanceInheritingThread
|
||||
from exceptions import BadSongFile
|
||||
from log import Loggable
|
||||
from ..saas.thread import apc, InstanceInheritingThread
|
||||
|
||||
class ThreadedRequestSync(InstanceInheritingThread, Loggable):
|
||||
def __init__(self, rs):
|
|
@ -1,10 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.exceptions import NoDirectoryInAirtime
|
||||
from media.saas.thread import user
|
||||
from os.path import normpath, join
|
||||
import media.monitor.pure as mmp
|
||||
from log import Loggable
|
||||
from exceptions import NoDirectoryInAirtime
|
||||
from ..saas.thread import user
|
||||
from os.path import normpath, join
|
||||
import pure as mmp
|
||||
|
||||
class AirtimeDB(Loggable):
|
||||
def __init__(self, apc, reload_now=True):
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import media.monitor.pure as mmp
|
||||
import pure as mmp
|
||||
import os
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.exceptions import CouldNotCreateIndexFile
|
||||
from media.saas.thread import InstanceInheritingThread
|
||||
from log import Loggable
|
||||
from exceptions import CouldNotCreateIndexFile
|
||||
from ..saas.thread import InstanceInheritingThread
|
||||
|
||||
class Toucher(Loggable):
|
||||
"""
|
|
@ -2,13 +2,13 @@
|
|||
import time
|
||||
import copy
|
||||
|
||||
from media.monitor.handler import ReportHandler
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.eventcontractor import EventContractor
|
||||
from media.monitor.events import EventProxy
|
||||
from media.monitor.request import ThreadedRequestSync, RequestSync
|
||||
from media.saas.thread import InstanceInheritingThread, getsig
|
||||
from handler import ReportHandler
|
||||
from log import Loggable
|
||||
from exceptions import BadSongFile
|
||||
from eventcontractor import EventContractor
|
||||
from events import EventProxy
|
||||
from request import ThreadedRequestSync, RequestSync
|
||||
from ..saas.thread import InstanceInheritingThread, getsig
|
||||
|
||||
class TimeoutWatcher(InstanceInheritingThread,Loggable):
|
||||
"""
|
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
from os.path import join, basename, dirname
|
||||
|
||||
from media.monitor.exceptions import NoConfigFile
|
||||
from media.monitor.pure import LazyProperty
|
||||
from media.monitor.config import MMConfig
|
||||
from media.monitor.owners import Owner
|
||||
from media.monitor.events import EventRegistry
|
||||
from media.monitor.listeners import FileMediator
|
||||
from ..monitor.exceptions import NoConfigFile
|
||||
from ..monitor.pure import LazyProperty
|
||||
from ..monitor.config import MMConfig
|
||||
from ..monitor.owners import Owner
|
||||
from ..monitor.events import EventRegistry
|
||||
from ..monitor.listeners import FileMediator
|
||||
from api_clients.api_client import AirtimeApiClient
|
||||
|
||||
# poor man's phantom types...
|
||||
|
@ -21,7 +21,7 @@ class AirtimeInstance(object):
|
|||
def root_make(cls, name, root):
|
||||
cfg = {
|
||||
'api_client' : join(root, 'etc/airtime/api_client.cfg'),
|
||||
'media_monitor' : join(root, 'etc/airtime/media-monitor.cfg'),
|
||||
'media_monitor' : join(root, 'etc/airtime/airtime.conf'),
|
||||
}
|
||||
return cls(name, root, cfg)
|
||||
|
||||
|
@ -41,7 +41,7 @@ class AirtimeInstance(object):
|
|||
|
||||
def touch_file_path(self):
|
||||
""" Get the path of the touch file for every instance """
|
||||
touch_base_path = self.mm_config['index_path']
|
||||
touch_base_path = self.mm_config['media-monitor']['index_path']
|
||||
touch_base_name = basename(touch_base_path)
|
||||
new_base_name = self.name + touch_base_name
|
||||
return join(dirname(touch_base_path), new_base_name)
|
|
@ -2,31 +2,31 @@ import os, sys
|
|||
import logging
|
||||
import logging.config
|
||||
|
||||
import media.monitor.pure as mmp
|
||||
from ..monitor import pure as mmp
|
||||
|
||||
from media.monitor.exceptions import FailedToObtainLocale, FailedToSetLocale
|
||||
from media.monitor.log import get_logger, setup_logging
|
||||
from ..monitor.exceptions import FailedToObtainLocale, FailedToSetLocale
|
||||
from ..monitor.log import get_logger, setup_logging
|
||||
from std_err_override import LogWriter
|
||||
from media.saas.thread import InstanceThread, user, apc, getsig
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.exceptions import CouldNotCreateIndexFile
|
||||
from media.monitor.toucher import ToucherThread
|
||||
from media.monitor.airtime import AirtimeNotifier, AirtimeMessageReceiver
|
||||
from media.monitor.watchersyncer import WatchSyncer
|
||||
from media.monitor.eventdrainer import EventDrainer
|
||||
from media.monitor.manager import Manager
|
||||
from media.monitor.syncdb import AirtimeDB
|
||||
from media.saas.airtimeinstance import AirtimeInstance
|
||||
from ..saas.thread import InstanceThread, user, apc, getsig
|
||||
from ..monitor.log import Loggable
|
||||
from ..monitor.exceptions import CouldNotCreateIndexFile
|
||||
from ..monitor.toucher import ToucherThread
|
||||
from ..monitor.airtime import AirtimeNotifier, AirtimeMessageReceiver
|
||||
from ..monitor.watchersyncer import WatchSyncer
|
||||
from ..monitor.eventdrainer import EventDrainer
|
||||
from ..monitor.manager import Manager
|
||||
from ..monitor.syncdb import AirtimeDB
|
||||
from airtimeinstance import AirtimeInstance
|
||||
|
||||
class MM2(InstanceThread, Loggable):
|
||||
|
||||
def index_create(self, index_create_attempt=False):
|
||||
config = user().mm_config
|
||||
if not index_create_attempt:
|
||||
if not os.path.exists(config['index_path']):
|
||||
if not os.path.exists(config['media-monitor']['index_path']):
|
||||
self.logger.info("Attempting to create index file:...")
|
||||
try:
|
||||
with open(config['index_path'], 'w') as f: f.write(" ")
|
||||
with open(config['media-monitor']['index_path'], 'w') as f: f.write(" ")
|
||||
except Exception as e:
|
||||
self.logger.info("Failed to create index file with exception: %s" \
|
||||
% str(e))
|
||||
|
@ -36,8 +36,8 @@ class MM2(InstanceThread, Loggable):
|
|||
else:
|
||||
self.logger.info("Already tried to create index. Will not try again ")
|
||||
|
||||
if not os.path.exists(config['index_path']):
|
||||
raise CouldNotCreateIndexFile(config['index_path'])
|
||||
if not os.path.exists(config['media-monitor']['index_path']):
|
||||
raise CouldNotCreateIndexFile(config['media-monitor']['index_path'])
|
||||
|
||||
def run(self):
|
||||
self.index_create()
|
||||
|
@ -45,8 +45,8 @@ class MM2(InstanceThread, Loggable):
|
|||
apiclient = apc()
|
||||
config = user().mm_config
|
||||
WatchSyncer(signal=getsig('watch'),
|
||||
chunking_number=config['chunking_number'],
|
||||
timeout=config['request_max_wait'])
|
||||
chunking_number=config['media-monitor']['chunking_number'],
|
||||
timeout=config['media-monitor']['request_max_wait'])
|
||||
airtime_receiver = AirtimeMessageReceiver(config,manager)
|
||||
airtime_notifier = AirtimeNotifier(config, airtime_receiver)
|
||||
|
||||
|
@ -76,14 +76,14 @@ class MM2(InstanceThread, Loggable):
|
|||
else: self.logger.info("Failed to add watch on %s" % str(watch_dir))
|
||||
|
||||
EventDrainer(airtime_notifier,
|
||||
interval=float(config['rmq_event_wait']))
|
||||
interval=float(config['media-monitor']['rmq_event_wait']))
|
||||
|
||||
# Launch the toucher that updates the last time when the script was
|
||||
# ran every n seconds.
|
||||
# TODO : verify that this does not interfere with bootstrapping because the
|
||||
# toucher thread might update the last_ran variable too fast
|
||||
ToucherThread(path=user().touch_file_path(),
|
||||
interval=int(config['touch_interval']))
|
||||
interval=int(config['media-monitor']['touch_interval']))
|
||||
|
||||
success = False
|
||||
while not success:
|
||||
|
@ -97,9 +97,9 @@ class MM2(InstanceThread, Loggable):
|
|||
|
||||
manager.loop()
|
||||
|
||||
def launch_instance(name, root, global_cfg, apc_cfg):
|
||||
def launch_instance(name, root, global_cfg):
|
||||
cfg = {
|
||||
'api_client' : apc_cfg,
|
||||
'api_client' : global_cfg,
|
||||
'media_monitor' : global_cfg,
|
||||
}
|
||||
ai = AirtimeInstance(name, root, cfg)
|
|
@ -4,12 +4,12 @@ import os
|
|||
from media.saas.launcher import setup_global, launch_instance, setup_logger
|
||||
from media.monitor.config import MMConfig
|
||||
|
||||
def main(global_config, api_client_config, log_config):
|
||||
def main(global_config, log_config):
|
||||
""" function to run hosted install """
|
||||
mm_config = MMConfig(global_config)
|
||||
log = setup_logger( log_config, mm_config['logpath'] )
|
||||
log = setup_logger( log_config, mm_config['media-monitor']['logpath'] )
|
||||
setup_global(log)
|
||||
launch_instance('hosted_install', '/', global_config, api_client_config)
|
||||
launch_instance('hosted_install', '/', global_config)
|
||||
|
||||
__doc__ = """
|
||||
Usage:
|
|
@ -8,7 +8,7 @@ real_path1 = u'/home/rudi/throwaway/watch/unknown/unknown/ACDC_-_Back_In_Black-s
|
|||
opath = u"/home/rudi/Airtime/python_apps/media-monitor2/tests/"
|
||||
ppath = u"/home/rudi/Airtime/python_apps/media-monitor2/media/"
|
||||
|
||||
api_client_path = '/etc/airtime/api_client.cfg'
|
||||
api_client_path = '/etc/airtime/airtime.conf'
|
||||
# holdover from the time we had a special config for testing
|
||||
sample_config = api_client_path
|
||||
real_config = api_client_path
|
|
@ -1,9 +0,0 @@
|
|||
set daemon 10 # Poll at 5 second intervals
|
||||
set logfile /var/log/monit.log
|
||||
|
||||
set httpd port 2812
|
||||
|
||||
check process airtime-media-monitor
|
||||
with pidfile "/var/run/airtime-media-monitor.pid"
|
||||
start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
|
||||
stop program = "/etc/init.d/airtime-media-monitor stop"
|
66
python_apps/media-monitor/setup.py
Normal file
66
python_apps/media-monitor/setup.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
from setuptools import setup
|
||||
from subprocess import call
|
||||
import sys
|
||||
import os
|
||||
|
||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||
print script_path
|
||||
os.chdir(script_path)
|
||||
|
||||
# Allows us to avoid installing the upstart init script when deploying on Airtime Pro:
|
||||
if '--no-init-script' in sys.argv:
|
||||
data_files = []
|
||||
sys.argv.remove('--no-init-script') # super hax
|
||||
else:
|
||||
media_monitor_files = []
|
||||
mm2_files = []
|
||||
for root, dirnames, filenames in os.walk('media-monitor'):
|
||||
for filename in filenames:
|
||||
media_monitor_files.append(os.path.join(root, filename))
|
||||
for root, dirnames, filenames in os.walk('media-monitor2'):
|
||||
for filename in filenames:
|
||||
mm2_files.append(os.path.join(root, filename))
|
||||
|
||||
data_files = [
|
||||
('/etc/init', ['install/upstart/airtime-media-monitor.conf.template']),
|
||||
('/etc/init.d', ['install/sysvinit/airtime-media-monitor']),
|
||||
('/etc/airtime', ['install/media_monitor_logging.cfg']),
|
||||
('/var/log/airtime/media-monitor', []),
|
||||
('/var/tmp/airtime/media-monitor', []),
|
||||
]
|
||||
print data_files
|
||||
|
||||
setup(name='airtime-media-monitor',
|
||||
version='1.0',
|
||||
description='Airtime Media Monitor',
|
||||
url='http://github.com/sourcefabric/Airtime',
|
||||
author='sourcefabric',
|
||||
license='AGPLv3',
|
||||
packages=['media_monitor', 'mm2', 'mm2.configs',
|
||||
'mm2.media', 'mm2.media.monitor',
|
||||
'mm2.media.metadata', 'mm2.media.saas'
|
||||
],
|
||||
package_data={'': ['*.cfg']},
|
||||
scripts=['bin/airtime-media-monitor'],
|
||||
install_requires=[
|
||||
'amqplib',
|
||||
'anyjson',
|
||||
'argparse',
|
||||
'configobj',
|
||||
'docopt',
|
||||
'kombu',
|
||||
'mutagen',
|
||||
'poster',
|
||||
'PyDispatcher',
|
||||
'pyinotify',
|
||||
'pytz',
|
||||
'wsgiref'
|
||||
],
|
||||
zip_safe=False,
|
||||
data_files=data_files)
|
||||
|
||||
# Reload the initctl config so that the media-monitor service works
|
||||
if data_files:
|
||||
print "Reloading initctl configuration"
|
||||
#call(['initctl', 'reload-configuration'])
|
||||
print "Run \"sudo service airtime-media-monitor start\""
|
|
@ -1,32 +0,0 @@
|
|||
[database]
|
||||
host = localhost
|
||||
dbname = airtime
|
||||
dbuser = airtime
|
||||
dbpass = airtime
|
||||
|
||||
[rabbitmq]
|
||||
host = 127.0.0.1
|
||||
port = 5672
|
||||
user = guest
|
||||
password = guest
|
||||
vhost = /
|
||||
|
||||
[general]
|
||||
api_key = I6EUOJM0D1EIGSMZ9T70
|
||||
web_server_user = www-data
|
||||
airtime_dir = /usr/share/airtime
|
||||
base_url = localhost
|
||||
base_port = 80
|
||||
base_dir = '/'
|
||||
|
||||
;How many hours ahead of time should Airtime playout engine (PYPO)
|
||||
;cache scheduled media files.
|
||||
cache_ahead_hours = 1
|
||||
|
||||
[monit]
|
||||
monit_user = guest
|
||||
monit_password = airtime
|
||||
|
||||
[soundcloud]
|
||||
connection_retries = 3
|
||||
time_between_retries = 60
|
|
@ -1,126 +0,0 @@
|
|||
bin_dir = "/usr/lib/airtime/api_clients"
|
||||
|
||||
#############################
|
||||
## Common
|
||||
#############################
|
||||
|
||||
# Value needed to access the API
|
||||
api_key = 'I6EUOJM0D1EIGSMZ9T70'
|
||||
|
||||
# Path to the base of the API
|
||||
api_base = 'api'
|
||||
|
||||
# URL to get the version number of the server API
|
||||
version_url = 'version/api_key/%%api_key%%'
|
||||
|
||||
#URL to register a components IP Address with the central web server
|
||||
register_component = 'register-component/format/json/api_key/%%api_key%%/component/%%component%%'
|
||||
|
||||
# Hostname
|
||||
host = 'localhost'
|
||||
base_port = 80
|
||||
base_dir = '/'
|
||||
|
||||
#############################
|
||||
## Config for Media Monitor
|
||||
#############################
|
||||
|
||||
# URL to setup the media monitor
|
||||
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
|
||||
|
||||
# Tell Airtime the file id associated with a show instance.
|
||||
upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%'
|
||||
|
||||
# URL to tell Airtime to update file's meta data
|
||||
update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%'
|
||||
|
||||
# URL to tell Airtime we want a listing of all files it knows about
|
||||
list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%/all/%%all%%'
|
||||
|
||||
# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir)
|
||||
list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%'
|
||||
|
||||
# URL to tell Airtime we want to add watched directory
|
||||
add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
|
||||
|
||||
# URL to tell Airtime we want to add watched directory
|
||||
remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
|
||||
|
||||
# URL to tell Airtime we want to add watched directory
|
||||
set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%'
|
||||
|
||||
# URL to tell Airtime about file system mount change
|
||||
update_fs_mount = 'update-file-system-mount/format/json/api_key/%%api_key%%'
|
||||
|
||||
# URL to commit multiple updates from media monitor at the same time
|
||||
|
||||
reload_metadata_group = 'reload-metadata-group/format/json/api_key/%%api_key%%'
|
||||
|
||||
# URL to tell Airtime about file system mount change
|
||||
handle_watched_dir_missing = 'handle-watched-dir-missing/format/json/api_key/%%api_key%%/dir/%%dir%%'
|
||||
|
||||
#############################
|
||||
## Config for Recorder
|
||||
#############################
|
||||
|
||||
# URL to get the schedule of shows set to record
|
||||
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
|
||||
|
||||
# URL to upload the recorded show's file to Airtime
|
||||
upload_file_url = 'upload-file/format/json/api_key/%%api_key%%'
|
||||
|
||||
# URL to commit multiple updates from media monitor at the same time
|
||||
|
||||
#number of retries to upload file if connection problem
|
||||
upload_retries = 3
|
||||
|
||||
#time to wait between attempts to upload file if connection problem (in seconds)
|
||||
upload_wait = 60
|
||||
|
||||
################################################################################
|
||||
# Uncomment *one of the sets* of values from the API clients below, and comment
|
||||
# out all the others.
|
||||
################################################################################
|
||||
|
||||
#############################
|
||||
## Config for Pypo
|
||||
#############################
|
||||
|
||||
# Schedule export path.
|
||||
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||
export_url = 'schedule/api_key/%%api_key%%'
|
||||
|
||||
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
|
||||
|
||||
# Update whether a schedule group has begun playing.
|
||||
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
|
||||
|
||||
# Update whether an audio clip is currently playing.
|
||||
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/'
|
||||
|
||||
# URL to tell Airtime we want to get stream setting
|
||||
get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
|
||||
|
||||
#URL to update liquidsoap status
|
||||
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
||||
|
||||
#URL to check live stream auth
|
||||
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%'
|
||||
|
||||
#URL to update source status
|
||||
update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%'
|
||||
|
||||
get_bootstrap_info = 'get-bootstrap-info/format/json/api_key/%%api_key%%'
|
||||
|
||||
get_files_without_replay_gain = 'get-files-without-replay-gain/api_key/%%api_key%%/dir_id/%%dir_id%%'
|
||||
|
||||
update_replay_gain_value = 'update-replay-gain-value/api_key/%%api_key%%'
|
||||
|
||||
notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%media_id%%/format/json'
|
||||
|
||||
notify_liquidsoap_started = 'rabbitmq-do-push/api_key/%%api_key%%/format/json'
|
||||
|
||||
get_stream_parameters = 'get-stream-parameters/api_key/%%api_key%%/format/json'
|
||||
|
||||
push_stream_stats = 'push-stream-stats/api_key/%%api_key%%/format/json'
|
|
@ -1,31 +0,0 @@
|
|||
api_client = "airtime"
|
||||
|
||||
# where the binary files live
|
||||
bin_dir = '/usr/lib/airtime/media-monitor'
|
||||
|
||||
# where the logging files live
|
||||
log_dir = '/var/log/airtime/media-monitor'
|
||||
|
||||
|
||||
############################################
|
||||
# RabbitMQ settings #
|
||||
############################################
|
||||
rabbitmq_host = 'localhost'
|
||||
rabbitmq_user = 'guest'
|
||||
rabbitmq_password = 'guest'
|
||||
rabbitmq_vhost = '/'
|
||||
|
||||
############################################
|
||||
# Media-Monitor preferences #
|
||||
############################################
|
||||
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
|
||||
check_airtime_events = 30 #how long to queue metadata input from airtime.
|
||||
|
||||
# MM2 only:
|
||||
touch_interval = 5
|
||||
chunking_number = 450
|
||||
request_max_wait = 3.0
|
||||
rmq_event_wait = 0.1
|
||||
logpath = '/var/log/airtime/media-monitor/media-monitor.log'
|
||||
index_path = '/var/tmp/airtime/media-monitor/last_index'
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
set daemon 10 # Poll at 10 second intervals
|
||||
set logfile /var/log/monit.log
|
||||
|
||||
# set mailserver %%mail_server%% port 25
|
||||
# set alert support@airtime.pro
|
||||
|
||||
# set mail-format {
|
||||
# from: lxc%%instance_id%%@airtime.pro
|
||||
# subject: $ACTION $SERVICE (%%mail_server%%)
|
||||
# message:
|
||||
# Monit: $ACTION $SERVICE
|
||||
# Date: $DATE
|
||||
# Description: $DESCRIPTION.
|
||||
# }
|
||||
|
||||
set httpd port 2812
|
||||
allow admin:$admin_pass
|
||||
allow guest:airtime read-only
|
|
@ -1,7 +0,0 @@
|
|||
set daemon 10 # Poll at 5 second intervals
|
||||
set logfile /var/log/monit.log
|
||||
|
||||
check process rabbitmq-server
|
||||
with pidfile "/var/run/rabbitmq.pid"
|
||||
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; /usr/lib/airtime/utils/rabbitmq-update-pid.sh'"
|
||||
stop program = "/etc/init.d/rabbitmq-server stop"
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
debug="f"
|
||||
|
||||
showhelp () {
|
||||
echo "Usage: airtime-liquidsoap [options]
|
||||
--help|-h Displays usage information.
|
||||
--debug|-d Print error messages to console"
|
||||
}
|
||||
|
||||
set -- $(getopt -l help,debug "hd" "$@")
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
(-h|--help) showhelp; exit 0;;
|
||||
(-d|--debug) debug="t";;
|
||||
|
||||
(--) shift; break;;
|
||||
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
|
||||
(*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
|
||||
. ${virtualenv_bin}activate
|
||||
|
||||
export HOME="/var/tmp/airtime/pypo/"
|
||||
api_client_path="/usr/lib/airtime/"
|
||||
if [ $debug = "t" ]; then
|
||||
ls_path="/usr/bin/airtime-liquidsoap --verbose -f"
|
||||
else
|
||||
ls_path="/usr/bin/airtime-liquidsoap --verbose -f -d"
|
||||
fi
|
||||
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
|
||||
|
||||
export PYTHONPATH=${api_client_path}
|
||||
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
cd $SCRIPTPATH/liquidsoap_scripts
|
||||
python generate_liquidsoap_cfg.py
|
||||
|
||||
exec ${ls_path} ${ls_param} 2>&1
|
||||
# EOF
|
|
@ -1,125 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: airtime-liquidsoap
|
||||
# Required-Start: $local_fs $remote_fs $network $syslog $all
|
||||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Liquidsoap daemon
|
||||
### END INIT INFO
|
||||
|
||||
USERID=pypo
|
||||
GROUPID=pypo
|
||||
NAME="Liquidsoap Playout Engine"
|
||||
|
||||
DAEMON=/usr/lib/airtime/pypo/bin/airtime-liquidsoap
|
||||
PIDFILE=/var/run/airtime-liquidsoap.pid
|
||||
EXEC='/usr/bin/airtime-liquidsoap'
|
||||
|
||||
start () {
|
||||
mkdir -p /var/log/airtime/pypo-liquidsoap
|
||||
chown $USERID:$GROUPID /var/log/airtime/pypo-liquidsoap
|
||||
|
||||
chown $USERID:$GROUPID /etc/airtime
|
||||
touch /etc/airtime/liquidsoap.cfg
|
||||
chown $USERID:$GROUPID /etc/airtime/liquidsoap.cfg
|
||||
|
||||
touch $PIDFILE
|
||||
chown $USERID:$GROUPID $PIDFILE
|
||||
|
||||
#start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
|
||||
#--pidfile $PIDFILE --nicelevel -15 --startas $DAEMON
|
||||
start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
|
||||
--nicelevel -15 --startas $DAEMON --exec $EXEC
|
||||
}
|
||||
|
||||
stop () {
|
||||
timeout --version >/dev/null 2>&1
|
||||
RESULT="$?"
|
||||
|
||||
#send term signal after 10 seconds
|
||||
if [ "$RESULT" = "0" ]; then
|
||||
timeout -s9 10s /usr/lib/airtime/airtime_virtualenv/bin/python \
|
||||
/usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py
|
||||
else
|
||||
#some earlier versions of Ubuntu (Lucid) had a different timeout
|
||||
#command that takes different input parameters.
|
||||
timeout 10 /usr/lib/airtime/airtime_virtualenv/bin/python \
|
||||
/usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py
|
||||
fi
|
||||
# Send TERM after 5 seconds, wait at most 30 seconds.
|
||||
#start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --pidfile $PIDFILE
|
||||
start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --exec $EXEC
|
||||
|
||||
rm -f $PIDFILE
|
||||
sleep 2
|
||||
}
|
||||
|
||||
start_with_monit () {
|
||||
start
|
||||
monit monitor airtime-liquidsoap >/dev/null 2>&1
|
||||
}
|
||||
|
||||
stop_with_monit() {
|
||||
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
|
||||
stop
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
case "${1:-''}" in
|
||||
'stop')
|
||||
echo "* Stopping Liquidsoap without notifying Monit process watchdog. If Monit is
|
||||
* running it will automatically bring the Liquidsoap back up. You probably want
|
||||
* 'stop-with-monit' instead of 'stop'."
|
||||
echo -n "Stopping $NAME: "
|
||||
stop
|
||||
echo "Done."
|
||||
;;
|
||||
'start')
|
||||
echo "* Starting $NAME without Monit process watchdog. To make sure Monit is watching
|
||||
* Liquidsoap, use 'start-with-monit' instead of 'start'."
|
||||
echo -n "Starting $NAME: "
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
'restart')
|
||||
# restart commands here
|
||||
echo -n "Restarting $NAME: "
|
||||
stop
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
|
||||
'status')
|
||||
if [ -f "$PIDFILE" ]; then
|
||||
pid=`cat $PIDFILE`
|
||||
if [ -d "/proc/$pid" ]; then
|
||||
echo "$NAME is running"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
echo "$NAME is not running"
|
||||
exit 1
|
||||
;;
|
||||
'start-with-monit')
|
||||
# restart commands here
|
||||
echo -n "Starting $NAME: "
|
||||
start_with_monit
|
||||
echo "Done."
|
||||
;;
|
||||
'stop-with-monit')
|
||||
# restart commands here
|
||||
echo -n "Stopping $NAME: "
|
||||
stop_with_monit
|
||||
echo "Done."
|
||||
;;
|
||||
|
||||
*) # no parameter specified
|
||||
echo "Usage: $SELF start|stop|restart|status"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
|
@ -1,35 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
|
||||
. ${virtualenv_bin}activate
|
||||
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute directory this script is in
|
||||
pypo_path=`dirname $SCRIPT`
|
||||
|
||||
api_client_path="/usr/lib/airtime/"
|
||||
pypo_script="pypocli.py"
|
||||
cd ${pypo_path}
|
||||
|
||||
set +e
|
||||
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
|
||||
set -e
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/pypo/error.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export HOME="/var/tmp/airtime/pypo/"
|
||||
export PYTHONPATH=${api_client_path}:$PYTHONPATH
|
||||
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
|
||||
export TERM=xterm
|
||||
|
||||
|
||||
#Nothing to do with Pypo, but for container maintenance. Let's parse the IP address
|
||||
#so we may more easily manage our instance containers
|
||||
ifconfig eth0 | egrep -o 'inet addr:([0-9]{1,3}\.){3}[0-9]{1,3}' | cut -d':' -f2 > /etc/airtime_ip_addr
|
||||
|
||||
exec python ${pypo_path}/${pypo_script} > /var/log/airtime/pypo/py-interpreter.log 2>&1
|
||||
|
||||
# EOF
|
5
python_apps/pypo/bin/airtime-liquidsoap
Executable file
5
python_apps/pypo/bin/airtime-liquidsoap
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
import runpy
|
||||
|
||||
# Run the liquidsoap python module
|
||||
runpy.run_module('liquidsoap')
|
5
python_apps/pypo/bin/airtime-playout
Executable file
5
python_apps/pypo/bin/airtime-playout
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
import runpy
|
||||
|
||||
runpy.run_module("pypo", run_name="__main__")
|
||||
|
24
python_apps/pypo/pyponotify.py → python_apps/pypo/bin/pyponotify
Normal file → Executable file
24
python_apps/pypo/pyponotify.py → python_apps/pypo/bin/pyponotify
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import traceback
|
||||
|
||||
|
@ -29,6 +30,9 @@ from configobj import ConfigObj
|
|||
from api_clients import *
|
||||
from std_err_override import LogWriter
|
||||
|
||||
LOG_LEVEL = logging.INFO
|
||||
LOG_PATH = '/var/log/airtime/pypo/notify.log'
|
||||
|
||||
# help screeen / info
|
||||
usage = "%prog [options]" + " - notification gateway"
|
||||
parser = OptionParser(usage=usage)
|
||||
|
@ -49,17 +53,27 @@ parser.add_option("-n", "--liquidsoap-started", help="notify liquidsoap started"
|
|||
# parse options
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# configure logging
|
||||
logging.config.fileConfig("notify_logging.cfg")
|
||||
logger = logging.getLogger('notify')
|
||||
LogWriter.override_std_err(logger)
|
||||
# Set up logging
|
||||
logFormatter = logging.Formatter("%(asctime)s [%(module)s] [%(levelname)-5.5s] %(message)s")
|
||||
rootLogger = logging.getLogger()
|
||||
rootLogger.setLevel(LOG_LEVEL)
|
||||
|
||||
fileHandler = logging.handlers.RotatingFileHandler(filename=LOG_PATH, maxBytes=1024*1024*30,
|
||||
backupCount=8)
|
||||
fileHandler.setFormatter(logFormatter)
|
||||
rootLogger.addHandler(fileHandler)
|
||||
|
||||
consoleHandler = logging.StreamHandler()
|
||||
consoleHandler.setFormatter(logFormatter)
|
||||
rootLogger.addHandler(consoleHandler)
|
||||
logger = rootLogger
|
||||
|
||||
#need to wait for Python 2.7 for this..
|
||||
#logging.captureWarnings(True)
|
||||
|
||||
# loading config file
|
||||
try:
|
||||
config = ConfigObj('/etc/airtime/pypo.cfg')
|
||||
config = ConfigObj('/etc/airtime/airtime.conf')
|
||||
|
||||
except Exception, e:
|
||||
logger.error('Error loading config file: %s', e)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue