cc-4105: got rid of useless debugging lines. refined initial configuration. fixed double bootstrapping bug
This commit is contained in:
parent
701a618896
commit
a576af2482
4 changed files with 18 additions and 15 deletions
|
@ -53,8 +53,6 @@ class Bootstrapper(Loggable):
|
||||||
dispatcher.send(signal=self.watch_signal, sender=self, event=DeleteFile(to_delete))
|
dispatcher.send(signal=self.watch_signal, sender=self, event=DeleteFile(to_delete))
|
||||||
deleted += 1
|
deleted += 1
|
||||||
for to_add in songs.difference(db_songs):
|
for to_add in songs.difference(db_songs):
|
||||||
#if len(songs.difference(db_songs)) > 100:
|
|
||||||
#import ipdb; ipdb.set_trace()
|
|
||||||
dispatcher.send(signal=self.watch_signal, sender=self, event=NewFile(to_add))
|
dispatcher.send(signal=self.watch_signal, sender=self, event=NewFile(to_add))
|
||||||
added += 1
|
added += 1
|
||||||
self.logger.info( "Flushed watch directory (%s). (added, modified, deleted) = (%d, %d, %d)"
|
self.logger.info( "Flushed watch directory (%s). (added, modified, deleted) = (%d, %d, %d)"
|
||||||
|
|
|
@ -105,14 +105,16 @@ class OrganizeListener(BaseListener, pyinotify.ProcessEvent, Loggable):
|
||||||
|
|
||||||
class StoreWatchListener(BaseListener, Loggable, pyinotify.ProcessEvent):
|
class StoreWatchListener(BaseListener, Loggable, pyinotify.ProcessEvent):
|
||||||
# TODO : must intercept DeleteDirWatch events somehow
|
# TODO : must intercept DeleteDirWatch events somehow
|
||||||
def process_IN_CLOSE_WRITE(self, event): self.process_create(event)
|
def process_IN_CLOSE_WRITE(self, event):
|
||||||
|
import ipdb; ipdb.set_trace()
|
||||||
|
self.process_create(event)
|
||||||
def process_IN_MOVED_TO(self, event):
|
def process_IN_MOVED_TO(self, event):
|
||||||
if EventRegistry.registered(event):
|
if EventRegistry.registered(event):
|
||||||
# We need this trick because we don't how to "expand" dir events
|
# We need this trick because we don't how to "expand" dir events
|
||||||
# into file events until we know for sure if we deleted or moved
|
# into file events until we know for sure if we deleted or moved
|
||||||
morph = MoveDir(event) if event.dir else MoveFile(event)
|
morph = MoveDir(event) if event.dir else MoveFile(event)
|
||||||
EventRegistry.matching(event).morph_into(morph)
|
EventRegistry.matching(event).morph_into(morph)
|
||||||
else: self.process_create(event)
|
#else: self.process_create(event)
|
||||||
def process_IN_MOVED_FROM(self, event):
|
def process_IN_MOVED_FROM(self, event):
|
||||||
# Is either delete dir or delete file
|
# Is either delete dir or delete file
|
||||||
evt = self.process_delete(event)
|
evt = self.process_delete(event)
|
||||||
|
|
|
@ -17,10 +17,8 @@ import media.monitor.pure as mmp
|
||||||
from api_clients import api_client as apc
|
from api_clients import api_client as apc
|
||||||
|
|
||||||
global_config = u'/home/rudi/Airtime/python_apps/media-monitor2/tests/live_client.cfg'
|
global_config = u'/home/rudi/Airtime/python_apps/media-monitor2/tests/live_client.cfg'
|
||||||
logfile = u'/home/rudi/throwaway/mm2.log'
|
api_client_config = u'/home/rudi/Airtime/python_apps/media-monitor2/tests/live_client.cfg'
|
||||||
|
|
||||||
setup_logging(logfile)
|
|
||||||
log = get_logger()
|
|
||||||
# MMConfig is a proxy around ConfigObj instances. it does not allow itself
|
# MMConfig is a proxy around ConfigObj instances. it does not allow itself
|
||||||
# users of MMConfig instances to modify any config options directly through the
|
# users of MMConfig instances to modify any config options directly through the
|
||||||
# dictionary. Users of this object muse use the correct methods designated for
|
# dictionary. Users of this object muse use the correct methods designated for
|
||||||
|
@ -28,14 +26,19 @@ log = get_logger()
|
||||||
config = None
|
config = None
|
||||||
try: config = MMConfig(global_config)
|
try: config = MMConfig(global_config)
|
||||||
except NoConfigFile as e:
|
except NoConfigFile as e:
|
||||||
log.info("Cannot run mediamonitor2 without configuration file.")
|
print("Cannot run mediamonitor2 without configuration file.")
|
||||||
log.info("Current config path: '%s'" % global_config)
|
print("Current config path: '%s'" % global_config)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.info("Unknown error reading configuration file: '%s'" % global_config)
|
print("Unknown error reading configuration file: '%s'" % global_config)
|
||||||
log.info(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
logfile = unicode( config['logpath'] )
|
||||||
|
|
||||||
|
setup_logging(logfile)
|
||||||
|
log = get_logger()
|
||||||
log.info("Attempting to set the locale...")
|
log.info("Attempting to set the locale...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mmp.configure_locale(mmp.get_system_locale())
|
mmp.configure_locale(mmp.get_system_locale())
|
||||||
except FailedToSetLocale as e:
|
except FailedToSetLocale as e:
|
||||||
|
@ -52,8 +55,8 @@ watch_syncer = WatchSyncer(signal='watch',
|
||||||
chunking_number=config['chunking_number'],
|
chunking_number=config['chunking_number'],
|
||||||
timeout=config['request_max_wait'])
|
timeout=config['request_max_wait'])
|
||||||
|
|
||||||
apiclient = apc.AirtimeApiClient.create_right_config(log=log,config_path=global_config)
|
apiclient = apc.AirtimeApiClient.create_right_config(log=log,
|
||||||
|
config_path=api_client_config)
|
||||||
|
|
||||||
# TODO : Need to do setup_media_monitor call somewhere around here to get
|
# TODO : Need to do setup_media_monitor call somewhere around here to get
|
||||||
# import/organize dirs
|
# import/organize dirs
|
||||||
|
@ -67,7 +70,6 @@ airtime_notifier = AirtimeNotifier(config, airtime_receiver)
|
||||||
store = apiclient.setup_media_monitor()
|
store = apiclient.setup_media_monitor()
|
||||||
airtime_receiver.change_storage({ 'directory':store[u'stor'] })
|
airtime_receiver.change_storage({ 'directory':store[u'stor'] })
|
||||||
|
|
||||||
|
|
||||||
for watch_dir in store[u'watched_dirs']:
|
for watch_dir in store[u'watched_dirs']:
|
||||||
if not os.path.exists(watch_dir):
|
if not os.path.exists(watch_dir):
|
||||||
# Create the watch_directory here
|
# Create the watch_directory here
|
||||||
|
@ -80,7 +82,7 @@ for watch_dir in store[u'watched_dirs']:
|
||||||
last_ran=config.last_ran()
|
last_ran=config.last_ran()
|
||||||
bs = Bootstrapper( db=sdb, watch_signal='watch' )
|
bs = Bootstrapper( db=sdb, watch_signal='watch' )
|
||||||
|
|
||||||
bs.flush_all( config.last_ran() )
|
#bs.flush_all( config.last_ran() )
|
||||||
|
|
||||||
ed = EventDrainer(airtime_notifier.connection,interval=float(config['rmq_event_wait']))
|
ed = EventDrainer(airtime_notifier.connection,interval=float(config['rmq_event_wait']))
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ touch_interval = 5
|
||||||
chunking_number = 150
|
chunking_number = 150
|
||||||
request_max_wait = 3.0
|
request_max_wait = 3.0
|
||||||
rmq_event_wait = 0.5
|
rmq_event_wait = 0.5
|
||||||
|
logpath = '/home/rudi/throwaway/mm2.log'
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
## Common
|
## Common
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue