Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect st_mtime of folder #1514

Open
dylanlogann opened this issue Oct 1, 2019 · 0 comments
Open

Incorrect st_mtime of folder #1514

dylanlogann opened this issue Oct 1, 2019 · 0 comments

Comments

@dylanlogann
Copy link

Hi,

I am using Python to see how long a folder has been in my SFTP for, we have another process that parses the documents in these folders and deletes them, however if it fails to parse a single document or more, the folder won't be deleted.

So I am trying to create a report based on this statistic, and I am using .stat(folder path).st_mtime to get the modified time of the folder, however this returns a timestamp of: 2416060652, which if you translate, becomes: 2046-07-24 16:57:32

This time is the same for every folder in the SFTP (and I know they're all different)

The time on the SFTP server is correct, and the time on filezilla is showing correct.

Can anyone please help me understand why I am getting an incorrect (& constant) timestamp?

Cheers.

Code:

import os, sys, paramiko
from datetime import datetime

sys.path.insert(0, 'Utils')
import ReportUtils

sftpConnection = ReportUtils.__connectSFTP()

EDM = 'EDM'

sftpFolders = ReportUtils.getSFTPContents(EDM)

for sftpFolder in sftpFolders:
    sftpFolderPath = '/%s/%s' % (EDM, sftpFolder)
    sftpFolderAdded = sftpConnection.stat(sftpFolderPath).st_mtime
    print sftpFolderPath, sftpFolderAdded, datetime.fromtimestamp(sftpFolderAdded)

Output:

/EDM/02 20191001_110045 Folder_6_20191001105936_1131008001_[224 files] 2416060652 2046-07-24 16:57:32
/EDM/03 20190928_153952 File_9_20190924165437_9999999999_[8408 files] 2416060652 2046-07-24 16:57:32
/EDM/04 20190924_103559 File_9_20190924091126_9999999999_[9026 files] 2416060652 2046-07-24 16:57:32
/EDM/04 20190924_104533 File_9_20190924091126_9999999999_[9026 files] 2416060652 2046-07-24 16:57:32
/EDM/04 20190924_105523 File_9_20190924091126_9999999999_[9026 files] 2416060652 2046-07-24 16:57:32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant