Hi, On 26 June 2014 19:40, Albert-Jan Roskam <[email protected]> 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)
Parsing command line output is arguably generally (more) brittle and prone to breakage than coding to a direct API/library -- Paramiko & friends give you a proper programming API to code against with direct/native access to object properties. A file modification date and time (for example) from a shell command command is a string that then must be parsed/interpreted. This might be subject to locale format, command/shell settings and who knows what else. By contrast a "stat" result is a more well defined entity with unambiguous contents, completely removing having to guess/parse text. IMVHO much more preferable. :) Walter _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
