{"id":14965240,"url":"https://github.com/saltstack/python-tools-scripts","last_synced_at":"2025-10-19T08:32:19.451Z","repository":{"id":59915605,"uuid":"539947221","full_name":"saltstack/python-tools-scripts","owner":"saltstack","description":"Python Tools Scripts","archived":false,"fork":false,"pushed_at":"2024-02-29T10:15:47.000Z","size":241,"stargazers_count":5,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T11:21:15.957Z","etag":null,"topics":["python","repository-tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saltstack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-22T11:30:10.000Z","updated_at":"2025-01-19T22:29:07.000Z","dependencies_parsed_at":"2023-11-23T19:57:40.920Z","dependency_job_id":"b7188066-da6d-412c-940d-1dd726be22da","html_url":"https://github.com/saltstack/python-tools-scripts","commit_stats":{"total_commits":124,"total_committers":5,"mean_commits":24.8,"dds":"0.18548387096774188","last_synced_commit":"dee6091ba46f3cf427541b46e9643136fb172495"},"previous_names":["s0undt3ch/python-tools-scripts"],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack%2Fpython-tools-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack%2Fpython-tools-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack%2Fpython-tools-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack%2Fpython-tools-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saltstack","download_url":"https://codeload.github.com/saltstack/python-tools-scripts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237092958,"owners_count":19254319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","repository-tools"],"created_at":"2024-09-24T13:34:25.212Z","updated_at":"2025-10-19T08:32:18.893Z","avatar_url":"https://github.com/saltstack.png","language":"Python","readme":"# Python Tools Scripts\n\nThis is a tool, similar to [invoke](https://www.pyinvoke.org).\nIt's more recent and uses [argparse](https://docs.python.org/3/library/argparse.html) under the hood\nand some additional magic to define the CLI arguments.\n\nTo use it, you must have a `tools` package in your repository root.\nOn your `tools/__init__.py` import your scripts and *Python Tools Scripts* will add them to it's CLI.\n\n## An Example Script `tools/vm.py`\n\n```python\n\"\"\"\nThese commands are used to create/destroy VMs, sync the local checkout\nto the VM and to run commands on the VM.\n\"\"\"\n\nfrom ptscripts import Context, command_group\n\n# Define the command group\nvm = command_group(name=\"vm\", help=\"VM Related Commands\", description=__doc__)\n\n\n@vm.command(\n    arguments={\n        \"name\": {\n            \"help\": \"The VM Name\",\n            \"metavar\": \"VM_NAME\",\n            \"choices\": list(AMIS),\n        },\n        \"key_name\": {\n            \"help\": \"The SSH key name.\",\n        },\n        \"instance_type\": {\n            \"help\": \"The instance type to use.\",\n        },\n        \"region\": {\n            \"help\": \"The AWS regsion.\",\n        },\n    }\n)\ndef create(\n    ctx: Context,\n    name: str,\n    key_name: str = None,\n    instance_type: str = None,\n    region: str = \"eu-central-1\",\n):\n    \"\"\"\n    Create VM.\n    \"\"\"\n    vm = VM(ctx=ctx, name=name)\n    vm.create(region_name=region, key_name=key_name, instance_type=instance_type)\n\n\n@vm.command(\n    arguments={\n        \"name\": {\n            \"help\": \"The VM Name\",\n            \"metavar\": \"VM_NAME\",\n        },\n    }\n)\ndef destroy(ctx: Context, name: str):\n    \"\"\"\n    Destroy VM.\n    \"\"\"\n    vm = VM(ctx=ctx, name=name)\n    vm.destroy()\n```\n\nThe, on your repository root, run:\n\n```\n❯ tools -h\nusage: tools [-h] [--debug] {vm} ...\n\nPython Tools Scripts\n\noptional arguments:\n  -h, --help   show this help message and exit\n  --debug, -d  Show debug messages\n\nCommands:\n  {vm}\n    vm         VM Related Commands\n\nThese tools are discovered under `\u003crepo-root\u003e/tools`.\n```\n\n```\n❯ tools vm -h\nusage: tools vm [-h] {create,destroy} ...\n\nThese commands are used to create/destroy VMs, sync the local checkout to the VM and to run commands on the VM.\n\noptional arguments:\n  -h, --help            show this help message and exit\n\nCommands:\n  {create,destroy}\n    create              Create VM.\n    destroy             Destroy VM.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack%2Fpython-tools-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaltstack%2Fpython-tools-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack%2Fpython-tools-scripts/lists"}