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

[0.21.4] client.list returns Value Error because date format does not match on Windows #170

Open
looopTools opened this issue Dec 1, 2023 · 4 comments

Comments

@looopTools
Copy link

I get the following error:

ValueError: ('All parsers failed to parse', b'06-07-22  12:55PM               334976 opencv_frame_2.png\r\n', [KeyError('6-'), ValueError("time data '06-07-22 12:55PM' does not match format '%m/%d/%Y %I:%M %p'")])

I can replicate it with this simple test application.

import asyncio
import aioftp
import os 

async def test():
    client = aioftp.Client()
    await client.connect(host='127.0.0.1', port=21)
    await client.login(user=os.environ['ftpusr'], password=os.environ['ftppass'])
    l = await client.list('/')
    print(l)


if __name__ == '__main__':
    asyncio.run(test())

My suspicion is that it is because the parser expect a US date and not a european date?

@pohmelie
Copy link
Collaborator

pohmelie commented Dec 1, 2023

All LIST outputs are for humans, they have no standard and they will be broken somehow all the time. What you can do here:

  • Use your own parse_list_line_custom routine
  • Add code to aioftp windows parser
  • Update your ftp server to support MLSx commands family

@attilaolah
Copy link

parse_list_line_custom is a good and relatively simple workaround, however it would be even more convenient if we could simply pass in an expected timestamp format through init, then one would not need to re-implement the entire line parsing function.

I'm all for implementing MLSx commands but having a quick workaround would also be much appreciated.

@attilaolah
Copy link

Would you be willing to accept a pull request that adds a way to override the default timestamp format in aioftp.Client via either an init parameter or an attribute?

@pohmelie
Copy link
Collaborator

Would you be willing to accept a pull request that adds a way to override the default timestamp format in aioftp.Client via either an init parameter or an attribute?

Not sure this is a good idea to have multiple ways to do same thing. As I said above «All LIST outputs are for humans, they have no standard and they will be broken somehow all the time». So the most powerfull and common solution is available already.

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

3 participants