Exemple #1
0
            def monitoringAction():
                pendingProcessOutputReadLineTask[0] = ShowRevitProcessOutput(
                    hostRevitProcess.StandardOutput, output,
                    pendingProcessOutputReadLineTask[0])
                pendingProcessErrorReadLineTask[0] = ShowRevitProcessError(
                    hostRevitProcess.StandardError,
                    showRevitProcessErrorMessages, output,
                    pendingProcessErrorReadLineTask[0])
                pendingReadLineTask[0] = ShowRevitScriptOutput(
                    scriptOutputStreamReader, output, pendingReadLineTask[0])

                if time_util.GetSecondsElapsedSinceUtc(
                        progressRecordCheckTimeUtc[0]
                ) > REVIT_PROGRESS_CHECK_INTERVAL_IN_SECONDS:
                    progressRecordCheckTimeUtc[
                        0] = time_util.GetDateTimeUtcNow()
                    progressRecordNumber = ScriptDataUtil.GetProgressNumber(
                        progressRecordFilePath)
                    if progressRecordNumber is not None:
                        if currentProgressRecordNumber[
                                0] != progressRecordNumber:
                            # Progress update detected.
                            currentProgressRecordNumber[
                                0] = progressRecordNumber
                            progressRecordChangedTimeUtc[
                                0] = time_util.GetDateTimeUtcNow()

                if processingTimeOutInMinutes > 0:
                    if currentProgressRecordNumber[0] != 0:
                        if time_util.GetSecondsElapsedSinceUtc(
                                progressRecordChangedTimeUtc[0]) > (
                                    processingTimeOutInMinutes *
                                    SECONDS_PER_MINUTE):
                            output()
                            output(
                                "WARNING: Timed-out waiting for Revit task / file to be processed. Forcibly terminating the Revit process..."
                            )
                            TerminateHostRevitProcess(hostRevitProcess, output)

                if currentProgressRecordNumber[0] == 0:
                    if time_util.GetSecondsElapsedSinceUtc(
                            progressRecordChangedTimeUtc[0]
                    ) > REVIT_PROCESS_BEGIN_PROCESSING_TIMEOUT_IN_SECONDS:
                        output()
                        output(
                            "WARNING: Timed-out waiting for Revit script host to begin task / file processing. Forcibly terminating the Revit process..."
                        )
                        TerminateHostRevitProcess(hostRevitProcess, output)

                if snapshotDataFilesExistTimestamp[0] is not None:
                    if time_util.GetSecondsElapsedSinceUtc(
                            snapshotDataFilesExistTimestamp[0]
                    ) > REVIT_PROCESS_EXIT_TIMEOUT_IN_SECONDS:
                        output()
                        output(
                            "WARNING: Timed-out waiting for the Revit process to exit. Forcibly terminating the Revit process..."
                        )
                        TerminateHostRevitProcess(hostRevitProcess, output)
                elif snapshotDataFilePaths.All(
                        lambda snapshotDataFilePath: File.Exists(
                            snapshotDataFilePath)):
                    output()
                    output(
                        "Detected snapshot data files. Waiting for Revit process to exit..."
                    )
                    snapshotDataFilesExistTimestamp[
                        0] = time_util.GetDateTimeUtcNow()

                try:
                    revit_dialog_detection.DismissCheekyRevitDialogBoxes(
                        hostRevitProcessId, output)
                except Exception, e:
                    output()
                    output(
                        "WARNING: an error occurred in the cheeky Revit dialog box dismisser!"
                    )
                    exception_util.LogOutputErrorDetails(e, output)
Exemple #2
0
                        0] = time_util.GetDateTimeUtcNow()

                try:
                    revit_dialog_detection.DismissCheekyRevitDialogBoxes(
                        hostRevitProcessId, output)
                except Exception, e:
                    output()
                    output(
                        "WARNING: an error occurred in the cheeky Revit dialog box dismisser!"
                    )
                    exception_util.LogOutputErrorDetails(e, output)

                return

            monitor_revit_process.MonitorHostRevitProcess(
                hostRevitProcess, monitoringAction, output)
            return

        stream_io_util.UsingStream(scriptOutputStreamReader,
                                   streamReaderAction)
        return

    stream_io_util.UsingStream(serverStream, serverStreamAction)

    lastProgressNumber = ScriptDataUtil.GetProgressNumber(
        progressRecordFilePath)
    nextProgressNumber = (lastProgressNumber +
                          1) if lastProgressNumber is not None else None

    return nextProgressNumber