I’ve just put together some minimal Python bindings for libsmbclient, following on from what I said earlier. All that’s wrapped is enough for it to be useful for discovering printer shares, so that’s: the SMB context object, the opendir() method and the getdents() method. There’s an example included called
test.py, which shows it in action. I’ve included some API documentation as well.
Simply put, it goes like this:
>>> import smbc
>>> ctx = smbc.Context (debug=..., flags=..., auth_fn=...)
>>> dir = ctx.opendir ("smb://")
>>> print (dir.getdents ())
[<smbc.Dirent object "MYGROUP" (Workgroup) at 0x2aaaaaaf30f8>,
<smbc.Dirent object "WORKGROUP" (Workgroup) at 0x2aaaaaaf32d8>]
(Note that dir is an object representing a SMBCFILE* with a particular SMBCCTX*, and it calls closedir() automatically when it is cleaned up.)
It’s fairly easy to imagine it being extended to cover the rest of the libsmbclient API, but for now that is all.
I’ve put the tarball here.