sintonia/python_apps/airtime_analyzer/bin/airtime_analyzer
Albert Santoni 61c2c90b7e CC-5709: Airtime Analyzer
* Remove the "hidden" field from the REST blacklist, the analyzer needs to set it.
* Added import_status column messages in the recent uploads table
* Auto-refresh the recent uploads table while imports are pending
* Moved the file moving stuff to its own analyzer in airtime_analyzer
* Basic error reporting to the REST API in airtime_analyzer, needs
  hardeneing though
* Fixed a bug with the number of recent uploads
* Prevent airtime_analyzer from running if media_monitor is running
2014-03-22 02:12:03 -04:00

42 lines
1.4 KiB
Python
Executable file

#!/usr/bin/env python
import daemon
import argparse
import os
import airtime_analyzer.airtime_analyzer as aa
VERSION = "1.0"
print "Airtime Analyzer " + VERSION
parser = argparse.ArgumentParser()
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")
args = parser.parse_args()
'''Ensure media_monitor isn't running before we start, because it'll move newly uploaded
files into the library on us and screw up the operation of airtime_analyzer.
media_monitor is deprecated.
'''
def check_if_media_monitor_is_running():
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
try:
process_name = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
if 'media_monitor.py' in process_name:
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."
exit(1)
except IOError: # proc has already terminated
continue
check_if_media_monitor_is_running()
if args.daemon:
with daemon.DaemonContext():
analyzer = aa.AirtimeAnalyzerServer(debug=args.debug)
else:
# Run without daemonizing
analyzer = aa.AirtimeAnalyzerServer(debug=args.debug)