I am using pysftp to access files on SFTP. But I want to get the last modified date of these files and store it in mongo. This is to access the date again next time I run the code. I cannot find a function that returns me the date of the file.
class My_Connection(pysftp.Connection):
def __init__(self, *args, **kwargs):
try:
if kwargs.get('cnopts') is None:
kwargs['cnopts'] = pysftp.CnOpts()
except pysftp.HostKeysException as e:
self._init_error = True
raise paramiko.ssh_exception.SSHException(str(e))
else:
self._init_error = False
self._sftp_live = False
self._transport = None
super().__init__(*args, **kwargs)
def __del__(self):
if not self._init_error:
self.close()
This is my connection class.
How can I get the date of the file that I am accessing.
Thanks.