CC-1799 Put Airtime Storage into a Human Readable File Naming Convention
adding setup to get stor folder etc.
This commit is contained in:
parent
71d853567e
commit
8d9c0dab1a
5 changed files with 47 additions and 12 deletions
|
@ -10,6 +10,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$context->addActionContext('version', 'json')
|
$context->addActionContext('version', 'json')
|
||||||
->addActionContext('recorded-shows', 'json')
|
->addActionContext('recorded-shows', 'json')
|
||||||
->addActionContext('upload-recorded', 'json')
|
->addActionContext('upload-recorded', 'json')
|
||||||
|
->addActionContext('media-monitor-setup', 'json')
|
||||||
->addActionContext('media-item-status', 'json')
|
->addActionContext('media-item-status', 'json')
|
||||||
->addActionContext('reload-metadata', 'json')
|
->addActionContext('reload-metadata', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
|
@ -633,7 +633,6 @@ class StoredFile {
|
||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
//$p_targetDir = ini_get("upload_tmp_dir"); //. DIRECTORY_SEPARATOR . "plupload";
|
|
||||||
$cleanupTargetDir = false; // Remove old files
|
$cleanupTargetDir = false; // Remove old files
|
||||||
$maxFileAge = 60 * 60; // Temp file age in seconds
|
$maxFileAge = 60 * 60; // Temp file age in seconds
|
||||||
|
|
||||||
|
@ -734,6 +733,9 @@ class StoredFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -359,6 +359,25 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def setup_media_monitor(self):
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
response = None
|
||||||
|
try:
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["media_setup_url"])
|
||||||
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
|
logger.debug(url)
|
||||||
|
|
||||||
|
response = urllib.urlopen(url)
|
||||||
|
response = json.loads(response.read())
|
||||||
|
logger.debug("Json Media Setup %s", response)
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
response = None
|
||||||
|
logger.error("Exception: %s", e)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
def check_media_status(self, md5):
|
def check_media_status(self, md5):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ MODE_CREATE = "create"
|
||||||
MODE_MODIFY = "modify"
|
MODE_MODIFY = "modify"
|
||||||
|
|
||||||
global storage_directory
|
global storage_directory
|
||||||
storage_directory = "/srv/airtime/stor"
|
global plupload_directory
|
||||||
|
|
||||||
# configure logging
|
# configure logging
|
||||||
try:
|
try:
|
||||||
|
@ -136,7 +136,7 @@ class MediaMonitor(ProcessEvent):
|
||||||
connection = BrokerConnection(config["rabbitmq_host"], config["rabbitmq_user"], config["rabbitmq_password"], "/")
|
connection = BrokerConnection(config["rabbitmq_host"], config["rabbitmq_user"], config["rabbitmq_password"], "/")
|
||||||
channel = connection.channel()
|
channel = connection.channel()
|
||||||
|
|
||||||
self.producer = Producer(channel, exchange=schedule_exchange, serializer="json")
|
#self.producer = Producer(channel, exchange=schedule_exchange, serializer="json")
|
||||||
#producer.publish({"name": "/tmp/lolcat1.avi", "size": 1301013})
|
#producer.publish({"name": "/tmp/lolcat1.avi", "size": 1301013})
|
||||||
|
|
||||||
def get_md5(self, filepath):
|
def get_md5(self, filepath):
|
||||||
|
@ -280,9 +280,6 @@ class MediaMonitor(ProcessEvent):
|
||||||
else :
|
else :
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def setUpMediaMonitor(self, event):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def process_IN_CREATE(self, event):
|
def process_IN_CREATE(self, event):
|
||||||
if not event.dir:
|
if not event.dir:
|
||||||
#file created is a tmp file which will be modified and then moved back to the original filename.
|
#file created is a tmp file which will be modified and then moved back to the original filename.
|
||||||
|
@ -335,7 +332,7 @@ class MediaMonitor(ProcessEvent):
|
||||||
|
|
||||||
def process_IN_DELETE(self, event):
|
def process_IN_DELETE(self, event):
|
||||||
|
|
||||||
self.producer.publish({"name": "Hi!"})
|
#self.producer.publish({"name": "Hi!"})
|
||||||
|
|
||||||
self.logger.info("%s: %s", event.maskname, event.pathname)
|
self.logger.info("%s: %s", event.maskname, event.pathname)
|
||||||
|
|
||||||
|
@ -366,14 +363,27 @@ if __name__ == '__main__':
|
||||||
pyinotify.IN_DELETE_SELF
|
pyinotify.IN_DELETE_SELF
|
||||||
#mask = pyinotify.ALL_EVENTS
|
#mask = pyinotify.ALL_EVENTS
|
||||||
|
|
||||||
wm = WatchManager()
|
|
||||||
wdd = wm.add_watch(storage_directory, mask, rec=True, auto_add=True)
|
|
||||||
|
|
||||||
logger = logging.getLogger('root')
|
logger = logging.getLogger('root')
|
||||||
logger.info("Added watch to %s", storage_directory)
|
|
||||||
|
|
||||||
mm = MediaMonitor()
|
mm = MediaMonitor()
|
||||||
|
|
||||||
|
response = None
|
||||||
|
while response is None:
|
||||||
|
response = mm.api_client.setup_media_monitor()
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
storage_directory = response["stor"]
|
||||||
|
plupload_directory = response["plupload"]
|
||||||
|
|
||||||
|
wm = WatchManager()
|
||||||
|
|
||||||
|
wdd = wm.add_watch(storage_directory, mask, rec=True, auto_add=True)
|
||||||
|
logger.info("Added watch to %s", storage_directory)
|
||||||
|
logger.info("wdd result %s", wdd[storage_directory])
|
||||||
|
|
||||||
|
wdd = wm.add_watch(plupload_directory, mask, rec=False, auto_add=True)
|
||||||
|
logger.info("Added watch to %s", plupload_directory)
|
||||||
|
logger.info("wdd result %s", wdd[plupload_directory])
|
||||||
|
|
||||||
notifier = AirtimeNotifier(wm, mm, read_freq=int(config["check_filesystem_events"]), timeout=1)
|
notifier = AirtimeNotifier(wm, mm, read_freq=int(config["check_filesystem_events"]), timeout=1)
|
||||||
notifier.coalesce_events()
|
notifier.coalesce_events()
|
||||||
notifier.loop(callback=mm.check_rabbit_MQ)
|
notifier.loop(callback=mm.check_rabbit_MQ)
|
||||||
|
|
|
@ -19,6 +19,9 @@ api_base = 'api'
|
||||||
# URL to get the version number of the server API
|
# URL to get the version number of the server API
|
||||||
version_url = 'version/api_key/%%api_key%%'
|
version_url = 'version/api_key/%%api_key%%'
|
||||||
|
|
||||||
|
# URL to setup the media monitor
|
||||||
|
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
|
||||||
|
|
||||||
# URL to check Airtime's status of a file
|
# URL to check Airtime's status of a file
|
||||||
media_status_url = 'media-item-status/format/json/api_key/%%api_key%%/md5/%%md5%%'
|
media_status_url = 'media-item-status/format/json/api_key/%%api_key%%/md5/%%md5%%'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue