小编Jad*_*Lee的帖子

使用python的看门狗从Linux监视afp共享文件夹

我希望linux机器(Raspberry pi)通过AFP监视共享文件夹(Apple文件协议,macbook是主机)。

我可以通过mount_afp挂载共享文件夹,并安装看门狗python库来监视共享文件夹。问题是看门狗只能监视来自Linux机器本身的修改。

如果监视文件夹已由主机(Apple Macbook)或其他PC修改,则linux机器无法找到更改。没有日志出来。

在主机(Apple Macbook)上测试了相同的看门狗python文件后,我可以获取其他计算机所做的修改日志。

主机可以获取文件或文件夹的所有修改。但是其他计算机(来宾计算机)无法监视主机或其他设备对文件的修改。

看门狗是否正常?还是帐户和权限有问题?

这是看门狗样本。

  import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler


class Watcher:
    DIRECTORY_TO_WATCH = "/path/to/my/directory"

    def __init__(self):
        self.observer = Observer()

    def run(self):
        event_handler = Handler()
        self.observer.schedule(event_handler, self.DIRECTORY_TO_WATCH, recursive=True)
        self.observer.start()
        try:
            while True:
                time.sleep(5)
        except:
            self.observer.stop()
            print "Error"

        self.observer.join()


class Handler(FileSystemEventHandler):

    @staticmethod
    def on_any_event(event):
        if event.is_directory:
            return None

        elif event.event_type == 'created':
            # Take any action here when a file is first created.
            print "Received created event - %s." % event.src_path …
Run Code Online (Sandbox Code Playgroud)

python linux afp watchdog raspberry-pi

3
推荐指数
1
解决办法
2068
查看次数

标签 统计

afp ×1

linux ×1

python ×1

raspberry-pi ×1

watchdog ×1