Reputation: 1083
I have a file on the SFTP server that should be imported with paramiko package on certain conditions. Until these conditions aren't fulfilled, this file should stay on the server unimported, but its modified date shoud be updated, so that this date should be always bigger than the time, at which file was checked by my import program.
I read the documentation for the package but didn't found any function that could do this.
Upvotes: 0
Views: 1136
Reputation: 202168
There's the utime
method:
utime(path, times)
Set the access and modified times of the file specified by
path
. Iftimes
isNone
, then the file’s access and modified times are set to the current time. Otherwise,times
must be a 2-tuple of numbers, of the form(atime, mtime)
, which is used to set the access and modified times, respectively.
Upvotes: 2
Reputation: 5330
I would try opening the file in append mode ("a") and closing it immediately.
Upvotes: 0
Reputation: 1083
This can be done with copying the file from the SFTP to the local host, removing the file from the SFTP and copying it again to the SFTP.
So,
get(remotepath, localpath, callback=None)
remove(path)
put(localpath, remotepath, callback=None, confirm=True)
If anyone has another idea, please share your knowledge!
Upvotes: 0