cc-4105: hooked last run feature into mm2

This commit is contained in:
Rudi Grinberg 2012-07-23 14:27:12 -04:00
parent 50116fa6bb
commit 84313a6135
4 changed files with 22 additions and 9 deletions

View file

@ -9,11 +9,11 @@ class Bootstrapper(Loggable):
Bootstrapper reads all the info in the filesystem flushes organize
events and watch events
"""
def __init__(self,db,last_run,org_channels,watch_channels):
def __init__(self,db,last_ran,org_channels,watch_channels):
self.db = db
self.org_channels = org_channels
self.watch_channels = watch_channels
self.last_run = last_run
self.last_ran = last_ran
def flush_organize(self):
"""
@ -44,11 +44,11 @@ class Bootstrapper(Loggable):
songs[ pc.path ].add(f)
# We decide whether to update a file's metadata by checking
# its system modification date. If it's above the value
# self.last_run which is passed to us that means media monitor
# self.last_ran which is passed to us that means media monitor
# wasn't aware when this changes occured in the filesystem
# hence it will send the correct events to sync the database
# with the filesystem
if os.path.getmtime(f) > self.last_run:
if os.path.getmtime(f) > self.last_ran:
modded += 1
dispatcher.send(signal=pc.signal, sender=self, event=DeleteFile(f))
dispatcher.send(signal=pc.signal, sender=self, event=NewFile(f))

View file

@ -3,13 +3,11 @@ import os
from configobj import ConfigObj
import copy
from media.monitor.log import Loggable
from media.monitor.exceptions import NoConfigFile, ConfigAccessViolation
class MMConfig(Loggable):
class MMConfig(object):
def __init__(self, path):
if not os.path.exists(path):
self.logger.error("Configuration file does not exist. Path: '%s'" % path)
raise NoConfigFile(path)
self.cfg = ConfigObj(path)

View file

@ -277,6 +277,16 @@ def fondle(path,times=None):
with file(path, 'a'):
os.utime(path, times)
def last_modified(path):
"""
return the time of the last time mm2 was ran. path refers to the index file whose
date modified attribute contains this information. In the case when the file does not
exist we set this time 0 so that any files on the filesystem were modified after it
"""
if os.path.exists(path):
os.path.gmtime(path)
else: 0
if __name__ == '__main__':
import doctest
doctest.testmod()