Пример #1
0
def ExportSnapshotData(sessionId, revitProjectFilePath, snapshotStartTime,
                       snapshotEndTime, dataExportFolderPath,
                       revitJournalFilePath, snapshotError):
    snapshotData = ExportSnapshotDataInternal(
        snapshot_data_util.GetSnapshotDataFilePath(dataExportFolderPath),
        sessionId, revitProjectFilePath, snapshotStartTime, snapshotEndTime,
        dataExportFolderPath, revitJournalFilePath, snapshotError)
    return snapshotData
Пример #2
0
        def streamReaderAction():
            scriptOutputPipeHandleString = serverStream.GetClientHandleAsString(
            )

            def clientHandleAction():
                hostRevitProcess = revit_process_host.StartHostRevitProcess(
                    revitVersion, batchRvtScriptsFolderPath, scriptFilePath,
                    scriptDataFilePath, progressNumber,
                    scriptOutputPipeHandleString, testModeFolderPath)
                return hostRevitProcess

            hostRevitProcess = UsingClientHandle(serverStream,
                                                 clientHandleAction)

            hostRevitProcessId = hostRevitProcess.Id

            global_test_mode.ExportRevitProcessId(hostRevitProcessId)

            snapshotDataFilePaths = [
                snapshot_data_util.GetSnapshotDataFilePath(
                    scriptData.DataExportFolderPath.GetValue())
                for scriptData in scriptDatas
            ]

            pendingReadLineTask = [
                None
            ]  # Needs to be a list so it can be captured by reference in closures.
            pendingProcessOutputReadLineTask = [None]  # As above.
            pendingProcessErrorReadLineTask = [None]  # As above.

            snapshotDataFilesExistTimestamp = [
                None
            ]  # Needs to be a list so it can be captured by reference in closures.

            currentProgressRecordNumber = [
                0
            ]  # Needs to be a list so it can be captured by reference in closures.
            progressRecordCheckTimeUtc = [time_util.GetDateTimeUtcNow()
                                          ]  # As above.
            progressRecordChangedTimeUtc = [time_util.GetDateTimeUtcNow()
                                            ]  # As above.

            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)

                return