Wykres commitów

36 Commity (master)

Autor SHA1 Wiadomość Data
AuroraTea 2b0d7610ce aiohttp: Fix type of header's Sec-WebSocket-Key.
The function `binascii.b2a_base64()` returns a `bytes`, but here needs a
string.  Otherwise, the value of `Sec-WebSocket-Key` in the headers will be
`b'<BASE64-ENCODED_RANDOM_VALUE>'`.

Signed-off-by: AuroraTea <1352685369@qq.com>
2024-05-24 17:26:22 +10:00
Angus Gratton 00fc3fd37b all: Enable ruff E401 and E402 import lints.
Mostly small cleanups to put each top-level import on its own line.  But
explicitly disable the lint for examples/tests which insert the current
directory into the path before importing.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-05-17 17:06:33 +10:00
Angus Gratton 6c6fab1db1 all: Enable ruff F841 'Local variable is assigned to but never used'.
Most of these look like they were used for print debugging and then kept in
when the print statements were removed or commented.

Some look like missing or incomplete functionality, these have been marked
with comments where possible.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-05-15 18:05:21 +10:00
iabdalkader 8ee876dcd6 cbor2: Deprecate decoder and encoder modules.
Deprecate decoder and encoder modules to maintain compatibility with the
CPython cbor2 module.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-19 17:28:35 +11:00
Carlosgg 56f514f569 aiohttp: Fix binary data treatment.
- Fix binary data `Content-type` header and data `Content-Length`
  calculation.

- Fix query length when data is included.

- Fix `json` and `text` methods of `ClientResponse` to read
  `Content-Length` size

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2024-02-08 19:02:26 +11:00
Felix Dörre 35d41dbb0e ssl: Restructure micropython SSL interface to a new tls module.
MicroPython now supplies SSL/TLS functionality in a new built-in `tls`
module.  The `ssl` module is now implemented purely in Python, in this
repository.  Other libraries are updated to work with this scheme.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-07 12:12:13 +11:00
Carlosgg 7cdf708815 aiohttp: Add new aiohttp package.
Implement `aiohttp` with `ClientSession`, websockets and `SSLContext`
support.

Only client is implemented and API is mostly compatible with CPython
`aiohttp`.

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2023-12-20 16:26:04 +11:00
Jim Mussared cee0945f1c all: Replace "black" with "ruff format".
- Add config for [tool.ruff.format] to pyproject.toml.
- Update pre-commit to run both ruff and ruff-format.
- Update a small number of files that change with ruff's rules.
- Update CI.
- Simplify codeformat.py just forward directly to "ruff format"

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-12-20 11:56:24 +11:00
Brian Whitman e025c843b6 requests: Fix detection of iterators in chunked data requests.
Chunked detection does not work as generators never have an `__iter__`
attribute.  They do have `__next__`.

Example that now works with this commit:

    def read_in_chunks(file_object, chunk_size=4096):
        while True:
            data = file_object.read(chunk_size)
            if not data:
                break
            yield data

    file = open(filename, "rb")
    r = requests.post(url, data=read_in_chunks(file))
2023-10-05 10:42:14 +11:00
Angus Gratton 991ac986fd iperf3: Pre-declare some variables set in the loop.
This is a change just to make the linter happy, the code
probably would have run OK without it.

Found by Ruff checking F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-22 22:43:46 +10:00
Angus Gratton c6a72c70b9 cbor2: Improve decoder to pass Ruff F821 undefined-name.
These were probably intentional missing names, however raising
NotImplementedError or KeyError is more explicit than trying to call an
unknown function.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-22 22:43:20 +10:00
Graeme Winter 01ab7ba6e2 iperf3: Add compatibility for servers pre version 3.2.
Result message from servers pre version 3.2 do not encode start or end
time, so workaround this by using the t3, t0 timestamps used elsewhere for
sending.

Fixes issue #665.
2023-07-27 16:01:30 +10:00
Christian Clauss 4da6e6f1b2 all: Lint Python code with ruff.
Signed-off-by: Christian Clauss <cclauss@me.com>
2023-07-24 07:51:33 +02:00
Jim Mussared 8fc9edabf3 all: Standardise x.y.z versioning for all packages.
- For packages that were just x.y, update to x.y.0.
- For that were x.y.z-n, update to x.y.(z+1)

From now on we'll apply semver rules:
- MAJOR version when you make incompatible API changes
- MINOR version when you add functionality in a backward compatible manner
- PATCH version when you make backward compatible bug fixes

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-07-23 11:48:57 +10:00
Jim Mussared 8513bfbe9d requests: Rename urequests to requests.
This module implements a subset of the Python requests module, and so
it should have the same name.

