Dropbox 和 pyinotify

发布于 2024-09-25 08:57:55 字数 3654 浏览 1 评论 0原文

我刚买了一台 iPad,然后愚蠢地得到了 TexTouch 应用程序。愚蠢的是,由于Apple的规定,TexTouch无法编译Tex。它使用Dropbox将.tex文件同步到计算机。在远程计算机上,它被另一个程序捕获,该程序将 .tex 文件编译为 PDF 并将其发送回。但是(令人惊讶!)那个远程程序仅适用于 Windows 和 Mac。而且我在 Linux 上。所以我想,为什么不使用inotify呢?为了让事情变得更简单,我实际上使用了 pyinotify,这样我就不必处理大量的编译。但是,当 Dropbox 删除文件时,用 pyinotify 的话说,以下是发生的事件。 (显然,“first doc.tex”是我正在同步的文件的名称。)

event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event cookie=151401 dir=False mask=0x40 maskname=IN_MOVED_FROM name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event cookie=151402 dir=False mask=0x80 maskname=IN_MOVED_TO name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x4 maskname=IN_ATTRIB name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >

我能用它来做什么?唯一看起来唯一的事件是 IN_MOVE_FROM 和 IN_MOVE_TO 事件。但监控这些看起来是个坏主意。有没有办法检测 Dropbox 发起的事件?我应该使用 inotify 或 pyinotify 以外的其他东西吗?

I just got an iPad and I foolishly got the TexTouch application. Foolishly, because due to Apple regulation, TexTouch can't compile Tex. It syncs the .tex file to a computer using Dropbox. On the distant computer, it gets caught by another program that compiles the .tex file to PDF and sends it back. But (surprise!) that distant program in Windows and Mac only. And I'm on Linux. So I thought, why not use inotify? To make things a bit simpler, I actually used pyinotify so I wouldn't have to deal with tons of compilation. BUT when Dropbox drops a file, here are, in pyinotify vernacular, the events that happen. (Obviously, "first doc.tex" is the name of the file I'm syncing.)

event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event cookie=151401 dir=False mask=0x40 maskname=IN_MOVED_FROM name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event cookie=151402 dir=False mask=0x80 maskname=IN_MOVED_TO name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x4 maskname=IN_ATTRIB name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x20 maskname=IN_OPEN name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x1 maskname=IN_ACCESS name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >
event: <Event dir=False mask=0x10 maskname=IN_CLOSE_NOWRITE name=first doc.tex path=/home/eje211/Dropbox/TexTouch pathname=/home/eje211/Dropbox/TexTouch/first doc.tex wd=1 >

What can I make of that? The only events that appear to be unique are the IN_MOVE_FROM and IN_MOVE_TO events. But it looks like a BAD idea to monitor those. Is there a way to detect an event that is initiated by Dropbox? Should I use something other than inotify or pyinotify?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朱染 2024-10-02 08:57:55

好吧,IN_OPEN(打开文件以供读取)、IN_ACCESS(文件已访问)和IN_ATTRIB(已修改文件属性)显然不是您所需要的。 IN_CLOSE_NOWRITE 表示该文件已关闭以供读取(即无法进行任何更改),因此这也不是您所需要的。因此它必须是 IN_MOVED_FROMIN_MOVED_TO
您确定没有其他事件发生吗?
如果是,那么该文件可能正在其他地方创建,然后被移动到其最终位置 ~/Dropbox

Well, IN_OPEN (file opened for reading), IN_ACCESS (file accessed) and IN_ATTRIB (file attributes modified) are obviously not what you need. IN_CLOSE_NOWRITE means that the file has been closed for reading (i.e. no changes could have been made), so that's also not what you need. So it'll have to be either IN_MOVED_FROM or IN_MOVED_TO.
Are you sure there are no other events happening whatsoever?
If you are, then the file is probably being created somewhere else and then being moved to its final location at ~/Dropbox.

蓝天白云 2024-10-02 08:57:55

我有一个正在监视 IN_MOVED_TO 的脚本。每当 Dropbox 删除新文件时,就会触发该文件。您应该使用 IN_MOVED_TO。

<Event cookie=63896 dir=False mask=0x80 maskname=IN_MOVED_TO name=test.zip path=/home/bpotter/Dropbox/Apps/Backup pathname=/home/bpotter/Dropbox/Apps/Backup/test.zip wd=1 >

I got a script working that watches for IN_MOVED_TO. Whenever Dropbox drops a new file, it is triggered. You should use IN_MOVED_TO.

<Event cookie=63896 dir=False mask=0x80 maskname=IN_MOVED_TO name=test.zip path=/home/bpotter/Dropbox/Apps/Backup pathname=/home/bpotter/Dropbox/Apps/Backup/test.zip wd=1 >
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文