From 973e934151bf8c6fc113b02e2cae7c984edad1ec Mon Sep 17 00:00:00 2001 From: James Date: Tue, 4 Oct 2011 17:20:22 -0400 Subject: [PATCH 1/2] CC-2927: Media Monitor: if new dir is generated in the process of importing a file, airtime doesn't import the file. - fixed --- python_apps/media-monitor/MediaMonitor.py | 2 +- .../airtimefilemonitor/airtimeprocessevent.py | 13 ++----------- .../airtimefilemonitor/mediamonitorcommon.py | 5 ++++- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index 1b459c5f2..32ca17878 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -58,7 +58,7 @@ try: wm = WatchManager() - mmc = MediaMonitorCommon(config) + mmc = MediaMonitorCommon(config, wm=wm) pe = AirtimeProcessEvent(queue=multi_queue, airtime_config=config, wm=wm, mmc=mmc, api_client=api_client) bootstrap = AirtimeMediaMonitorBootstrap(logger, pe, api_client, mmc) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 30685b54d..5c8e9f9d6 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -90,12 +90,8 @@ class AirtimeProcessEvent(ProcessEvent): def process_IN_CREATE(self, event): self.logger.info("event: %s", event) - if not event.dir: - if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory): - self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': True}) - # record the timestamp of the time on IN_CREATE event - self.create_dict[event.pathname] = time.time() - + # record the timestamp of the time on IN_CREATE event + self.create_dict[event.pathname] = time.time() #event.dir: True if the event was raised against a directory. #event.name: filename @@ -171,11 +167,6 @@ class AirtimeProcessEvent(ProcessEvent): else: self.cookies_IN_MOVED_FROM[event.cookie] = (event, time.time()) - - #Some weird thing to note about this event: it seems that if a file is moved to a newly - #created directory, then the IN_MOVED_FROM event will be called, but instead of a corresponding - #IN_MOVED_TO event, a IN_CREATED event will happen instead. However if the directory existed before - #then the IN_MOVED_TO event will be called. def process_IN_MOVED_TO(self, event): self.logger.info("process_IN_MOVED_TO: %s", event) #if stuff dropped in stor via a UI move must change file permissions. diff --git a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py index d8ae5d1e6..bf0ab3f8e 100644 --- a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py +++ b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py @@ -6,16 +6,18 @@ import logging from subprocess import Popen, PIPE from airtimemetadata import AirtimeMetadata from api_clients import api_client +import pyinotify class MediaMonitorCommon: timestamp_file = "/var/tmp/airtime/last_index" - def __init__(self, airtime_config): + def __init__(self, airtime_config, wm=None): self.supported_file_formats = ['mp3', 'ogg'] self.logger = logging.getLogger() self.config = airtime_config self.md_manager = AirtimeMetadata() + self.wm = wm def is_parent_directory(self, filepath, directory): filepath = os.path.normpath(filepath) @@ -85,6 +87,7 @@ class MediaMonitorCommon: omask = os.umask(0) if not os.path.exists(directory): os.makedirs(directory, 02777) + self.wm.add_watch(directory, pyinotify.ALL_EVENTS, rec=True, auto_add=True) elif not os.path.isdir(directory): #path exists but it is a file not a directory! self.logger.error("path %s exists, but it is not a directory!!!") From 38f2290214ed5e4638e75035ab00dcabdbda9736 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 13 Oct 2011 23:35:18 +0200 Subject: [PATCH 2/2] CC-2972: Find better way to determine domain which pypo should download from. -remove basePort and baseUrl from code + config file, since it isn't used anywhere. --- airtime_mvc/application/configs/conf.php | 4 ++-- airtime_mvc/build/airtime.conf | 2 -- utils/phone_home_stat.php | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 51899021a..10d54b01a 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -63,8 +63,8 @@ class Config { $CC_CONFIG['webServerUser'] = $values['general']['web_server_user']; $CC_CONFIG['rabbitmq'] = $values['rabbitmq']; - $CC_CONFIG['baseUrl'] = $values['general']['base_url']; - $CC_CONFIG['basePort'] = $values['general']['base_port']; + //$CC_CONFIG['baseUrl'] = $values['general']['base_url']; + //$CC_CONFIG['basePort'] = $values['general']['base_port']; // Database config $CC_CONFIG['dsn']['username'] = $values['database']['dbuser']; diff --git a/airtime_mvc/build/airtime.conf b/airtime_mvc/build/airtime.conf index b11e672ce..aa1ca2dde 100644 --- a/airtime_mvc/build/airtime.conf +++ b/airtime_mvc/build/airtime.conf @@ -15,8 +15,6 @@ vhost = / api_key = AAA web_server_user = www-data airtime_dir = x -base_url = localhost -base_port = 80 [soundcloud] connection_retries = 3 diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index 1a695645b..73f5b7cc6 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -6,8 +6,8 @@ $CC_CONFIG['webServerUser'] = $values['general']['web_server_user']; $CC_CONFIG['phpDir'] = $values['general']['airtime_dir']; $CC_CONFIG['rabbitmq'] = $values['rabbitmq']; -$CC_CONFIG['baseUrl'] = $values['general']['base_url']; -$CC_CONFIG['basePort'] = $values['general']['base_port']; +//$CC_CONFIG['baseUrl'] = $values['general']['base_url']; +//$CC_CONFIG['basePort'] = $values['general']['base_port']; // Database config $CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];