Added a backwards-compatibility wrapper to allow people to continue to use
`import urequests`. This lives in micropython/urequests.

Changed requests to be a package, so that we can implement extension
packages in the future for optional functionality.

Added a basic README.md to both.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-07-23 11:41:44 +10:00
Jim Mussared 386ab99d7f python-ecosys: Add pypi= to metadata.
This is so the package knows the "upstream" name of the corresponding PyPI
package that it's based on.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-06 12:06:15 +10:00
Damien George ea21cb3fdc iperf3: Support devices without os.urandom().
Also add a version to the manifest.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 16:04:00 +11:00
iabdalkader b9741f6584 cbor2: Remove u-module prefix from imports. 2023-03-03 12:20:28 +11:00
iabdalkader 52fcb8e4a7 cbor2: Add cbor2 library.
This aims to follow the API of the cbor2 library found at
https://github.com/agronholm/cbor2 (also on PyPI as cbor2).

The original source for this MicroPython version of cbor2 is from
https://github.com/kpn-iot/senml-micropython-library.
2023-03-01 01:13:06 +11:00
Jim Mussared a9e52d085c top: Update top-level docs.
* Add instructions for how to use micropython-lib.
* Add a terminology guide and use consistent terminology
  (package/module/library).
* Improve code conventions and contributor guidelines.
* Misc readme updates.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-16 17:16:03 +11:00
Jim Mussared ce66e701a5 all: Replace metadata.txt with manifest.py.
Uses the new require()/package()/module() functions from manifestfile.py.

Add manifest.py for iperf3 and pyjwt.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-05 17:50:28 +10:00
Jim Mussared ecef7a506c all: Remove all setup.py files.
These are unused and will be replaced with manifest.py.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-05 17:50:11 +10:00
Jim Mussared c3f4779002 python-ecosys/pyjwt/jwt.py: Fix missing whitespace.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-09 17:06:49 +10:00
Miguel Grinberg 9fdf046e27 python-ecosys/pyjwt: Add pyjwt-compatible module. 2022-08-08 22:13:08 +10:00
Andrew Leech 70e422dc2e urequests: Release 0.7.0. 2022-06-29 13:02:46 +10:00
Bogdan a3d6d29b1b urequests: Add timeout, passed to underlying socket if supported. 2022-06-29 13:02:31 +10:00
Andrew Leech dbd8fff830 urequests: Raise error when server doesn't respond with valid http. 2022-06-29 13:02:00 +10:00
karfas a725c42049 urequests: Always open sockets in SOCK_STREAM mode.
On the ESP32, socket.getaddrinfo() might return SOCK_DGRAM instead of
SOCK_STREAM, eg with ".local" adresses.  As a HTTP request is always a TCP
stream, we don't need to rely on the values returned by getaddrinfo.
2022-06-29 13:01:34 +10:00
Diefesson de Sousa SIlva b29cffb3e3 urequests: Add support for redirects. 2022-06-29 13:01:24 +10:00
Diefesson de Sousa SIlva b17e9aaf93 urequests: Add support for requests with chunked upload data. 2022-06-29 13:01:01 +10:00
Fabian Schmitt e7e8eff86b urequests: Add Basic Authentication support.
Usage matches the shorthand version described in
https://requests.readthedocs.io/en/latest/user/authentication/#basic-authentication
2022-06-29 12:59:38 +10:00
Andrew Leech 106c28a4d7 urequests: Fix raising unsupported Transfer-Encoding exception.
Would lead to recursive TypeError because of str + bytes.
2022-06-29 12:59:12 +10:00
Paul Sokolovsky d978e246d5 urequests: Explicitly add "Connection: close" to request headers.
Even though we use HTTP 1.0, where closing connection after sending
response should be the default, some servers ignore this requirement and
keep the connection open.  So, explicitly send corresponding header to get
the expected behavior.
2022-06-29 12:58:47 +10:00
Paul Sokolovsky 5854ae1286 urequests: Add ability to parse response headers.
This is controlled by parse_headers param to request(), which defaults to
True for compatibility with upstream requests. In this case, headers are
available as .headers of Response objects. They are however normal (not
case-insensitive) dict.

If parse_headers=False, old behavior of ignore response headers is used,
which saves memory on the dict.

Finally, parse_headers can be a custom function which can e.g. parse only
subset of headers (again, to save memory).
2022-06-28 16:55:15 +10:00
Damien George fe975d973a python-ecosys/iperf3: Add iperf3.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-28 12:47:35 +10:00
Jim Mussared 35e3c9e4ff python-ecosys: Move urequests to python-ecosys.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-05-27 16:53:02 +10:00