Skip to main content

scription

light-weight library to enhance command-line scripts; includes conversion of parameters to specified data types, parameter checking, basic input/output with users, support for suid [1], sending email, executing sub-programs, and having sub-commands within a script

decorators

  • Script: sets global variables and/or parameters for Commands; the decorated function will be called by Main/Run before any specified Command

  • Command: marks function as a subcommand for the script (e.g. add, delete, list, etc.); if no subcommand is specified on the command-line, scription will look for a Command with the same name as the script

  • Alias: registers other names for Commands (e.g. delete / remove / kill)

functions

  • Main: if the importing module’s __name__ is __main__, call Run() (this allows for importing the script as a module)

  • Run: unconditionally attempts to run the Script function (if any) and the Command found on the command-line

Main() or Run() should be the last thing in the script

classes

  • Spec: can be used when defining the command-line parameters (can also just use tuples)

helper functions/classes

  • abort: quits immediately by raising SystemExit

  • Execute: class for executing other programs; uses subprocess.Popen by default, but if pty=True is specified then pty.fork will be used (handy for programs that only accept input from a pty)

  • get_response: function for displaying text and getting feedback

  • help: quits immediately, but adds a reference to –help in the quit message

  • log_exception: logs an exception with logging.logger

  • mail: rudimentary mail sender

  • OrmFile: lightweight orm – supports str, int, float, date, time, datetime, bool, and path (which defaults to str); custom data types can also be specified

  • print: wrapper around print that adds a ‘verbose_level’ keyword (default: 1); default verbosity is 0 (so print does nothing), but can be increased using -v, -vv, –verbose, or –verbose=2 (in Python 2 the script must use ‘from __future__ import print_function’ to use scription’s print)

  • user_ids: context manager useful for suid scripts – all actions taken within the context are run as the user/group specified

features

  • extra parameters defined by Script are global, and can be accessed from any function or Command

  • ‘module’ is a namespace inserted into the script

  • ‘script_command’ is the Command selected from the command line (useful when one needs to call the subcommand directly from a main() function)

  • ‘script_command_name’ is the name of the script_command

  • ‘script_verbosity’ is the level of verboseness selected (defaults to 0)

  • ‘script_name’ is the name of the script

  • builtin options are: –help, –verbose (-v or -vv), –version, –all-versions –version attempts to display the version of the main package in use –all-versions attempts to display the versions of any imported packages

  • command-line is decoded to unicode under Python 2 (Python 3 does this for us)

[1] I use the suid-python program, available at http://selliott.org/python/suid-python.c

Metadata

Release files for scription 0.86.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scription 0.86.27
File Size Uploaded
scription-0.86.27.tar.gz 65.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for scription 0.86.27
File Interpreter ABI Platform
scription-0.86.27-py3-none-any.whl Python 3 none any Details
scription-0.86.27-py2-none-any.whl Python 2 none any Details

Total release size: 196.8 kB

Release files / scription-0.86.27.tar.gz

Download URL scription-0.86.27.tar.gz
Size 65.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0722052e800ed1f7cbb5c3ebf3b4e7b020c663f5dac91fa544aebb9c6aa16477
BLAKE2b-256 checksum
How to use checksums
b6c54b66b9c4a1fc0f72582992539e3c15b7fec4038f3570913d071b4eca9f47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.32.3 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

Release files / scription-0.86.27-py3-none-any.whl

Download URL scription-0.86.27-py3-none-any.whl
Size 65.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46852c313e027cb826a24cf6f8dfa7eb95488a255695dcffdbfffb87a9f999ab
BLAKE2b-256 checksum
How to use checksums
1366e291e5e70114651b09c8bc3e7eb387daa96ce2cdc94b2e31158f688cd3dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.32.3 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

Release files / scription-0.86.27-py2-none-any.whl

Download URL scription-0.86.27-py2-none-any.whl
Size 65.5 kB
Tags Python 2
SHA-256 checksum
How to use checksums
7a31b6bf5d61f797dc9c694d2e5e421de6a9d0c5aebc9b93de6404de3a8ab680
BLAKE2b-256 checksum
How to use checksums
fddc6ea8dafdba7348ec012fe125ef3fb85cc63005a19bf5331c02dbb0d2248d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.32.3 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.86.27 This release

3 release files

0.86.9

3 release files

0.86.7

3 release files

0.86.6

3 release files

0.86.5

3 release files

0.86.4

3 release files

0.86.3

3 release files

0.86.0

3 release files

0.85.3

3 release files

0.85.1

3 release files

0.85.0

3 release files

0.84.4

3 release files

0.84.3

3 release files

0.84.2

3 release files

0.84.1

3 release files

0.84.0

3 release files

0.83.3

3 release files

0.83.1

3 release files

0.83.0

3 release files

0.82.0

3 release files

0.81.9

3 release files

0.81.8

3 release files

0.81.1

3 release files

0.81.0

3 release files

0.80.8

3 release files

0.80.7

3 release files

0.80.6

3 release files

0.80.5

3 release files

0.80.4

3 release files

0.80.1

3 release files

0.80.0

3 release files

0.78.1

4 release files

0.78.0

4 release files

0.77.4

4 release files

0.77.3

4 release files

0.77.2

4 release files

0.77.0

3 release files

0.76.0

3 release files

0.75.5

3 release files

0.75.4

3 release files

0.74.8

2 release files

0.74.7

2 release files

0.70.8

2 release files

0.70.7

2 release files

0.70.6

2 release files

0.70.5

2 release files

0.53.0

2 release files

0.52.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page