Hi, I would recommend you to migrate your Python version for a newer one where you can use fabric, paramiko or other ssh tools. It would be easier.
I would recommend also instead of doing an "ls -l" command doing something to retrieve only the information you need: /bin/ls -ls | awk '{print $7,$8,$9, $10}' Jun 27 10:36 my_file Then I would use timedelta instead where you can be more accurate with the dates (in the example if the file is older than 62 days): def too_old(text): month, day, year = (text[0], text[1], text[2] if ':' not in text[2] else datetime.datetime.now().year) time_difference = datetime.datetime.now() - datetime.datetime.strptime( "{0}{1}{2}".format(month, day, year), '%b%d%Y') return time_difference > datetime.timedelta(days=62) Thanks, Raúl On Thu, Jun 26, 2014 at 7:40 PM, Albert-Jan Roskam < fo...@yahoo.com.dmarc.invalid> wrote: > <snip> > > > > I'd probably rather try Paramiko's SFTPClient and retrieve the file > > > modified date directly: > > > http://paramiko-docs.readthedocs.org/en/latest/api/sftp.html#paramiko.sftp_client.SFTPClient > > (see the SFTPFile.stat() method in particular, which gives you back a > > stat object containing mtime, the modification datetime IIRC) > > > > 2 more (hopefully) useful links if you decide to go this route: > > http://www.saltycrane.com/blog/2010/02/python-paramiko-notes/ > > > http://jessenoller.com/blog/2009/02/05/ssh-programming-with-paramiko-completely-different > > Interesting. Question: what is the added value of paramiko compared to > using subprocess to use ssh (ie, shell commands)? (Possible answer: it is > platform-independent) > > Regards, > Albert-Jan > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Raúl Cumplido
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor