CC-1799 : Live Studio Playout from media library (pytagsfs)
starting python script using pyinotify
This commit is contained in:
parent
7a40161e7e
commit
a9d6bc3db5
|
@ -0,0 +1,29 @@
|
|||
api_client = "airtime"
|
||||
|
||||
# Hostname
|
||||
base_url = 'localhost'
|
||||
base_port = 80
|
||||
|
||||
# where the binary files live
|
||||
bin_dir = '/usr/lib/airtime/media-monitor'
|
||||
|
||||
# base path to store recordered shows at
|
||||
base_recorded_files = '/var/tmp/airtime/show-recorder/'
|
||||
|
||||
# where the logging files live
|
||||
log_dir = '/var/log/airtime/show-recorder'
|
||||
|
||||
# Value needed to access the API
|
||||
api_key = 'AAA'
|
||||
|
||||
# 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 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-recorded/format/json/api_key/%%api_key%%'
|
|
@ -0,0 +1,52 @@
|
|||
import os
|
||||
import pyinotify
|
||||
from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent
|
||||
|
||||
# configure logging
|
||||
try:
|
||||
logging.config.fileConfig("logging.cfg")
|
||||
except Exception, e:
|
||||
print 'Error configuring logging: ', e
|
||||
sys.exit()
|
||||
|
||||
# loading config file
|
||||
try:
|
||||
config = ConfigObj('/etc/airtime/recorder.cfg')
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
|
||||
# watched events
|
||||
mask = pyinotify.ALL_EVENTS
|
||||
|
||||
wm = WatchManager()
|
||||
wdd = wm.add_watch('/srv/airtime/stor', mask, rec=True)
|
||||
|
||||
class PTmp(ProcessEvent):
|
||||
def process_IN_CREATE(self, event):
|
||||
if event.dir :
|
||||
global wm
|
||||
wdd = wm.add_watch(event.pathname, mask, rec=True)
|
||||
#print wdd.keys()
|
||||
|
||||
print "%s: %s" % (event.maskname, os.path.join(event.path, event.name))
|
||||
|
||||
def process_IN_MODIFY(self, event):
|
||||
if not event.dir :
|
||||
print event.path
|
||||
|
||||
print "%s: %s" % (event.maskname, os.path.join(event.path, event.name))
|
||||
|
||||
def process_default(self, event):
|
||||
print "%s: %s" % (event.maskname, os.path.join(event.path, event.name))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
try:
|
||||
notifier = Notifier(wm, PTmp(), read_freq=2, timeout=1)
|
||||
notifier.coalesce_events()
|
||||
notifier.loop()
|
||||
except KeyboardInterrupt:
|
||||
notifier.stop()
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
[loggers]
|
||||
keys=root
|
||||
|
||||
[handlers]
|
||||
keys=consoleHandler
|
||||
|
||||
[formatters]
|
||||
keys=simpleFormatter
|
||||
|
||||
[logger_root]
|
||||
level=DEBUG
|
||||
handlers=consoleHandler
|
||||
|
||||
[handler_consoleHandler]
|
||||
class=StreamHandler
|
||||
level=DEBUG
|
||||
formatter=simpleFormatter
|
||||
args=(sys.stdout,)
|
||||
|
||||
[formatter_simpleFormatter]
|
||||
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s
|
||||
datefmt=
|
Loading…
Reference in New Issue