コード例 #1
0
ファイル: update.py プロジェクト: AerisCloud/AerisCloud
def cli(force):
    """
    Update AerisCloud
    """
    if not force and config.get('github', 'enabled', default=False) == 'true':
        client = Github().gh
        repo = client.repository('aeriscloud', 'aeriscloud')
        latest_release = repo.iter_releases().next()
        latest_version = latest_release.tag_name[1:]

        if semver.compare(version, latest_version) != -1:
            click.secho('AerisCloud is already up to date!', fg='green')
            sys.exit(0)

        click.echo('A new version of AerisCloud is available: %s (%s)' % (
            click.style(latest_version, fg='green', bold=True),
            click.style(latest_release.name, bold=True)
        ))

    # retrieve install script in a tmpfile
    tmp = tempfile.NamedTemporaryFile()
    r = requests.get('https://raw.githubusercontent.com/' +
                     'AerisCloud/AerisCloud/develop/scripts/install.sh')
    if r.status_code != 200:
        fatal('error: update server returned %d (%s)' % (
            r.status_code, r.reason))

    tmp.write(r.content)
    tmp.flush()

    os.environ['INSTALL_DIR'] = aeriscloud_path
    call(['bash', tmp.name])

    tmp.close()
コード例 #2
0
ファイル: fetch.py プロジェクト: AerisCloud/AerisCloud
def _clone_project(project_name):
    gh = Github()

    (gh_repo, forked) = gh.get_repo(project_name, fork=True)
    if not gh_repo:
        click.echo('error: no repository named %s was found on '
                   'your user and configured organizations' %
                   click.style(project_name, bold=True))
        sys.exit(1)

    if forked:
        click.echo('We found a repository named %s and forked it to your '
                   'user, it now accessible at the following url:\n'
                   '%s' % (forked.full_name, gh_repo.html_url))

    dest_path = os.path.join(projects_path(), project_name)
    click.echo('We will clone %s in %s\n' % (gh_repo.ssh_url, dest_path))

    vgit('clone', gh_repo.ssh_url, dest_path)

    # add our upstream remote
    if gh_repo.parent:
        repo = Repo(dest_path)
        repo.create_remote('upstream', gh_repo.parent.ssh_url)
コード例 #3
0
ファイル: organization.py プロジェクト: AerisCloud/AerisCloud
def init(name, repository):
    """
    Initialize a new organization.

    The following usages are supported:

        cloud organization init <name> <git repository url>

    \b
It will create a new AerisCloud organization and set the origin remote to
the specified url.

    \b
If the GitHub integration is enabled, you can also use the following
commands:

        cloud organization init <github organization name>

    \b
It will create a new AerisCloud organization and set the origin remote to
[email protected]/<organization>/aeriscloud-organization.git

        cloud organization init <github organization name>/<project name>

    \b
It will create a new AerisCloud organization and set the origin remote to
[email protected]/<organization>/<project>-aeriscloud-organization.git

        cloud organization init <org name>/<customer>/<project name>

    \b
It will create a new AerisCloud organization and set the origin remote to
[email protected]/<organization>/<customer>-<project>-aeriscloud-organization.git
"""
    dirname = '-'.join(name.split('/'))

    dest_path = get_env_path(dirname)
    if os.path.exists(dest_path):
        fatal("The organization %s already exists." % dirname)

    # If remote is not specified
    if not repository:
        # If GH integration is enabled
        if has_github_integration():
            gh = Github()

            if '/' in name:
                split = name.split('/')
                name = split[0]
                repo_name = '-'.join(split[1:]) + "-aeriscloud-organization"
            else:
                repo_name = "aeriscloud-organization"

            # If member of the organization
            orgs = [org for org in gh.get_organizations()
                    if org.login.lower() == name.lower()]
            if orgs:
                # If repo exists
                repos = [repo.name for repo in orgs[0].iter_repos()
                         if repo.name.lower() == repo_name.lower()]
                if not repos:
                    # Give instructions to create the repo
                    info("""The repository {repo} has not been found in the {org} organization.
You can create a new repo at the following address: https://github.com/new."""
                         .format(repo=repo_name, org=name))
                    if not click.confirm("Do you want to continue?",
                                         default=False):
                        info("Aborted. Nothing has been done.")
                        return
            # If not member of the organization
            else:
                warning("We were not able to verify the existence of the "
                        "repository as you don't belong to the {org} "
                        "organization.".format(org=name))
                if not click.confirm("Do you want to continue?",
                                     default=False):
                    info("Aborted. Nothing has been done.")
                    return

            repository = "[email protected]:{org}/{repo}.git".format(
                org=name,
                repo=repo_name
            )
        else:
            fatal("You need to specify a repository URL or enable the GitHub "
                  "integration in AerisCloud.")

    archive_url = "https://github.com/AerisCloud/sample-organization/" \
                  "archive/master.tar.gz"

    os.makedirs(dest_path)
    os.chdir(dest_path)
    curl(archive_url,
         o='%s/master.tar.gz' % dest_path,
         silent=True,
         location=True)

    tar = tarfile.open("%s/master.tar.gz" % dest_path, 'r:gz')
    members = [m for m in tar.getmembers() if '/' in m.name]
    for m in members:
        m.name = m.name[m.name.find('/') + 1:]
    tar.extractall(path=dest_path, members=members)
    tar.close()

    os.unlink("%s/master.tar.gz" % dest_path)

    vgit("init")

    move_shell_to(dest_path)
    info("You have been moved to the organization folder.")
    success("The %s organization has been created." % dirname)

    run_galaxy_install(dirname)

    vgit("remote", "add", "origin", repository)

    info("""You can now manage your organization like a standard git repository.
Edit your files, do some commits and push them!""")