Example #1
0
def cmd_build_template(args):
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']
    has_next_custom = next_store.has(last_tag)
    next_custom = next_store.get(last_tag) if has_next_custom else None
    parse_templates(args.templates, repo_info, next_custom)
Example #2
0
def cmd_clean(args):
    next_store = KVStore(NEXT_STORE_FILE)
    if len(args.tag) > 0:
        tag = args.tag
    else:
        repo_info = get_repo_info()
        tag = repo_info['last-tag']

    has_custom = next_store.has(tag)
    next_custom = next_store.get(tag) if has_custom else None

    if has_custom:
        next_store.rm(tag).save()
        print "Cleaned up custom string version \"" + next_custom + \
              "\" for tag \"" + tag + "\""
    else:
        print "No custom string version found for tag \"" + tag + "\""
Example #3
0
def cmd_next(args):
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()

    last_tag = repo_info['last-tag']

    vn = args.next_version_numbers
    user = user_numbers_from_string(vn)
    if not user:
        print err("Please specify valid version numbers.\nThe expected "
                  "format is <MAJ>.<MIN>.<PATCH>, e.g. v0.0.1 or 0.0.1")
        sys.exit(1)

    custom = "%d.%d.%d" % (int(user[0]), int(user[1]), int(user[2]))
    next_store.set(last_tag, custom).save()
    print "Set NEXT version string to " + color_next(custom) + \
          " for the current tag " + color_tag(last_tag)
Example #4
0
def cmd_info(args):
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']

    has_next_custom = next_store.has(last_tag)
    next_custom = next_store.get(last_tag) if has_next_custom else None

    if has_next_custom:
        nvn = color_next(next_custom)
    else:
        nvn = "none defined, using " + color_next("-" + cfg['next_suffix']) + \
              " suffix"

    print "Most recent tag: " + color_tag(last_tag)
    print "NEXT defined as: " + nvn
    print "Current build ID: " + color_tag(repo_info['full-build-id'])
    print "Current version: " + \
          color_version("v" + build_version_string(repo_info, next_custom))
Example #5
0
def cmd_list_next(args):
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']
    has_next_custom = next_store.has(last_tag)
    if not next_store.empty():
        def print_item(k, v):
            print "    %s => %s" % (color_tag(k), color_next(v)) +\
                  (' (*)' if k == last_tag else '')

        print "Currently set NEXT custom strings (*=most recent " \
              "and reachable tag):"
        for tag, vstring in sorted(next_store.items()):
            print_item(tag, vstring)

        if not has_next_custom:
            print_item(last_tag, '<undefined>')

    else:
        print "No NEXT custom strings set."
Example #6
0
import falcon
from semantic_version import Version
from storage import KVStore

version = Version("1.0.0")
versioned = lambda p: "/v{}/{}".format(version.major, p.strip('/')).rstrip('/')
store = KVStore()


class KeyValResource(object):
    def on_get(self, req, resp, key):
        """Handles GET requests"""
        value = store.get(key)
        if not value:
            raise falcon.HTTPNotFound(title="Not Found")
        else:
            resp.status = falcon.HTTP_200
            resp.body = value

    def on_put(self, req, resp, key):
        """Handles PUT requests"""
        body = req.stream.read(req.content_length)
        store.set(key, body)
        resp.status = falcon.HTTP_201

    def on_delete(self, req, resp, key):
        """Handles DELETE requests"""
        store.delete(key)
        resp.status = falcon.HTTP_204