-
Notifications
You must be signed in to change notification settings - Fork 165
[1LP][RFR] Fix ftp failures due to year change #9810
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valaparthvi thank for quick catch.
I think lets check first its back year file or not as per that we will put year
yr = datetime.now().year if ":" in fields[-2] else fields[-2]
time = fields[-2] if ":" in fields[-2] else "00:00"
date = strptime(f"{yr} {fields[-4]} {fields[-3]} {time}", "%Y %b %d %H:%M")
cfme/utils/ftp.py
Outdated
f"{datetime.now().year} {fields[-4]} {fields[-3]} {fields[-2]}", | ||
"%Y %b %d %H:%M", | ||
) | ||
except ValueError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't this ValueError
handling is better way.
As per my observation. when ftp file/dir
created in back year then it will remove time
and put year
.
cfme/utils/ftp.py
Outdated
"%Y %b %d %H:%M", | ||
) | ||
except ValueError: | ||
date = strptime(f"{datetime.now().year} {fields[-4]} {fields[-3]}", "%Y %b %d") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your taking current year here i.e 2020
for last year; which is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @digitronik Just curious :)
- I can see 2020 year for all the files uploaded as below:
In [9]: fs.ls()
Out[9]:
[(False, 'bz_1364407.zip', datetime.datetime(2020, 12, 19, 7, 30)),
(False, 'bz_1440226.zip', datetime.datetime(2020, 10, 9, 4, 34)),
(False, 'bz_1558926.yml', datetime.datetime(2020, 11, 7, 3, 11)),
(False, 'bz_1558926.zip', datetime.datetime(2020, 11, 7, 1, 30)),
(False, 'bz_1559999.zip', datetime.datetime(2020, 12, 19, 2, 40)),
(False, 'bz_1570152.yml', datetime.datetime(2020, 9, 13, 5, 18)),
(False, 'bz_1570152.zip', datetime.datetime(2020, 9, 13, 3, 30)),
(False, 'bz_1571000.yml', datetime.datetime(2020, 10, 24, 4, 24)),
(False, 'bz_1571000.zip', datetime.datetime(2020, 10, 24, 4, 23)),
(False, 'bz_1576107.zip', datetime.datetime(2020, 12, 19, 8, 27)),
(False, 'bz_1613443.yml', datetime.datetime(2020, 11, 21, 0, 6)),
(False, 'bz_1613443.zip', datetime.datetime(2020, 11, 21, 0, 7)),
(False, 'bz_1614436.yml', datetime.datetime(2020, 9, 18, 6, 42)),
.....
- But most of these added in 2019. So why it is not showing exact date of that file uploaded(only about old files otherwise current files are taking expected datetime)?
- Otherwise looks good to me :)
@ganeshhubale this is due to time is available for those file and no year.
|
Purpose or Intent
FTPClient.ls()
which in my opinion is failing due to the change in year.Normal lines
-rwxrwxrwx 1 ftp ftp 1602 Jul 25 05:02 filter_report.yaml
Changed lines
-rwxrwxrwx 1 ftp ftp 1361 Jun 10 2019 import_report.yaml
Error: