Search in sources :

Example 51 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project DigitalMediaServer by DigitalMediaServer.

the class ChromecastPlayer method startPoll.

public void startPoll() {
    Runnable r = new Runnable() {

        @Override
        public void run() {
            for (; ; ) {
                try {
                    Thread.sleep(1000);
                    Status s1 = api.getStatus();
                    if (s1 == null || !s1.isAppRunning(MediaPlayer)) {
                        continue;
                    }
                    MediaStatus status = api.getMediaStatus();
                    if (status == null) {
                        continue;
                    }
                    state.playback = translateState(status.playerState);
                    Media m = status.media;
                    if (m != null) {
                        if (m.url != null) {
                            state.uri = status.media.url;
                        }
                        if (m.duration != null) {
                            state.duration = StringUtil.convertTimeToString(status.media.duration, "%02d:%02d:%02.0f");
                        }
                    }
                    state.position = StringUtil.convertTimeToString(status.currentTime, "%02d:%02d:%02.0f");
                    if (status.volume != null) {
                        state.volume = status.volume.level.intValue();
                        state.mute = status.volume.muted;
                    }
                    alert();
                } catch (InterruptedException | IOException e) {
                    LOGGER.debug("Bad chromecast mediastate " + e);
                }
            }
        }
    };
    poller = new Thread(r);
    poller.start();
}
Also used : MediaStatus(su.litvak.chromecast.api.v2.MediaStatus) Status(su.litvak.chromecast.api.v2.Status) Media(su.litvak.chromecast.api.v2.Media) IOException(java.io.IOException) MediaStatus(su.litvak.chromecast.api.v2.MediaStatus)

Example 52 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project data-prepper by opensearch-project.

the class OTelProtoHelperTest method testStatusAttributes.

@Test
public void testStatusAttributes() {
    final Status st1 = Status.newBuilder().setCode(Status.StatusCode.STATUS_CODE_ERROR).setMessage("Some message").build();
    final Status st2 = Status.newBuilder().setMessage("error message").build();
    final Status st3 = Status.newBuilder().setCode(Status.StatusCode.STATUS_CODE_UNSET).build();
    final Status st4 = Status.newBuilder().build();
    assertThat(OTelProtoHelper.getSpanStatusAttributes(st1).size() == 2).isTrue();
    assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st1).get(OTelProtoHelper.STATUS_CODE)).equals(st1.getCode())).isTrue();
    assertThat(OTelProtoHelper.getSpanStatusAttributes(st1).get(OTelProtoHelper.STATUS_MESSAGE).equals(st1.getMessage())).isTrue();
    assertThat(OTelProtoHelper.getSpanStatusAttributes(st2).size() == 2).isTrue();
    assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st2).get(OTelProtoHelper.STATUS_CODE)).equals(st2.getCode())).isTrue();
    assertThat(OTelProtoHelper.getSpanStatusAttributes(st3).size() == 1).isTrue();
    assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st3).get(OTelProtoHelper.STATUS_CODE)).equals(st3.getCode())).isTrue();
    assertThat(OTelProtoHelper.getSpanStatusAttributes(st4).size() == 1).isTrue();
    assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st4).get(OTelProtoHelper.STATUS_CODE)).equals(st4.getCode())).isTrue();
}
Also used : Status(io.opentelemetry.proto.trace.v1.Status) Test(org.junit.Test)

Example 53 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project openhab-addons by openhab.

the class ChromecastCommander method handleRefresh.

public void handleRefresh() {
    if (!chromeCast.isConnected()) {
        scheduler.cancelRefresh();
        scheduler.scheduleConnect();
        return;
    }
    Status status;
    try {
        status = chromeCast.getStatus();
        statusUpdater.processStatusUpdate(status);
        if (status == null) {
            scheduler.cancelRefresh();
        }
    } catch (IOException ex) {
        logger.debug("Failed to request status: {}", ex.getMessage());
        statusUpdater.updateStatus(ThingStatus.OFFLINE, COMMUNICATION_ERROR, ex.getMessage());
        scheduler.cancelRefresh();
        return;
    }
    try {
        if (status != null && status.getRunningApp() != null) {
            MediaStatus mediaStatus = chromeCast.getMediaStatus();
            statusUpdater.updateMediaStatus(mediaStatus);
            if (mediaStatus != null && mediaStatus.playerState == MediaStatus.PlayerState.IDLE && mediaStatus.idleReason != null && mediaStatus.idleReason != MediaStatus.IdleReason.INTERRUPTED) {
                stopMediaPlayerApp();
            }
        }
    } catch (IOException ex) {
        logger.debug("Failed to request media status with a running app: {}", ex.getMessage());
    // We were just able to request status, so let's not put the device OFFLINE.
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) MediaStatus(su.litvak.chromecast.api.v2.MediaStatus) Status(su.litvak.chromecast.api.v2.Status) IOException(java.io.IOException) MediaStatus(su.litvak.chromecast.api.v2.MediaStatus)

Example 54 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project geotoolkit by Geomatys.

the class WPS2Process method checkResult.

/**
 * A Function to ensure response object is success or failure. Otherwise, we request continually status until
 * we reach a result.
 *
 * @param response The execute response given by service.
 */
private Result checkResult(Object response) throws IOException, JAXBException, InterruptedException, ProcessException {
    if (response instanceof ExceptionResponse) {
        final ExceptionResponse report = (ExceptionResponse) response;
        throw new ProcessException("Exception when executing the process.", this, report.toException());
    } else if (response instanceof StatusInfo) {
        final StatusInfo statusInfo = (StatusInfo) response;
        Status status = statusInfo.getStatus();
        jobId = statusInfo.getJobID();
        if (Status.SUCCEEDED.equals(status)) {
            fireProgressing("WPS remote process has been successfully executed", 100f, false);
            return null;
        } else if (Status.FAILED.equals(status)) {
            throw new ProcessException("Process failed", this);
        } else if (Status.DISMISS.equals(status)) {
            throw new DismissProcessException("WPS remote process has been canceled", this);
        } else if (Status.ACCEPTED.equals(status)) {
            // Initial status
            fireProgressing("Process accepted: " + jobId, 0, false);
        } else {
            // Running
            final Integer progress = statusInfo.getPercentCompleted();
            // Not in the standard
            String message = statusInfo.getMessage();
            if (message == null || (message = message.trim()).isEmpty()) {
                message = status.name();
            }
            fireProgressing(message, progress == null ? Float.NaN : progress, false);
        }
        // loop until we have an answer
        Object tmpResponse;
        // TODO : make timelapse configurable
        int timeLapse = 3000;
        // we tolerate a few unmarshalling or IO errors, the servers behave differentely
        // and may not offer the result file right from the start
        int failCount = 0;
        while (true) {
            stopIfDismissed();
            synchronized (this) {
                wait(timeLapse);
            }
            try {
                tmpResponse = getStatus();
                failCount = 0;
            } catch (UnmarshalException | IOException ex) {
                if (failCount < 5 && !isDimissed()) {
                    failCount++;
                    continue;
                } else if (isDimissed()) {
                    throw new DismissProcessException("WPS remote process has been canceled", this);
                } else {
                    // happenning so we consider the process failed
                    throw ex;
                }
            }
            if (tmpResponse instanceof StatusInfo) {
                final StatusInfo statInfo = (StatusInfo) tmpResponse;
                status = statInfo.getStatus();
                if (Status.SUCCEEDED.equals(status)) {
                    fireProgressing("WPS remote process has been successfully executed", 100f, false);
                    return null;
                } else if (Status.FAILED.equals(status)) {
                    throw new ProcessException("Process failed", this);
                } else if (Status.DISMISS.equals(status)) {
                    throw new DismissProcessException("WPS remote process has been canceled", this);
                }
                // Not in the standard
                String message = statusInfo.getMessage();
                if (message == null || (message = message.trim()).isEmpty()) {
                    message = status.name();
                }
                final Integer percentCompleted = statInfo.getPercentCompleted();
                if (!Objects.equals(message, lastMessage) || !Objects.equals(percentCompleted, lastProgress)) {
                    lastMessage = message;
                    lastProgress = percentCompleted;
                    fireProgressing(lastMessage, lastProgress, false);
                }
            } else if (tmpResponse instanceof ExceptionResponse) {
                final ExceptionResponse report = (ExceptionResponse) tmpResponse;
                throw new ProcessException("Exception when executing the process.", this, report.toException());
            }
        }
    } else if (response instanceof Result) {
        final Result result = checkLegacyResult((Result) response);
        if (result.getJobID() != null) {
            jobId = result.getJobID();
        }
        return result;
    } else {
        throw new ProcessException("Unexpected response " + response, this);
    }
}
Also used : Status(org.geotoolkit.wps.xml.v200.Status) LegacyStatus(org.geotoolkit.wps.xml.v100.LegacyStatus) ProcessException(org.geotoolkit.process.ProcessException) DismissProcessException(org.geotoolkit.process.DismissProcessException) ExceptionResponse(org.geotoolkit.ows.xml.ExceptionResponse) StatusInfo(org.geotoolkit.wps.xml.v200.StatusInfo) DismissProcessException(org.geotoolkit.process.DismissProcessException) Result(org.geotoolkit.wps.xml.v200.Result)

Example 55 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project theta by ftsrg.

the class Z3Solver method check.

@Override
public SolverStatus check() {
    final Status z3Status = z3Solver.check();
    status = transformStatus(z3Status);
    return status;
}
Also used : SolverStatus(hu.bme.mit.theta.solver.SolverStatus) Status(com.microsoft.z3.Status)

Aggregations

Status (com.microsoft.z3.Status)63 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)49 Test (org.junit.jupiter.api.Test)17 Expr (com.microsoft.z3.Expr)10 IOException (java.io.IOException)10 JsonMapper.convertObjectToJsonString (com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString)9 RandomDataGenerator.generateRandomAlphabeticString (com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString)9 Status (com.arbindo.mimock.manage.mimocks.models.v1.Status)9 Context (com.microsoft.z3.Context)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)9 Pageable (org.springframework.data.domain.Pageable)9 HttpStatus (org.springframework.http.HttpStatus)9 MvcResult (org.springframework.test.web.servlet.MvcResult)9 Mock (com.arbindo.mimock.entities.Mock)8 List (java.util.List)7 Solver (com.microsoft.z3.Solver)6 PageImpl (org.springframework.data.domain.PageImpl)6