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
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)
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
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)
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)
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)
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)