diff --git a/bambulabs_api/__init__.py b/bambulabs_api/__init__.py index 40d8404..a0a6544 100644 --- a/bambulabs_api/__init__.py +++ b/bambulabs_api/__init__.py @@ -5,6 +5,8 @@ except Exception: __version__ = "0.dev0+unknown" +from bambulabs_api import client, mqtt_client, ftp_client, ams + # flake8: noqa: F405 from .client import * # noqa from .filament_info import Filament, AMSFilamentSettings, FilamentTray # noqa @@ -12,6 +14,7 @@ from .mqtt_client import * # noqa from .ftp_client import * # noqa from .ams import * # noqa +from bambulabs_api.logger import logger # noqa: F401 __all__ = [] @@ -19,3 +22,4 @@ __all__.extend(mqtt_client.__all__) __all__.extend(ftp_client.__all__) __all__.extend(ams.__all__) +__all__.append("logger") diff --git a/bambulabs_api/ftp_client.py b/bambulabs_api/ftp_client.py index 9eb3fa6..a05a7e3 100644 --- a/bambulabs_api/ftp_client.py +++ b/bambulabs_api/ftp_client.py @@ -16,9 +16,10 @@ class ImplicitFTP_TLS(ftplib.FTP_TLS): """FTP_TLS subclass that automatically wraps sockets in SSL to support implicit FTPS.""" # noqa - def __init__(self, *args, **kwargs): + def __init__(self, *args, unwrap: bool = False, **kwargs): super().__init__(*args, **kwargs) self._sock = None + self.unwrap = unwrap """Explicit FTPS, with shared TLS session""" def ntransfercmd(self, cmd, rest=None): @@ -45,7 +46,7 @@ def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None): self.voidcmd('TYPE I') conn = self.transfercmd(cmd, rest) try: - while 1: + while True: buf = fp.read(blocksize) if not buf: break @@ -53,8 +54,8 @@ def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None): if callback: callback(buf) # shutdown ssl layer - if isinstance(conn, ssl.SSLSocket): - # conn.unwrap() # Fix for storbinary waiting indefinitely for response message from server # noqa + if isinstance(conn, ssl.SSLSocket) and self.unwrap: + conn.unwrap() # Fix for storbinary waiting indefinitely for response message from server # noqa pass finally: conn.close() # This is the addition to the previous comment. diff --git a/bambulabs_api/logger.py b/bambulabs_api/logger.py index 7e54307..cd301b8 100644 --- a/bambulabs_api/logger.py +++ b/bambulabs_api/logger.py @@ -1,3 +1,5 @@ +__all__ = ["logger"] + import logging logger = logging.getLogger("bambulabs_api") diff --git a/docs/release.rst b/docs/release.rst index bdf5655..2d9fc0b 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -7,6 +7,7 @@ Release notes for each release here: .. toctree:: :maxdepth: 1 + 2.6.6 2.6.5 2.6.4 2.6.3 diff --git a/docs/release/2.6.6-notes.md b/docs/release/2.6.6-notes.md new file mode 100644 index 0000000..ec581cf --- /dev/null +++ b/docs/release/2.6.6-notes.md @@ -0,0 +1,5 @@ +Bambulabs API 2.6.6 Release Notes +================================= + +* Add unwrap connection option +* Expose bambulab logger diff --git a/pyproject.toml b/pyproject.toml index ea25341..bd6087c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "bambulabs_api" -version = "2.6.5" +version = "2.6.6" authors = [ { name="Chris Ioannidis", email="chris.ioannidis23@imperial.ac.uk" }, { name="Haotian Wu", email="64962148+ohmdelta@users.noreply.github.com"}