'Run command from this environment
Use ``cls`` to instantiate a command
:param warn_only: Don\'t raise an exception on command failure'

def run_command_class(self, cls, cmd, **kwargs):

    warn_only = kwargs.pop('warn_only', False)
    env_path = self.environment.pop('BIN_PATH', None)
    if (('bin_path' not in kwargs) and env_path):
        kwargs['bin_path'] = env_path
    assert ('environment' not in kwargs), "environment    can't    be    passed    in    via    commands."
    kwargs['environment'] = self.environment
    kwargs['build_env'] = self
    build_cmd = cls(cmd, **kwargs)
    self.commands.append(build_cmd)
    build_cmd.run()
    if self.record:
        build_cmd.save()
    if build_cmd.failed:
        msg = u'Command    {cmd}    failed'.format(cmd=build_cmd.get_command())
        if build_cmd.output:
            msg += u':\n{out}'.format(out=build_cmd.output)
        if warn_only:
            log.warn(LOG_TEMPLATE.format(project=self.project.slug, version=self.version.slug, msg=msg))
        else:
            raise BuildEnvironmentWarning(msg)
    return build_cmd
