Debian Codegraph @

README.rst

raw
1 .. aioftp documentation master file, created by
2 sphinx-quickstart on Fri Apr 17 16:21:03 2015.
3 You can adapt this file completely to your liking, but it should at least
4 contain the root `toctree` directive.
5
6 aioftp
7 ======
8
9 .. image:: https://github.com/aio-libs/aioftp/actions/workflows/ci-cd.yml/badge.svg?branch=master
10 :target: https://github.com/aio-libs/aioftp/actions/workflows/ci-cd.yml
11 :alt: Github actions ci-cd for master branch
12
13 .. image:: https://codecov.io/gh/aio-libs/aioftp/branch/master/graph/badge.svg
14 :target: https://codecov.io/gh/aio-libs/aioftp
15
16 .. image:: https://img.shields.io/pypi/v/aioftp.svg
17 :target: https://pypi.python.org/pypi/aioftp
18
19 .. image:: https://img.shields.io/pypi/pyversions/aioftp.svg
20 :target: https://pypi.python.org/pypi/aioftp
21
22 .. image:: https://pepy.tech/badge/aioftp/month
23 :target: https://pypi.python.org/pypi/aioftp
24
25 ftp client/server for asyncio (https://aioftp.rtfd.io)
26
27 .. _GitHub: https://github.com/aio-libs/aioftp
28
29 Features
30 --------
31
32 - Simple.
33 - Extensible.
34 - Client socks proxy via `siosocks <https://github.com/pohmelie/siosocks>`_
35 (`pip install aioftp[socks]`).
36
37 Goals
38 -----
39
40 - Minimum usable core.
41 - Do not use deprecated or overridden commands and features (if possible).
42 - Very high level api.
43
44 Client use this commands: USER, PASS, ACCT, PWD, CWD, CDUP, MKD, RMD, MLSD,
45 MLST, RNFR, RNTO, DELE, STOR, APPE, RETR, TYPE, PASV, ABOR, QUIT, REST, LIST
46 (as fallback)
47
48 Server support this commands: USER, PASS, QUIT, PWD, CWD, CDUP, MKD, RMD, MLSD,
49 LIST (but it's not recommended to use it, cause it has no standard format),
50 MLST, RNFR, RNTO, DELE, STOR, RETR, TYPE ("I" and "A"), PASV, ABOR, APPE, REST
51
52 This subsets are enough for 99% of tasks, but if you need something, then you
53 can easily extend current set of commands.
54
55 Server benchmark
56 ----------------
57
58 Compared with `pyftpdlib <https://github.com/giampaolo/pyftpdlib>`_ and
59 checked with its ftpbench script.
60
61 aioftp 0.8.0
62
63 ::
64
65 STOR (client -> server) 284.95 MB/sec
66 RETR (server -> client) 408.44 MB/sec
67 200 concurrent clients (connect, login) 0.18 secs
68 STOR (1 file with 200 idle clients) 287.52 MB/sec
69 RETR (1 file with 200 idle clients) 382.05 MB/sec
70 200 concurrent clients (RETR 10.0M file) 13.33 secs
71 200 concurrent clients (STOR 10.0M file) 12.56 secs
72 200 concurrent clients (QUIT) 0.03 secs
73
74 aioftp 0.21.4 (python 3.11.2)
75
76 ::
77
78 STOR (client -> server) 280.17 MB/sec
79 RETR (server -> client) 399.23 MB/sec
80 200 concurrent clients (connect, login) 0.22 secs
81 STOR (1 file with 200 idle clients) 248.46 MB/sec
82 RETR (1 file with 200 idle clients) 362.43 MB/sec
83 200 concurrent clients (RETR 10.0M file) 5.41 secs
84 200 concurrent clients (STOR 10.0M file) 2.04 secs
85 200 concurrent clients (QUIT) 0.04 secs
86
87 pyftpdlib 1.5.2
88
89 ::
90
91 STOR (client -> server) 1235.56 MB/sec
92 RETR (server -> client) 3960.21 MB/sec
93 200 concurrent clients (connect, login) 0.06 secs
94 STOR (1 file with 200 idle clients) 1208.58 MB/sec
95 RETR (1 file with 200 idle clients) 3496.03 MB/sec
96 200 concurrent clients (RETR 10.0M file) 0.55 secs
97 200 concurrent clients (STOR 10.0M file) 1.46 secs
98 200 concurrent clients (QUIT) 0.02 secs
99
100 Dependencies
101 ------------
102
103 - Python 3.10+
104
105 0.13.0 is the last version which supports python 3.5.3+
106
107 0.16.1 is the last version which supports python 3.6+
108
109 0.21.4 is the last version which supports python 3.7+
110
111 0.22.3 is the last version which supports python 3.8+
112
113 0.26.3 is the last version which supports python 3.9+
114
115 License
116 -------
117
118 aioftp is offered under the Apache 2 license.
119
120 Library installation
121 --------------------
122
123 ::
124
125 pip install aioftp
126
127 Getting started
128 ---------------
129
130 Client example
131
132 **WARNING**
133
134 For all commands, which use some sort of «stats» or «listing», ``aioftp`` tries
135 at first ``MLSx``-family commands (since they have structured, machine readable
136 format for all platforms). But old/lazy/nasty servers do not implement this
137 commands. In this case ``aioftp`` tries a ``LIST`` command, which have no
138 standard format and can not be parsed in all cases. Take a look at
139 `FileZilla <https://svn.filezilla-project.org/filezilla/FileZilla3/trunk/src/engine/directorylistingparser.cpp?revision=7322&view=markup>`_
140 «directory listing» parser code. So, before creating new issue be sure this
141 is not your case (you can check it with logs). Anyway, you can provide your own
142 ``LIST`` parser routine (see the client documentation).
143
144 .. code-block:: python
145
146 import asyncio
147 import aioftp
148
149
150 async def get_mp3(host, port, login, password):
151 async with aioftp.Client.context(host, port, login, password) as client:
152 for path, info in (await client.list(recursive=True)):
153 if info["type"] == "file" and path.suffix == ".mp3":
154 await client.download(path)
155
156
157 async def main():
158 tasks = [
159 asyncio.create_task(get_mp3("server1.com", 21, "login", "password")),
160 asyncio.create_task(get_mp3("server2.com", 21, "login", "password")),
161 asyncio.create_task(get_mp3("server3.com", 21, "login", "password")),
162 ]
163 await asyncio.wait(tasks)
164
165 asyncio.run(main())
166
167 Server example
168
169 .. code-block:: python
170
171 import asyncio
172 import aioftp
173
174
175 async def main():
176 server = aioftp.Server([user], path_io_factory=path_io_factory)
177 await server.run()
178
179 asyncio.run(main())
180
181 Or just use simple server
182
183 .. code-block:: shell
184
185 python -m aioftp --help