Closed Eric-Vignola closed 3 years ago
More information need: code to reproduce and traceback.
Modified the example in README.rst
Using an existing server, fill in the details for host, login, password and port.
` import asyncio, aioftp
async def get_mp3(host, port, login, password): async with aioftp.Client.context(host, port, login, password) as client: for path, info in (await client.list(recursive=True)): if info["type"] == "file" and path.suffix == ".mp3": await client.download(path)
tasks = ( asyncio.create_task(get_mp3("MY_SERVER_IP", 22, "MY_LOGIN", "MY_PASSWORD")) ) asyncio.run(asyncio.wait(tasks)) `
Traceback error:
Traceback (most recent call last):
File "C:\async_test.py", line 17, in
Sorry pressed close by mistake and before finishing.
MY_SERVER_IP, MY_LOGIN and MY_PASSWORD are filled out with my server details.
This is essentially the example edited to connect to my server. In my IDE (Wing) i see client.list and client.download as undefined attributes, which may or may not be related to the traceback error i posted above.
Oh, example code was modified by @decaz in recent pull request. I will fix them soon. In short, code should look as:
import asyncio
import aioftp
async def get_mp3(host, port, login, password):
async with aioftp.Client.context(host, port, login, password) as client:
for path, info in (await client.list(recursive=True)):
if info["type"] == "file" and path.suffix == ".mp3":
await client.download(path)
async def main():
tasks = (
asyncio.create_task(get_mp3("server1.com", 21, "login", "password")),
asyncio.create_task(get_mp3("server2.com", 21, "login", "password")),
asyncio.create_task(get_mp3("server3.com", 21, "login", "password")),
)
await asyncio.wait(tasks)
asyncio.run(main())
Ah, didn't notice that asyncio.run
is getting asyncio.wait
directly, sorry.
Python 3.9 (win32) asyncio-3.4.3 aioftp-0.18.1
Just trying out aioftp following the example. Seems like list and download are undefined attributes of client.