Under the Hood of SAWS, A Supercharged AWS CLI




What's SAWS?

SAWS: GitHub Repo

So what's under the hood?

AWS CLI

Python-powered official AWS CLI. Does the heavy lifting communicating with AWS and feeds completions to SAWS. The AWS CLI uses boto, the official Python SDK for AWS.

Check out completer.py for more details on how awscli is used.

Python-Prompt Toolkit

Python-prompt-toolkit simplifies the creation of interactive command lines.

Used throughout the SAWS source code.

Pygments

Pygments is a syntax highlighter for SAWS commands and output.

Check out lexer.py for more details on how pygments is used.

Unit Tests

SAWS uses:

If you want to play around the development environment, run the following:

$ git clone https://github.com/donnemartin/saws.git
$ pip install -e .
$ pip install -r requirements-dev.txt
$ saws

Run unit tests in your active Python environment:

$ python tests/run_tests.py

I'm also a fan of:

While working on SAWS I came across 'behavior driven development' with behave--interesting!

Tox

Tox is used to automate and standardize testing in Python 2.6, 2.7, 3.3, 3.4, and pypy.

I've found Tox + Travis CI to be a great combination. To hook up tox to Travis CI, add the following to your .travis.yml:

install:
  - travis_retry pip install tox

after_success:
    - codecov

To run locally:

$ tox

The tox.ini file specifies:

  • Python environments
  • Travis CI arguments
  • Dependencies
  • Test commands

Coverage Tests

Codecov

Codecov provides code coverage. SAWS uses codecov-python to interact with CodeCov.

Coveralls is also very popular and can be used with python-coveralls and coveralls-python.

To hook up to Codecov to Travis CI, add the following to your .travis.yml:

install:
  - pip install codecov

after_success:
    - codecov

TravisCI

Build Status

Travis CI provides continuous integration.

The .travis.yml file specifies:

  • Python versions
  • OS (I had trouble getting Mac OS X to work)
  • Install dependencies
  • Script to run
  • What to do after running (send the coverage stats to Codecov)

Sphinx

Documentation Status

Sphinx is a great documentation tool. It takes your docstrings and turns it into documentation that can be hosted on sites such as Readthedocs.org and PyPi.

Here's a handy article to learn more about how to build and upload your Sphinx docs to PyPi:

Run the following to build the docs:

$ python setup.py build_sphinx

PyPI and Setup.py

PyPI version PyPI

Setup.py contains information on versioning, package requirements, and other useful info for PyPI.

This allows end-users to install with a one-liner:

$ pip install saws

A virtualenv install is recommended to avoid potential permissions or package dependency issues.

Check out this article to learn more about posting to PyPI.

Git-Flow

Git-Flow is a set of Git extensions that provide high-level repository operations for the popular git branching model.

Misc

  • Six - Python 2 and 3 compatibility.
  • Flake8 - Linter for code quality.