Re: Recognizing the Arrival of a New File
On Tue, Mar 08, 2005 at 08:43:04AM -0600, Greg Lindstrom wrote: > I am writing an application where I need to recognize when a file > arrives in a given directory. Files may arrive at any time during the > course of the day. Do I set up a cron job to poll the directory every > few minutes? Write a daemon to monitor the directory? Or is there some > other more common/accepted way to perform this task? I'm using Python > 2.3 on Linux. you could use dnotify; unfortunately although the fcntl wrapper in python would suffice, there is AFAIK no way to do sigaction. Fortunately there is a dnotify program which is easy enough to use, both from python or directly. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: 2fort5 sucks enough to have its own gravity ... signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Recognizing the Arrival of a New File
Greg Lindstrom <[EMAIL PROTECTED]> writes: > Hello- > I am writing an application where I need to recognize when a file > arrives in a given directory. Files may arrive at any time during the > course of the day. Do I set up a cron job to poll the directory every > few minutes? Write a daemon to monitor the directory? Or is there some > other more common/accepted way to perform this task? I'm using Python > 2.3 on Linux. At my last job, we had a similar problem and I wanted to be able to check that the file was closed by the application that was putting it there (in that case the application was w32 writing to a share via samba). http://cmg.dok.org/cgi-bin/pyblosxom.cgi/python/linuxlease/ Every other way I could find that relied on simple FS semantics had the possibility of reading a file partially. -- Chris Green <[EMAIL PROTECTED]> Eschew obfuscation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Recognizing the Arrival of a New File
On Tue, 08 Mar 2005 08:43:04 -0600, rumours say that Greg Lindstrom <[EMAIL PROTECTED]> might have written: >I am writing an application where I need to recognize when a file >arrives in a given directory. Files may arrive at any time during the >course of the day. Do I set up a cron job to poll the directory every >few minutes? Write a daemon to monitor the directory? Or is there some >other more common/accepted way to perform this task? I'm using Python >2.3 on Linux. The most common way to watch for a file or a directory change (in my experience) is to use the SGI fam (file alteration monitor); I think it has been ported to Linux. Otherwise, either way you describe is common use. Suggestion: first check for changes in the st_mtime of the directory, then search for the file existence. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
RE: Recognizing the Arrival of a New File
Title: RE: Recognizing the Arrival of a New File [Greg Lindstrom] #- I am writing an application where I need to recognize when a file #- arrives in a given directory. Files may arrive at any time #- during the #- course of the day. Do I set up a cron job to poll the #- directory every #- few minutes? Write a daemon to monitor the directory? Or #- is there some #- other more common/accepted way to perform this task? I'm #- using Python #- 2.3 on Linux. You can check the date info of the directory: [EMAIL PROTECTED] ~> ll -d gsm drwxr-xr-x 3 fbatista root 4096 feb 25 2004 gsm [EMAIL PROTECTED] ~> cd gsm [EMAIL PROTECTED] ~/gsm> touch w [EMAIL PROTECTED] ~/gsm> cd .. [EMAIL PROTECTED] ~> ll -d gsm drwxr-xr-x 3 fbatista root 4096 mar 8 12:15 gsm Regards, . Facundo Bitácora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://pyar.decode.com.ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley. Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje. Muchas Gracias. -- http://mail.python.org/mailman/listinfo/python-list
Recognizing the Arrival of a New File
Hello- I am writing an application where I need to recognize when a file arrives in a given directory. Files may arrive at any time during the course of the day. Do I set up a cron job to poll the directory every few minutes? Write a daemon to monitor the directory? Or is there some other more common/accepted way to perform this task? I'm using Python 2.3 on Linux. Thanks for your help, --greg -- Greg Lindstrom 501 975.4859 Computer Programmer [EMAIL PROTECTED] NovaSys Health Little Rock, Arkansas "We are the music makers, and we are the dreamers of dreams." W.W. -- http://mail.python.org/mailman/listinfo/python-list