Ejemplo n.º 1
0
    def _push_cmd(self, deployment, push_deployment_name, source):
        cmd = None
        if deployment["branch"].startswith("bzr+ssh"):
            rcs = check_installed_rcs("bzr")
            if not rcs:
                raise InputErrorException("BazaarRequiredToPush")

            if source:
                cmd = [rcs, "push", deployment["branch"], "-d", source]
            else:
                cmd = [rcs, "push", deployment["branch"]]
        elif deployment["branch"].startswith("ssh"):
            rcs = check_installed_rcs("git")
            if not rcs:
                raise InputErrorException("GitRequiredToPush")

            if push_deployment_name == "default":
                git_branch = "master"
            else:
                git_branch = push_deployment_name

            if source:
                git_dir = os.path.join(source, ".git")
                cmd = [rcs, "--git-dir=" + git_dir, "push", deployment["branch"], git_branch]
            else:
                cmd = [rcs, "push", deployment["branch"], git_branch]

        return cmd
Ejemplo n.º 2
0
    def push(self, args):
        """
            Push is actually only a shortcut for bzr and git push commands
            that automatically takes care of using the correct repository url.

            It queries the deployment details and uses whatever is in branch.

            If deployment exists will clear the buildpack cache if
            --clear-cache flag is set.

            If no deployment exists we automatically create one.


        """
        if not check_installed_rcs("bzr") and not check_installed_rcs("git"):
            raise InputErrorException("NeitherBazaarNorGitFound")

        if args.deploy and args.ship:
            raise InputErrorException("ShipAndDeploy")

        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        deployment, push_deployment_name = self._get_or_create_deployment(app_name, deployment_name, args.clear_cache)

        cmd = self._push_cmd(deployment, push_deployment_name, args.source)

        try:
            check_call(cmd)
        except CalledProcessError, e:
            print str(e)
            sys.exit(1)
Ejemplo n.º 3
0
Archivo: app.py Proyecto: B-Rich/cctrl
    def by_env():
        """
            Provides the cvs (repo) type by checking environment variable
            PATH for existence of either Bazaar or Git.
        """
        if check_installed_rcs('git'):
            print messages['GitExecutableFound']
            return CVSType.GIT

        if check_installed_rcs('bzr'):
            print messages['BazaarExecutableFound']
            return CVSType.BZR

        return None
Ejemplo n.º 4
0
Archivo: app.py Proyecto: guetux/cctrl
    def by_env():
        """
            Provides the cvs (repo) type by checking environment variable
            PATH for existence of either Bazaar or Git.
        """
        for (execname, cvstype, msg) in [('git', CVSType.GIT, 'GitExecutableFound'),
                                         ('bzr', CVSType.BZR, 'BazaarExecutableFound')]:
            if check_installed_rcs(execname):
                return (cvstype, msg)

        return (None, None)
Ejemplo n.º 5
0
    def by_env():
        """
            Provides the cvs (repo) type by checking environment variable
            PATH for existence of either Bazaar or Git.
        """
        for (execname, cvstype, msg) in [('git', CVSType.GIT, 'GitExecutableFound'),
                                         ('bzr', CVSType.BZR, 'BazaarExecutableFound')]:
            if check_installed_rcs(execname):
                return (cvstype, msg)

        return (None, None)
Ejemplo n.º 6
0
Archivo: app.py Proyecto: guetux/cctrl
    def push(self, args):
        """
            Push is actually only a shortcut for bzr and git push commands
            that automatically takes care of using the correct repository url.

            It queries the deployment details and uses whatever is in branch.

            If no deployment exists we automatically create one.
        """
        if not check_installed_rcs('bzr') and not check_installed_rcs('git'):
            raise InputErrorException('NeitherBazaarNorGitFound')

        #noinspection PyTupleAssignmentBalance
        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        try:
            if deployment_name == '':
                push_deployment_name = 'default'
            else:
                push_deployment_name = deployment_name
            #noinspection PyUnusedLocal
            deployment = self.api.read_deployment(
                app_name,
                push_deployment_name)
        except GoneError:
            push_deployment_name = ''
            if deployment_name != '':
                push_deployment_name = deployment_name
            try:
                deployment = self.api.create_deployment(
                    app_name,
                    deployment_name=push_deployment_name)
            except GoneError:
                raise InputErrorException('WrongApplication')
            except ForbiddenError:
                raise InputErrorException('NotAllowed')

        cmd = None
        if deployment['branch'].startswith('bzr+ssh'):
            rcs = check_installed_rcs('bzr')
            if not rcs:
                raise InputErrorException('BazaarRequiredToPush')
            if args.source:
                cmd = [rcs, 'push', deployment['branch'], '-d', args.source]
            else:
                cmd = [rcs, 'push', deployment['branch']]
        elif deployment['branch'].startswith('ssh'):
            rcs = check_installed_rcs('git')
            if not rcs:
                raise InputErrorException('GitRequiredToPush')
            if push_deployment_name == 'default':
                git_branch = 'master'
            else:
                git_branch = push_deployment_name
            if args.source:
                git_dir = os.path.join(args.source, '.git')
                cmd = [
                    rcs,
                    '--git-dir=' + git_dir,
                    'push',
                    deployment['branch'],
                    git_branch]
            else:
                cmd = [rcs, 'push', deployment['branch'], git_branch]
        try:
            check_call(cmd)
        except CalledProcessError, e:
            print str(e)
Ejemplo n.º 7
0
    def push(self, args):
        """
            Push is actually only a shortcut for bzr and git push commands
            that automatically takes care of using the correct repository url.

            It queries the deployment details and uses whatever is in branch.

            If no deployment exists we automatically create one.
        """
        if not check_installed_rcs('bzr') and not check_installed_rcs('git'):
            raise InputErrorException('NeitherBazaarNorGitFound')

        #noinspection PyTupleAssignmentBalance
        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        try:
            if deployment_name == '':
                push_deployment_name = 'default'
            else:
                push_deployment_name = deployment_name
            #noinspection PyUnusedLocal
            deployment = self.api.read_deployment(
                app_name,
                push_deployment_name)
        except GoneError:
            push_deployment_name = ''
            if deployment_name != '':
                push_deployment_name = deployment_name
            try:
                deployment = self.api.create_deployment(
                    app_name,
                    deployment_name=push_deployment_name)
            except GoneError:
                raise InputErrorException('WrongApplication')
            except ForbiddenError:
                raise InputErrorException('NotAllowed')

        cmd = None
        if deployment['branch'].startswith('bzr+ssh'):
            rcs = check_installed_rcs('bzr')
            if not rcs:
                raise InputErrorException('BazaarRequiredToPush')
            if args.source:
                cmd = [rcs, 'push', deployment['branch'], '-d', args.source]
            else:
                cmd = [rcs, 'push', deployment['branch']]
        elif deployment['branch'].startswith('ssh'):
            rcs = check_installed_rcs('git')
            if not rcs:
                raise InputErrorException('GitRequiredToPush')
            if push_deployment_name == 'default':
                git_branch = 'master'
            else:
                git_branch = push_deployment_name
            if args.source:
                git_dir = os.path.join(args.source, '.git')
                cmd = [
                    rcs,
                    '--git-dir=' + git_dir,
                    'push',
                    deployment['branch'],
                    git_branch]
            else:
                cmd = [rcs, 'push', deployment['branch'], git_branch]
        try:
            check_call(cmd)
        except CalledProcessError, e:
            print str(e)