The branch, frodo has been updated
via df7a635a9616deca7d421b5cdaf1bf9eab48f210 (commit)
from ae5173cc2c2e33f32a2c065fcd132fe8b9df5912 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=df7a635a9616deca7d421b5cdaf1bf9eab48f210
commit df7a635a9616deca7d421b5cdaf1bf9eab48f210
Author: Martijn Kaijser <[email protected]>
Date: Sun May 26 19:57:05 2013 +0200
[service.watchdog] 0.7.6
diff --git a/service.watchdog/addon.xml b/service.watchdog/addon.xml
index 594ccc6..f25ae49 100644
--- a/service.watchdog/addon.xml
+++ b/service.watchdog/addon.xml
@@ -2,7 +2,7 @@
<addon
id="service.watchdog"
name="Watchdog"
- version="0.7.5"
+ version="0.7.6"
provider-name="takoi">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
@@ -17,5 +17,8 @@
<summary lang="fr">Maintient les médiathèques synchonisée avec le
système de fichiers</summary>
<description lang="en">This service will automatically update the video
and music library when new files are added or removed from a media source.
Update is instant.</description>
<description lang="fr">Ce service met automatiquement à jour les
médiathèques vidéo et musique lorsque des nouveaux fichiers sont ajoutés ou
supprimés d'une source. La mise à jour est instantannée.</description>
+ <license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007</license>
+ <forum>http://forum.xbmc.org/showthread.php?tid=128896</forum>
+ <source>https://github.com/takoi/xbmc-addon-watchdog</source>
</extension>
</addon>
diff --git a/service.watchdog/changelog.txt b/service.watchdog/changelog.txt
index 8fe3d8c..dbfda03 100644
--- a/service.watchdog/changelog.txt
+++ b/service.watchdog/changelog.txt
@@ -1,3 +1,6 @@
+[B]0.7.6[/B]
+- fixed multiple issues with the depth 2 poller
+
[B]0.7.5[/B]
- added option for forcing global scan on video sources. This is a workaround
for a bug that cause XBMC to sometimes fail to recognize the newly added files
diff --git a/service.watchdog/core/polling.py b/service.watchdog/core/polling.py
index 7107e55..3d22b31 100644
--- a/service.watchdog/core/polling.py
+++ b/service.watchdog/core/polling.py
@@ -37,35 +37,38 @@ class SnapshotRootOnly(object):
class PathSnapsot(object):
def __init__(self, root, walker):
- self._paths = set()
- self._dirs = set()
+ self._files = set()
for dirs, files in walker(root):
- self._dirs.update(dirs)
- self._paths.update(files)
-
- def path_diff(self, other):
- created = other._paths - self._paths
- deleted = self._paths - other._paths
- return created, deleted
+ self._files.update(files)
def diff(self, other):
- created, deleted = self.path_diff(other)
+ created = other._files - self._files
+ deleted = self._files - other._files
return created, deleted, []
-class SnapshotWithStat(PathSnapsot):
+class SnapshotWithStat(object):
def __init__(self, root, walker, get_mtime):
- PathSnapsot.__init__(self, root, walker)
+ self._dirs = set()
+ self._files = set()
self._stat_info = {}
+ for dirs, files in walker(root):
+ self._dirs.update(dirs)
+ self._files.update(files)
for path in self._dirs:
self._stat_info[path] = get_mtime(path)
def diff(self, other):
- created, deleted = self.path_diff(other)
- modified = []
- for path in set(self._stat_info) - deleted - created:
+ created_files = other._files - self._files
+ deleted_files = self._files - other._files
+
+ created_dirs = other._dirs - self._dirs
+ deleted_dirs = self._dirs - other._dirs
+
+ modified_dirs = []
+ for path in set(self._stat_info) - deleted_dirs - created_dirs:
if self._stat_info[path] != other._stat_info[path]:
- modified.append(path)
- return created, deleted, modified
+ modified_dirs.append(path)
+ return created_files | created_dirs, deleted_files | deleted_dirs,
modified_dirs
class Poller(EventEmitter):
def __init__(self, event_queue, watch, make_snapshot, timeout):
diff --git a/service.watchdog/lib/watchdog/events.py
b/service.watchdog/lib/watchdog/events.py
index dabbecc..7495cf5 100644
--- a/service.watchdog/lib/watchdog/events.py
+++ b/service.watchdog/lib/watchdog/events.py
@@ -142,9 +142,7 @@ src_path=%(src_path)s, is_directory=%(is_directory)s>" %\
# Used for comparison of events.
@property
def key(self):
- return (self.event_type,
- self.src_path,
- self.is_directory)
+ return (self.event_type, self.src_path, self.is_directory)
def __eq__(self, event):
return self.key == event.key
@@ -174,11 +172,9 @@ class FileSystemMovedEvent(FileSystemEvent):
return self._dest_path
# Used for hashing this as an immutable object.
- def _key(self):
- return (self.event_type,
- self.src_path,
- self.dest_path,
- self.is_directory)
+ @property
+ def key(self):
+ return (self.event_type, self.src_path, self.dest_path, self.is_directory)
def __repr__(self):
return "<%(class_name)s: src_path=%(src_path)s, dest_path=%(dest_path)s, \
diff --git a/service.watchdog/lib/watchdog/observers/inotify.py
b/service.watchdog/lib/watchdog/observers/inotify.py
index 18d6179..8b4d46e 100644
--- a/service.watchdog/lib/watchdog/observers/inotify.py
+++ b/service.watchdog/lib/watchdog/observers/inotify.py
@@ -569,8 +569,7 @@ if platform.is_linux():
event_list.append(inotify_event)
- if inotify_event.is_directory:
- if inotify_event.is_create:
+ if self.is_recursive and inotify_event.is_directory and
inotify_event.is_create:
# HACK: We need to traverse the directory path
# recursively and simulate events for newly
# created subdirectories/files. This will handle
@@ -583,35 +582,24 @@ if platform.is_linux():
# IN_MOVED_TO events which don't pair up with
# IN_MOVED_FROM events should be marked IN_CREATE
# instead relative to this directory.
+ try:
self._add_watch(src_path, self._event_mask)
-
- for root, dirnames, filenames in os.walk(src_path):
- for dirname in dirnames:
- full_path = absolute_path(
- os.path.join(root, dirname))
- wd_dir = self._add_watch(full_path,
- self._event_mask)
+ except OSError:
+ continue
+ for root, dirnames, filenames in os.walk(src_path):
+ for dirname in dirnames:
+ try:
+ full_path = absolute_path(os.path.join(root, dirname))
+ wd_dir = self._add_watch(full_path, self._event_mask)
event_list.append(InotifyEvent(wd_dir,
- InotifyConstants.IN_CREATE |
- InotifyConstants.IN_ISDIR
- ,
- 0,
- dirname,
- full_path))
- for filename in filenames:
- full_path = absolute_path(
- os.path.join(root, filename))
- wd_parent_dir = self._wd_for_path[
- absolute_path(
- os.path.dirname(
- full_path))]
- event_list.append(
- InotifyEvent(wd_parent_dir,
- InotifyConstants.IN_CREATE
- ,
- 0,
- filename,
- full_path))
+ InotifyConstants.IN_CREATE | InotifyConstants.IN_ISDIR,
0, dirname, full_path))
+ except OSError:
+ pass
+ for filename in filenames:
+ full_path = absolute_path(os.path.join(root, filename))
+ wd_parent_dir =
self._wd_for_path[absolute_path(os.path.dirname(full_path))]
+ event_list.append(InotifyEvent(wd_parent_dir,
+ InotifyConstants.IN_CREATE, 0, filename, full_path))
return event_list
diff --git a/service.watchdog/lib/watchdog/observers/read_directory_changes.py
b/service.watchdog/lib/watchdog/observers/read_directory_changes.py
index b521973..7bb8b68 100644
--- a/service.watchdog/lib/watchdog/observers/read_directory_changes.py
+++ b/service.watchdog/lib/watchdog/observers/read_directory_changes.py
@@ -46,7 +46,9 @@ if platform.is_windows():
DEFAULT_OBSERVER_TIMEOUT,\
DEFAULT_EMITTER_TIMEOUT
from watchdog.events import\
+ DirCreatedEvent, \
DirMovedEvent,\
+ FileCreatedEvent,\
FileMovedEvent
@@ -85,7 +87,7 @@ if platform.is_windows():
dest_path = src_path
src_path = last_renamed_src_path
- if os.path.isdir(src_path):
+ if os.path.isdir(dest_path):
event = DirMovedEvent(src_path, dest_path)
if self.watch.is_recursive:
# HACK: We introduce a forced delay before
@@ -104,14 +106,21 @@ if platform.is_windows():
self.queue_event(sub_moved_event)
self.queue_event(event)
else:
- self.queue_event(FileMovedEvent(src_path,
- dest_path))
+ self.queue_event(FileMovedEvent(src_path, dest_path))
else:
if os.path.isdir(src_path):
- action_event_map = DIR_ACTION_EVENT_MAP
+ event = DIR_ACTION_EVENT_MAP[action](src_path)
+ if isinstance(event, DirCreatedEvent):
+ # If a directory is moved from outside the watched folder to
inside it
+ # we only get a created directory event out of it, not any
events for its children
+ # so use the same hack as for file moves to get the child
events
+ time.sleep(WATCHDOG_TRAVERSE_MOVED_DIR_DELAY)
+ sub_events = _generate_sub_created_events_for(src_path)
+ for sub_created_event in sub_events:
+ self.queue_event(sub_created_event)
+ self.queue_event(event)
else:
- action_event_map = FILE_ACTION_EVENT_MAP
- self.queue_event(action_event_map[action](src_path))
+ self.queue_event(FILE_ACTION_EVENT_MAP[action](src_path))
class WindowsApiObserver(BaseObserver):
@@ -124,3 +133,20 @@ if platform.is_windows():
BaseObserver.__init__(self,
emitter_class=WindowsApiEmitter,
timeout=timeout)
+
+def _generate_sub_created_events_for(src_dir_path):
+ """Generates an event list of :class:`DirCreatedEvent` and
:class:`FileCreatedEvent`
+ objects for all the files and directories within the given moved directory
+ that were moved along with the directory.
+
+ :param src_dir_path:
+ The source path of the created directory.
+ :returns:
+ An iterable of file system events of type :class:`DirCreatedEvent` and
+ :class:`FileCreatedEvent`.
+ """
+ for root, directories, filenames in os.walk(src_dir_path):
+ for directory in directories:
+ yield DirCreatedEvent(os.path.join(root, directory))
+ for filename in filenames:
+ yield FileCreatedEvent(os.path.join(root, filename))
-----------------------------------------------------------------------
Summary of changes:
service.watchdog/addon.xml | 5 ++-
service.watchdog/changelog.txt | 3 +
service.watchdog/core/polling.py | 37 +++++++++-------
service.watchdog/lib/watchdog/events.py | 12 ++---
service.watchdog/lib/watchdog/observers/inotify.py | 46 +++++++------------
.../watchdog/observers/read_directory_changes.py | 38 ++++++++++++++---
6 files changed, 80 insertions(+), 61 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons