BlogMatrix
 

watch.py: a nicer interface for pyinotify

edit David P. Janes 2007-12-05 23:05 UTC add comment  ·

Via Noah Gift at O'Reilly, I've just found out about pyinotify a filesystem event listener (for Linux kernels after 2.6.13). BlogMatrix (and hence Onaswarm, etc.) has great interest in this sort of thing since a lot of our code is built around queuing information through the filesystem.

The main issue I have is that, well, it's a little too complicated for what I would consider to be the common use case. After a little thinking, I've made a Pythonic iterator wrapper which I'm going to submit to Sébastien Martini for inclusion in the code base so that people can write code like this:

import pyinotify
for event in pyinotify.watch("/tmp", "/var/tmp", create = True, delete = True):
   print event

I've attached the code to this posting if anyone would like to give it a try. Hmmm ... the attachment isn't working properly, try this.

Attached Documents:

Almost Universal Microformats Parser and hResume

edit David P. Janes 2006-09-16 20:21 UTC 15 comments  ·  ·  ·

Once of the projects we've been persuing over the last year is the "Almost Universal Microformats Parser", a Python library that does a pretty good job of breaking apart microformats. You can run the AUMFP against any webpage here or download (currently an old version of) the source here.

We've made quite a few modifications in the last two weeks and we're getting ready to release a new version of the source and also a few tools based on this project. We'll wait till we have more documentation and testing in place before we do the release though. We do the include-pattern thingie now and the interface makes a lot more sense.

As part of the update, we've extended the parser to handle hResume and tested against the samples pointed to on the Wiki. We also tried to identify places where documents don't conform to the proposed standard and document them as quirks (in general, we write our software to fail-as-last-resort). Here's the results of our testing:

Note that the "contact" quirk may be a misinterpretation on my part.

Internals: pinging, "stealth saves"

edit David P. Janes 2006-09-03 23:38 UTC add comment  ·  ·  ·

We've changed bm_disk_entry.DiskEntry.Save to add a new parameter: "stealth".

  • by default, stealth = False
  • if stealth = True when saving:
    • no monitors are notified of changes
    • the mtime and atime of the "index.pyd" files are preserved
    • timestamps are not updated
  • the purpose is to allow writing scratch-pad or administrive information without triggering unnecessary workflow. For example:
    • when recording that "ping" was sent
    • when recording that an email was sent
  • to support pings, we've added two more functions to DiskEntry
    • SetPing(ping_service, data)
    • GetPing(ping_service)

New "timeline-api.js" for SIMILE Timeline

edit David P. Janes 2006-07-12 18:34 UTC add comment  ·  ·

As mentioned before, I think the Timeline Javascript should be Initializable. And since I see the need, who better to do it than I?

I've attached a new version of timeline-api.js to this posting. It has an initialization function that one can pass in a urlPrefix parameter (and hopefully more if the SIMILE folks pick it up):

<script type="text/javascript" src="http://www.example.com/timeline-api.js">
<script type="text/javascript">
Timeline.Initialize({
    urlPrefix : "http://simile.mit.edu/timeline/api/"
})
</script>
 

Attached Documents: