[IMP] server: dev mode - manage the case where editor use atomic mode to save

Some editors save file in mode atomic and consequently make a move from
temp file into dest file instead of modified the src file.
Now we manage the both cases:
   ModifiedFile: if editor don't use atomic mode
   MovedFile: if editor use atomic mode.
This commit is contained in:
Jeremy Kersten
2015-02-16 16:32:31 +01:00
parent 0d18132b11
commit 3b2f65407b
+3 -3
View File
@@ -46,7 +46,7 @@ _logger = logging.getLogger(__name__)
try:
import watchdog
from watchdog.observers import Observer
from watchdog.events import FileCreatedEvent, FileModifiedEvent
from watchdog.events import FileCreatedEvent, FileModifiedEvent, FileMovedEvent
except ImportError:
watchdog = None
@@ -124,9 +124,9 @@ class FSWatcher(object):
self.observer.schedule(self, path, recursive=True)
def dispatch(self, event):
if isinstance(event, (FileCreatedEvent, FileModifiedEvent)):
if isinstance(event, (FileCreatedEvent, FileModifiedEvent, FileMovedEvent)):
if not event.is_directory:
path = event.src_path
path = getattr(event, 'dest_path', event.src_path)
if path.endswith('.py'):
try:
source = open(path, 'rb').read() + '\n'