Skip to main content

A Python package enabling the development of robust automation scripts that are subdivided into stages.

Project description

Lines of code codecov CodeFactor CodeQL Conda Version Conda Downloads Continuous Integration Contributor Covenant GitHub contributors Documentation Status License Merged PRs OpenSSF Best Practices OpenSSF Scorecard Platforms pre-commit pre-commit.ci Status PyPI - Version PyPI - Downloads Python Version Ruff

staged-script

Python is an ideal language for certain types of infrastructure automation. Automating what a user does manually often involves walking through a series of stages. A user may wish to run all the stages in series, or perhaps only a subset, and depending on how things go, certain stages may need to be retried. Once the script finishes running, it'd be ideal if it could tell the user exactly what was run, for the sake of easing replicability. staged-script aims to ease the development such automation scripts. It's easy to get started with, but also provides significant power-user functionality for those who need it.

Installation

To get up and running with staged-script, simply:

python3 -m pip install staged-script

Usage

Once installed, you can simply

import sys

from staged_script import StagedScript


class MyScript(StagedScript):

    @StagedScript.stage("hello", "Greeting the user")
    def say_hello(self) -> None:
        self.run("echo 'Hello World'", shell=True)

    @StagedScript.stage("goodbye", "Bidding farewell")
    def say_goodbye(self) -> None:
        self.run("echo 'Goodbye World'", shell=True)

    def main(self, argv: list[str]) -> None:
        self.parse_args(argv)
        try:
            self.say_hello()
            self.say_goodbye()
        finally:
            self.print_script_execution_summary()


if __name__ == "__main__":
    my_script = MyScript({"hello", "goodbye"})
    my_script.main(sys.argv[1:])

For more detailed usage and API information, please see our documentation.

Where to Get Help

If you're having trouble with staged-script, or just want to ask a question, head on over to our issue board. If a quick search doesn't yield what you're looking for, feel free to file an issue.

Contributing

If you're interested in contributing to the development of staged-script, we'd love to have your help :grinning: Check out our contributing guidelines for how to get started. Past contributors include:

License & Copyright

See LICENSE.md and COPYRIGHT.md.

Credits

Special thanks to the GMS project for investing in the development of this package. Aspects of this functionality were inspired by the SPiFI Jenkins Pipeline plugin and the ShellLogger Python package.

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

staged_script-2.0.3.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

staged_script-2.0.3-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file staged_script-2.0.3.tar.gz.

File metadata

  • Download URL: staged_script-2.0.3.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for staged_script-2.0.3.tar.gz
Algorithm Hash digest
SHA256 72e4b9f98c0c37548de6ea2778e51f094546f784257ad246e0347aba908e34c5
MD5 ce1ac4a533935a277107d45a300e18de
BLAKE2b-256 d0ee71fefe0b504241861e3db396667b107d49b6f04dbc46abf78f2e58bfbe2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for staged_script-2.0.3.tar.gz:

Publisher: semantic-release.yml on sandialabs/staged-script

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file staged_script-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: staged_script-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for staged_script-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d800983b04edd5ad73c2b03444e9f83c8587a94818363f774481805b5389739a
MD5 78353459edf4350afaa9a2a3b870a888
BLAKE2b-256 f54ee7ac20d4b5495e831968ae51705d8c0cc827ed3779aa7c0c61dd158bd7f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for staged_script-2.0.3-py3-none-any.whl:

Publisher: semantic-release.yml on sandialabs/staged-script

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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