get todays files

2008-12-10 Thread Andrew D
I have a script that will login to my ftp server and download all the
backup files, but I want it to only download the files that were
created today, e.g. if I ran the script today I want it to only fetch
files created today.

I am really not sure about how to do this, but it is quite important
to me, so all help is highly appreciated!

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew D
On Dec 10, 5:55 pm, Steve Holden [EMAIL PROTECTED] wrote:
 Andrew D wrote:
  I have a script that will login to my ftp server and download all the
  backup files, but I want it to only download the files that were
  created today, e.g. if I ran the script today I want it to only fetch
  files created today.

  I am really not sure about how to do this, but it is quite important
  to me, so all help is highly appreciated!

 IIRC there's an ftpmirror script in the Tools directory (if you're on
 Windows - Linux/Unix users have to download the source). I adapted it to
 several different purposes.

 regards
  Steve
 --
 Steve Holden        +1 571 484 6266   +1 800 494 3119
 Holden Web LLC              http://www.holdenweb.com/

Thanks Steve,

I don't want to sound rude here, but I really want some code to add to
my script so that it will only download todays files.

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew D
On Dec 10, 6:13 pm, Steve Holden [EMAIL PROTECTED] wrote:
 Andrew D wrote:
  On Dec 10, 5:55 pm, Steve Holden [EMAIL PROTECTED] wrote:
  Andrew D wrote:
  I have a script that will login to my ftp server and download all the
  backup files, but I want it to only download the files that were
  created today, e.g. if I ran the script today I want it to only fetch
  files created today.
  I am really not sure about how to do this, but it is quite important
  to me, so all help is highly appreciated!
  IIRC there's an ftpmirror script in the Tools directory (if you're on
  Windows - Linux/Unix users have to download the source). I adapted it to
  several different purposes.

  Thanks Steve,

  I don't want to sound rude here, but I really want some code to add to
  my script so that it will only download todays files.

 That's OK. Maybe somebody's already got that code ready to go. I don't ...

 regards
  Steve
 --
 Steve Holden        +1 571 484 6266   +1 800 494 3119
 Holden Web LLC              http://www.holdenweb.com/

Thank you anyway Steve!

Lets hope someone has the code ;)

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew D
On Dec 10, 6:55 pm, Tim Chase [EMAIL PROTECTED] wrote:
  I have a script that will login to my ftp server and download
  all the backup files, but I want it to only download the files
  that were created today, e.g. if I ran the script today I want
  it to only fetch files created today.

 Use Python's ftp module and send the MDTM command to get back the
 timestamp of the filename.  Insecurely, this would look something
 like

    from ftplib import FTP
    hostname = ftp.mozilla.org
    conn = FTP(hostname)
    user = anonymous
    password = [EMAIL PROTECTED]
    conn.login(user, password)
    filename = pub/README
    results = conn.sendcmd(MDTM %s % filename)
    code, stamp = results.split(None, 1)
    assert code == 213, Unexpected result
    print %s was modified on %s % (filename, stamp)
    today = '20081210'
    if stamp[:8] == today:
      process(filename)
    else:
      print ignoring, filename

 The MDTM command is not part of the core RFC-959, but rather the
 RFC-3659[1] so you might run across some servers that don't
 support it.  You can read more about the Python ftplib module at
 [2] which would be where you want to read up on pulling back a
 listing of the directory of file-names to check.  There is a NLST
 command (I don't have a server handy that supports this command).
   The LIST command returns pretty/readable information that's not
 quite so machine-parsing friendly (at least in a cross-FTP-server
 sort of way).  However, that part, I leave as an exercise for the
 reader along with the complications of the today bit.

 Oh, SteveH, I checked your FTP-cloning source in my Python dir,
 and it doesn't look like it does anything regarding file-times in
 it, so that may have been a red-herring.  Unless you've added
 something since the ver. I've got here.

 -tkc

 [1]http://en.wikipedia.org/wiki/List_of_FTP_commands

 [2]http://www.python.org/doc/2.5.2/lib/ftp-objects.html

This looks very good and I have tested successfully, but is there a
way I can set the today to automatically become todays date in that
format?

Thanks though, this is what I was looking for!

Andrew
--
http://mail.python.org/mailman/listinfo/python-list