A new Naked release was pushed to PyPI and GitHub. It includes extensive updates to the XDict dictionary extension & several updates to the NakedObject class. These are classes in the
Naked.toolshed.c.types library modules.
NakedObject documentation was released last week and is current with the changes that were included in this release.
Naked.toolshed.shell.muterun_rb() function allows you to execute a Ruby script from your Python code and control the standard output and standard error streams on the Python side. These data are returned as attributes of a generic object without a write to the terminal and can be accessed (along with the exit status code) using standard Python dot syntax.
The returned object’s attributes include:
- stdout = standard output stream data (or empty string on non-zero exit status)
- stderr = standard error stream data (or empty string on zero exit status)
- exitcode = the exit status code
Here’s an example of how a script named
testscript.rb could be executed and handled on the Python side of your code:
from Naked.toolshed.shell import muterun_rb response = muterun_rb('testscript.rb') if response.exitcode == 0: # the command was successful, handle the standard output standard_out = response.stdout print(standard_out) else: # the command failed or the executable was not present, handle the standard error standard_err = response.stderr exit_code = response.exitcode print('Exit Status ' + exit_code + ': ' + standard_err)
The utility of this approach is that you can manipulate the output or suppress it altogether from the calling code. If you simply intend to print it to the terminal, then use the
execute_rb() function in the same module. This allows the Ruby script to maintain control of the data that are displayed in the terminal.
Naked.toolshed.c.types library documentation will be released in installments by type over the next week or two as I complete a battery of tests on the type extensions (and make some final tweaks) before they are released for public consumption.
The v0.1.24 release is now available from PyPI and GitHub. It includes numerous updates to the toolshed shell module. Complete shell module documentation is now available. Check it out to learn more about how to use the functions in the shell library to run system commands, Node.js & Ruby scripts, and access shell environment variables from your Python code.
I am hard at work on the documentation for the Naked toolshed library. The Ink templating system documentation will be published later today and I intend to publish documentation on the rest of the library over the upcoming week as I complete testing on some of the components.