Skip to main content

Helper module for creating simple Python 3 scripts

Project description


Helper module for simple command line Python scripts

Basic usage

import scripthelper

logger = scripthelper.bootstrap()

logger.critical('critical message')
logger.error('error message')
logger.warning('warning message')'info message')
logger.verbose('verbose message')
logger.debug('debug message')
logger.spam('spam message')

It just works, and adds --verbose and --quiet command line options, too.

Adding other command line parameters

import scripthelper

scripthelper.add_argument('-n', '--name', help='Name to greet')
logger, args = scripthelper.bootstrap_args()

    logger.debug('Name was provided')'Hello {}')
    logger.warning('Name was not provided')

Progressbar works with logging, too

import scripthelper
import time

logger = scripthelper.bootstrap()'Doing the calculations...')
for i in scripthelper.progressbar(range(200)):
    if i % 20 == 0:
        logger.verbose(f'Iteration {i}')
    if i % 5 == 0:
        logger.debug(f'Iteration {i}')
    logger.spam(f'Iteration {i}')

You can easily preserve logs in files

import scripthelper

logger = scripthelper.bootstrap()

logger.warning('warning message')'info message')
logger.debug('debug message')

It handles exceptions, warnings

import scripthelper
import warnings


warnings.warn("This user warning will be captured.")
raise RuntimeError("This exception should be handled.")

(The local variables will be displayed in stack trace.)

Project details

Download files

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

Source Distribution

scripthelper-1.8.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

scripthelper-1.8-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page