diff --git a/docker_volume_watcher/call_debouncer.py b/docker_volume_watcher/call_debouncer.py index e4a2050..7217007 100644 --- a/docker_volume_watcher/call_debouncer.py +++ b/docker_volume_watcher/call_debouncer.py @@ -49,7 +49,6 @@ def __init__(self, callee, delay=0.1): self._worker.setDaemon(True) self._worker.start() - def __call__(self, *args, **kwargs): self._calls.put((time.time(), CallArgs(*args, **kwargs))) @@ -74,7 +73,7 @@ def _process_calls(self): def _remove_outdated(self, submit_time): while self._call_times: - cache_key, cache_time = next(iter(self._call_times.items())) # Pick first item + cache_key, cache_time = next(iter(self._call_times.items())) # Pick first item if submit_time < cache_time: break self._call_times.pop(cache_key) diff --git a/docker_volume_watcher/cli.py b/docker_volume_watcher/cli.py index 800aac0..9e051e6 100644 --- a/docker_volume_watcher/cli.py +++ b/docker_volume_watcher/cli.py @@ -1,5 +1,5 @@ """ -A tool to notify Docker contianers about changes in mounts on Windows. +A tool to notify Docker containers about changes in mounts on Windows. """ import argparse @@ -15,7 +15,7 @@ def main(): """ parser = argparse.ArgumentParser( - description='A tool to notify Docker contianers about changes in mounts on Windows.' + description='A tool to notify Docker containers about changes in mounts on Windows.' ) parser.add_argument('container_pattern', metavar='CONTAINER_PATTERN', type=str, default='*', nargs='?', help='pattern of container names to be notified (default: *)') @@ -50,5 +50,6 @@ def main(): monitor.unwatch_all() + if __name__ == "__main__": main() diff --git a/docker_volume_watcher/container_monitor.py b/docker_volume_watcher/container_monitor.py index 6c60845..a8762b7 100644 --- a/docker_volume_watcher/container_monitor.py +++ b/docker_volume_watcher/container_monitor.py @@ -15,7 +15,11 @@ def docker_bind_to_windows_path(path): """ - Converts Hyper-V mount path to Windows path (e.g. [/host_mnt]/C/some-path -> C:/some-path). + Converts Hyper-V mount path to Windows path (e.g. + [/host_mnt]/C/some-path -> C:/some-path + [/run/desktop/mnt/host]/C/some-path -> C:/some-path + C:\\some-path -> C:\\some-path + ). Args: path (str): Hyper-V mount path @@ -24,8 +28,8 @@ def docker_bind_to_windows_path(path): str: Converts Hyper-V mount path to Windows path (e.g. /C/some-path -> C:/some-path). """ - expr = re.compile('^(?:/host_mnt)?/([a-zA-Z])/(.*)$') - match = re.match(expr, path) + expr = re.compile(r'^(?:/host_mnt/|/run/desktop/mnt/host/)?([a-zA-Z]):?[/\\](.*)$') + match = expr.match(path) if not match: return None return '%s:\\%s' % match.groups() @@ -42,7 +46,6 @@ def __init__(self, container_name_pattern, host_dir_pattern, notifier_options=No Args: container_name_pattern (str): Container name pattern host_dir_pattern (str): Host directory pattern - exclude_patterns (list): List of file name patterns for which changes should be ignored notifier_options (NotifierOptions): options to be passed to each instance of ContainerNotifier """