Sign inSign up

siteworx/pystash

By siteworx

•Updated about 10 years ago

A command line utility and python library for talking to Stash

Image
0

259

siteworx/pystash repository overview

PYSTASH: PYTHON LIBRARY AND COMMAND LINE UTILITY FOR INTERACTING WITH STASH

Pystash is an (incomplete) framework for creating Stash commands that can be used from the command line via a git-like subcommand structure.

The project contains a Dockerfile, and the docker image can be used to create "serverless", short-lived containers which execute the utility, eliminating the need to setup python and dependencies on your system.

Frequently-referenced information about your Stash environment must be passed to the utility via environment variables. the remaining parameters are sent to the utility via command-line arguments.

To use (via docker): Build the image: docker build -t pystash:latest .

Create a stash.env file. Declare the following variables in it:

`STASH_USERNAME=yourstashusername`
`STASH_PASSWORD=yourstashpassword`
`STASH_BASE_URL=https://stash.siteworx.com`
`STASH_PRODUCT_KEY=SI #project code`
`STASH_REPOSITORY=prbuildertest #name of your repository`

Run the command: docker run --env-file /path/to/stash.env pystash pullrequests comment 2 'I am a robot.'

To use (without docker):

  1. Create a virtualenv for pystash
  2. Use pip to install dependencies from requirements.txt
  3. Set each environment variable above.
  4. find pystash.py and run it with the python command.

Command Structure: pystash <module> <command> <arg> ... <arg>

module: There's only one for now and that's pullrequest command: currently comment, merge declind arg: pull_request_id. If commenting, text comes second.

PROTIP: pystash uses the argparse library, and should behave similarly to a real linux command. use -h after any section to get help.

Architecture pystash.py, the top level script, is in charge of creating a top-level command parser, and registering each submodule (there's only 1 right now: pullrequests) with that parser by adding the submodule's sub-parser. Each submodule (aka pullrequests.py) contains a number of command classes that have init methods that take the necessary arguments. Each command class contains a parser that can register it with its submodule's parser. Each submodule also contains a handler that can dispatch commands based on the command parameter. In this way it should be possible to build out more modules to handle different stash resource types, and different commands to handle different methods, and retain a somewhat-organized, fairly legitimate, command-line application.

Tag summary

Content type

Image

Digest

Size

256.2 MB

Last updated

about 10 years ago

docker pull siteworx/pystash