tests: add cram dependency

Cram is a tool for testing command line programs:

  https://bitheap.org/cram/

This allows us to do whole-system testing of zpm.

Cram 0.6 doesn't support Python 3.2. I fixed this and made a pull
request for getting the fix into upstream, but until this happens we
can depend on my fork.
zpm: handle invocation with no subcommand

Invoking zpm under Python 3 resulted in

   $ zpm
   Traceback (most recent call last):
     File "/home/mg/src/zpm/.tox/py3/bin/zpm", line 27, in <module>
       args.func(args)
   AttributeError: 'Namespace' object has no attribute 'func'

The problem is that argparse returns an empty Namespace in Python 3
when none of the subparsers match -- subparsers are seen as optional
in Python 3, but not in Python 2.
setup: include templates as package_data

The templates were not packaged and thus also not installed. This
meant that running 'zpm new' failed with:

  jinja2.exceptions.TemplateNotFound: zar.yaml

The error only occurs if the zpm package is installed normally,
creating a link with 'pip install -e .' hides the error.

Versions of Python before 2.7 did not automatically included the files
listed in package_data in the MANIFEST. So we now list them there too.
commands: RuntimeError has no message attribute in Python 3

This would trigger the following traceback if one tried to run 'zpm
new foo' and foo/zapp.yaml already existed:

  $ python3 zpm new foo
  Traceback (most recent call last):
    File "/home/mg/src/zpm/zpmlib/commands.py", line 86, in new
      zappyaml = zpm.create_project(args.dir)
    File "/home/mg/src/zpm/zpmlib/zpm.py", line 52, in create_project
      return _create_zapp_yaml(location)
    File "/home/mg/src/zpm/zpmlib/zpm.py", line 72, in _create_zapp_yaml
      raise RuntimeError("'%s' already exists!" % filepath)
  RuntimeError: 'foo/zapp.yaml' already exists!

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "zpm", line 23, in <module>
      args.func(args)
    File "/home/mg/src/zpm/zpmlib/commands.py", line 88, in new
      print(err.message)
  AttributeError: 'RuntimeError' object has no attribute 'message'
bundle: only encode shlex.split arg on Python 2.x

Before, we would encode all str objects to bytes objects, and this
causes an error in Python 3:

  >>> shlex.split(b'foo bar baz')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python3.3/shlex.py", line 276, in split
      return list(lex)
    File "/usr/lib/python3.3/shlex.py", line 266, in __next__
      token = self.get_token()
    File "/usr/lib/python3.3/shlex.py", line 93, in get_token
      raw = self.read_token()
    File "/usr/lib/python3.3/shlex.py", line 121, in read_token
      nextchar = self.instream.read(1)
  AttributeError: 'bytes' object has no attribute 'read'
bundle: use io.BytesIO for tar.addfile in Python 3

In Python 2, tar.addfile works with StringIO, but in Python 3 it needs
a io.BytesIO object instead.
bundle: add system tests

These tests verify the behavior patched in 06aa7e094db1 and
c86d7b5cb868.
Merge pull request #88 from mgeisler/cram

Add cram tests for exercising zpm CLI
Add support for Swift v1 auth

Unfortunately, `python-swiftclient` doesn't work well with python3, so
we have to continue building out our own home-baked Swift client.

If in the future `python-swiftclient` does get patched to work with py3,
we simplify this code and remove the `miniswift` module.
test_miniswift: expand auth tests to cover v1 & v?

This adds cases to test the v1 auth, and also to test what happens when
an unknown auth version is specified.
zpm: catch ZPMExceptions, print error messages

... without stacktraces.
Merge pull request #93 from larsbutler/swift-auth-v1

Add support for Swift auth v1
templates/zebra: put ZwiftClient tenant constructer arg last

It is last so that it's easy to make it optional. It will become
optional when we begin supporting Swift v1 auth for the Zebra
environment.
templates/zebra: refactor auth into a _auth2 method
templates/index: better way to escape inner template

The deploy.* settings are only known at deploy time, but the
index.html template is processed at bundle time.
templates/zebra: allow different args for different auth methods

The differnet authentication methods (v1, v2, no auth) will need
differnet arguments in the future.
templates/zebra: only add auth token when set

This allows a client to use the library without authentication.
templates/zebra: optionally take success callback from opts

This is similar to how jQuery allows you to pass callbacks.
templates/zebra: add support for Swift v1 auth
templates/zebra: document opts keys needed for auth methods