Chapter 3

Modules

Extend your scripts with the Scrippy modules.


scrippy-core provides the foundations of every Scrippy script. The Scrippy modules add ready to use, consistent and logged implementations of the tasks system administrators perform every day:

Module Package Purpose
Template scrippy-template Document generation from Jinja2 templates
Remote scrippy-remote Remote command execution and file transfers over SSH/SFTP, FTP/FTPS and CIFS
SNMP scrippy-snmp SNMP get, walk and set operations
Database scrippy-db PostgreSQL, MySQL and SQLite queries and transactions
API scrippy-api REST API client, with OpenAPI support
Mail scrippy-mail Sending emails with SMTP, reading emails with IMAP and POP3
Git scrippy-git Cloning, committing and pushing Git repositories

Using a module

All modules are installed by the Scrippy installer. Each module can also be installed on its own with pip, i.e:

pip install scrippy-template

All modules share the same principles:

  • They log through the Scrippy logger: Their messages appear in the log of your script, with the same format, and the secrets registered by your script are redacted from them.
  • Each module has its own exception class (ScrippyTemplateError, ScrippyRemoteError...), handled by the execution context like any other error (see Error handling).
  • scrippy_core must be imported first, before any module (see Importing scrippy_core).
import scrippy_core
from scrippy_core import logger
from scrippy_template import template, ScrippyTemplateError

Following the tutorial

Each module page starts by extending disk_watch.py, the script written in the tutorial, with the module, then describes the module in details. The module pages can be read in any order: Each one starts from the complete tutorial script.