Ejemplo n.º 1
0
def __upload(proj, repo, branch, data, maker, force=True):
    root, source, dist = (None, None, None)
    try:
        root = Folder(data.root or '~')
        source = root.child_folder('src')
        source.make()
        source = source.child_folder(proj)
        dist = root.child_folder('dist')
        tree = Tree(source, repo=repo, branch=branch)
        key = None
        if not force:
            key = check_revision_already_published(proj, data.bucket, tree)

        if not key:
            b = Bucket(data.bucket)
            b.make()
            key_folder = Folder(proj).child_folder(branch)
            zippath = dist.child_file(proj + '.zip')
            tree.clone(tip_only=True)
            sha = tree.get_revision(short=False)
            key_folder = key_folder.child_folder(sha)
            target = dist.child_folder(proj)
            target.make()
            maker(source, target)
            target.zip(zippath.path)
            b.add_file(zippath, target_folder=key_folder.path)
            key = b.bucket.get_key(key_folder.child(zippath.name))
    finally:
        if source:
            source.delete()
        if dist:
            dist.delete()

    return key.generate_url(30000)
Ejemplo n.º 2
0
def get_worker_outputs(data):
    result = None
    try:
        region = data.region or 'us-east-1'
        root = Folder(data.root or '~')
        source = root.child_folder('src')
        source.make()
        source = source.child_folder('worker')
        repo = data.worker_repo or 'git://github.com/gitbot/worker.git'
        branch = data.worker_branch or 'master'

        #   1. Pull worker repo
        tree = Tree(source, repo, branch)
        tree.clone(tip_only=True)

        #   2. Call gitbot.stack.publish with 'gitbot.yaml'
        worker_stack_name = stack.publish_stack(
                                    source.child_file('gitbot.yaml'),
                                    wait=True)
        result = stack.get_outputs(worker_stack_name, region)
    except Exception, e:
        print repr(e)
        raise
Ejemplo n.º 3
0
def setup_module():
    teardown_module()
    assert not GIT_REMOTE_DIR.exists
    assert not GIT_TEST_DIR1.exists
    assert not GIT_TEST_DIR2.exists
    global remote_tree
    global local_repo1
    global local_repo2

    print 'setting up remote'
    GIT_REMOTE_DIR.make()
    remote_tree = Tree(GIT_REMOTE_DIR)
    remote_tree.make(bare=True)

    print 'setting up local 1'

    GIT_TEST_DIR1.make()
    home = File(GIT_TEST_DIR1.child(HTML_FILE))
    home.parent.make()
    home.write(HTML)

    css = File(GIT_TEST_DIR1.child(CSS_FILE))
    css.parent.make()
    css.write(CSS)

    js = File(GIT_TEST_DIR1.child(JS_FILE))
    js.parent.make()
    js.write(JS)

    local_repo1 = Tree(GIT_TEST_DIR1, GIT_REMOTE)
    local_repo1.make()
    local_repo1.add_remote()
    local_repo1.commit("Initial commit")
    local_repo1.push(set_upstream=True)

    local_repo2 = Tree(GIT_TEST_DIR2, GIT_REMOTE)
    local_repo2.clone()