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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scription-0.86.27.tar.gz (65.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

scription-0.86.27-py3-none-any.whl (65.5 kB view details)

Uploaded Python 3

scription-0.86.27-py2-none-any.whl (65.5 kB view details)

Uploaded Python 2

File details

Details for the file scription-0.86.27.tar.gz.

File metadata

  • Download URL: scription-0.86.27.tar.gz
  • Upload date:
  • Size: 65.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for scription-0.86.27.tar.gz
Algorithm Hash digest
SHA256 0722052e800ed1f7cbb5c3ebf3b4e7b020c663f5dac91fa544aebb9c6aa16477
MD5 7497b2667a38286e941f3acff6cc1119
BLAKE2b-256 b6c54b66b9c4a1fc0f72582992539e3c15b7fec4038f3570913d071b4eca9f47

See more details on using hashes here.

File details

Details for the file scription-0.86.27-py3-none-any.whl.

File metadata

  • Download URL: scription-0.86.27-py3-none-any.whl
  • Upload date:
  • Size: 65.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for scription-0.86.27-py3-none-any.whl
Algorithm Hash digest
SHA256 46852c313e027cb826a24cf6f8dfa7eb95488a255695dcffdbfffb87a9f999ab
MD5 3e2574230b9b3e081c3c818c61bb9f95
BLAKE2b-256 1366e291e5e70114651b09c8bc3e7eb387daa96ce2cdc94b2e31158f688cd3dc

See more details on using hashes here.

File details

Details for the file scription-0.86.27-py2-none-any.whl.

File metadata

  • Download URL: scription-0.86.27-py2-none-any.whl
  • Upload date:
  • Size: 65.5 kB
  • Tags: Python 2
  • Uploaded using 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

File hashes

Hashes for scription-0.86.27-py2-none-any.whl
Algorithm Hash digest
SHA256 7a31b6bf5d61f797dc9c694d2e5e421de6a9d0c5aebc9b93de6404de3a8ab680
MD5 09f27d16daa9ad608ab760cb5af4eaf1
BLAKE2b-256 fddc6ea8dafdba7348ec012fe125ef3fb85cc63005a19bf5331c02dbb0d2248d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.86.27 This release

3 files

0.86.26

3 files

0.86.25

3 files

0.86.24

3 files

0.86.23

3 files

0.86.22

3 files

0.86.21

3 files

0.86.20

3 files

0.86.19

3 files

0.86.18

3 files

0.86.17

3 files

0.86.16

3 files

0.86.15

3 files

0.86.14

3 files

0.86.13

3 files

0.86.12

3 files

0.86.11

3 files

0.86.10

3 files

0.86.9

3 files

0.86.8

3 files

0.86.7

3 files

0.86.6

3 files

0.86.5

3 files

0.86.4

3 files

0.86.3

3 files

0.86.2

3 files

0.86.0

3 files

0.85.3

3 files

0.85.2

3 files

0.85.1

3 files

0.85.0

3 files

0.84.4

3 files

0.84.3

3 files

0.84.2

3 files

0.84.1

3 files

0.84.0

3 files

0.83.3

3 files

0.83.2

3 files

0.83.1

3 files

0.83.0

3 files

0.82.0

3 files

0.81.10

3 files

0.81.9

3 files

0.81.8

3 files

0.81.7

3 files

0.81.6

3 files

0.81.5

3 files

0.81.4

3 files

0.81.3

3 files

0.81.2

3 files

0.81.1

3 files

0.81.0

3 files

0.80.8

3 files

0.80.7

3 files

0.80.6

3 files

0.80.5

3 files

0.80.4

3 files

0.80.3

3 files

0.80.2

3 files

0.80.1

3 files

0.80.0

3 files

0.79.3

3 files

0.79.2

3 files

0.79.1

3 files

0.79.0

3 files

0.78.1

4 files

0.78.0

4 files

0.77.4

4 files

0.77.3

4 files

0.77.2

4 files

0.77.1

4 files

0.77.0

3 files

0.76.0

3 files

0.75.5

3 files

0.75.4

3 files

0.75.3

3 files

0.75.2

2 files

0.75.1

2 files

0.75.0

2 files

0.74.41

2 files

0.74.39

2 files

0.74.38

2 files

0.74.37

2 files

0.74.36

2 files

0.74.35

2 files

0.74.34

2 files

0.74.33

2 files

0.74.32

2 files

0.74.31

2 files

0.74.30

2 files

0.74.28

2 files

0.74.27

2 files

0.74.26

2 files

0.74.25

2 files

0.74.24

2 files

0.74.23

2 files

0.74.22

2 files

0.74.21

2 files

0.74.20

2 files

0.74.19

2 files

0.74.18

2 files

0.74.17

2 files

0.74.16

2 files

0.74.15

2 files

0.74.14

2 files

0.74.13

2 files

0.74.12

2 files

0.74.11

2 files

0.74.9

2 files

0.74.8

2 files

0.74.7

2 files

0.74.06

2 files

0.74.05

2 files

0.74.04

2 files

0.74.03

2 files

0.74.02

2 files

0.73.02

2 files

0.73.01

2 files

0.72.03

2 files

0.72.02

2 files

0.72.01

2 files

0.72.00

2 files

0.71.01

2 files

0.70.82

2 files

0.70.81

2 files

0.70.8

2 files

0.70.7

2 files

0.70.6

2 files

0.70.5

2 files

0.70.4

2 files

0.70.3

2 files

0.53.0

2 files

0.52.0

2 files

0.50.09

2 files

0.50.08

2 files

0.50.07

2 files

0.50.06

2 files

0.50.05

2 files

0.50.04

2 files

0.50.03

2 files

0.50.01

2 files

0.45.003

2 files

0.45.001

2 files

0.45.000

2 files

0.41.005

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page