Are there Python3 libraries for the net commands and etc?
phlogistonjohn at asynchrono.us
Mon Mar 28 19:44:18 UTC 2022
On Monday, March 28, 2022 12:11:18 PM EDT Jeremy Allison via samba-technical
> On Sun, Mar 27, 2022 at 09:21:38AM -0700, Richard Sharpe via samba-technical
> >Hi folks,
> >A lot of system management scripts these days are implemented in
> >Python and I am sick of using popen and system in python to run Samba
> >commands and then grub through the output to figure out what I need.
> >Are there any Python3 libraries that provide the functionality of the
> >net commands?
> I don't think so. The only python SMB stuff I'm aware of is:
> I think only Samba does the management stuff. However,
> most of our management stuff is drivable directly from
> python, as that's how we do much of the testing.
> Talk to David Mulder from SuSE or some of the Catalyst
> Team as they know much more about this than I.
There's also https://github.com/hamano/pysmbc that I used in past projects. It
uses libsmbclient, rather than being pure python.
However, I do think Richard Sharpe meant management stuff. I am also very
interested in doing less fork/exec/parse and make more use of samba library
bindings for our `sambacc` project. Personally, I keep meaning to spend some
time digging around in the samba-tool code. Since there's some overlap there
with `net` around things like domain join, even for non-AD-DC servers, I think
there *are* some existing libs to do a lot of these actions. However, the
documentation is missing/not obvious. One of my big stumbling blocks when I
see a package/api that seems to be something I want there's often a lack of
clarity around how to make use of it due to stuff like undocumented arguments &
some magic numeric constants, etc. However, its been some months since I last
looked so things may have improved too... so take this with a grain of salt.
There was also an effort to add JSON to some of the commands. If smbstatus and/
or other commands had JSON output we don't have to do low-level parsing of
output, even if we still need to fork/exec/read. My team was interested in
this but we didn't have sufficient bandwidth to actively pursue it ourselves.
However, a teammate alerted me to a new MR on the subject earlier today:
Anyway, I just wanted to reply to say that Richard isn't the only person
interested in this kind of thing. :-)
More information about the samba-technical