[Tutor] Hot Folders?

Scott Ralph scott@zenplex.com
Tue, 24 Oct 2000 09:21:28 -0400


Daniel Yoo wrote:

> On Mon, 23 Oct 2000, Scott Ralph wrote:
>
> > I'd like to create a hot folder program in Python..  I'm still in the
> > learning stage so any help would be great.  Basically I would have a
> > folder on my server that if and when a file hits it it will do
> > something.. My problem is I'm not sure were to start.  How can I code
> > in my script a
> >
> > sort of watcher routine that will monitor this folder?  Also how can I
> > check if the file is actually done coping into the folder?
>
> Wow!  I've never done this before, so I don't know what's traditionally
> done to do monitoring.  One idea is to have your program sleep for a
> while, and then every once in a while, check to see if things in your
> directory are changing.  Here's some pseudocode:
>
>     dircontents = getDirContents()
>     while 1:
>         newcontents = getDirContents()
>         if dircontents != newcontents:
>             doSomething()
>             dircontents = newcontents
>         sleep(1000)
>
> This won't work unless we define getDirContents(), but that shouldn't be
> too bad.  You can do directory stuff with the 'os.path' module.  From a
> quick scanthrough, the 'dircache' module also looks useful for this stuff.
>
> This looks like an interesting program!  I hope this helps get you
> started.
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

Thanks for the input.  I was trying to use atime to check for status of a
file based on last access time and I was getting no where.   I was thinking
this >> If a file was being copied in I would check every 10sec if the file
is older then 10sec file copy complete.  Anyway thanks for the input this is
a start.  I will pass on my progress.
Thanks
Scott

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott Ralph
Zenplex, Inc.
317 Madison Ave
Suite 1500
New York,  NY 10017
212.499.0668
http://www.zenplex.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~