diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index 13fc79c0..034bd279 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -34,7 +34,7 @@ jobs: - name: Install Python dependences run: | python -m pip install flit - flit install --only-deps # Install the dependencies, but not the EasyDiffractionApp package itself + flit install --only-deps # Install the dependencies, but not the EasyReflectometryApp package itself - name: Add extra info to pyproject.toml run: python utils.py --update diff --git a/.github/workflows/snapcraft.yml b/.github/workflows/snapcraft.yml index ae6064c0..49e38459 100644 --- a/.github/workflows/snapcraft.yml +++ b/.github/workflows/snapcraft.yml @@ -43,7 +43,7 @@ jobs: echo "DISPLAY=:0" >> $GITHUB_ENV - name: Run snap run: | - snap run easydiffraction & + snap run easyreflectometry & sleep 60 upload_snap: diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/AnalysisView.qml b/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/AnalysisView.qml index db10ca5b..42481d5c 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/AnalysisView.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/AnalysisView.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/diffraction_AnalysisView.qml b/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/diffraction_AnalysisView.qml deleted file mode 100644 index 42a45bd3..00000000 --- a/EasyReflectometryApp/Gui/Pages/Analysis/MainContent/diffraction_AnalysisView.qml +++ /dev/null @@ -1,570 +0,0 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors -// SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project - -import QtQuick -import QtQuick.Controls -import QtCharts - -import EasyApp.Gui.Style as EaStyle -import EasyApp.Gui.Globals as EaGlobals -import EasyApp.Gui.Elements as EaElements -import EasyApp.Gui.Charts as EaCharts - -import Gui.Globals as Globals - - -Column { - id: container - - property alias measSerie: measSerie - property alias bkgSerie: bkgSerie - property alias calcSerie: calcSerie - property alias residSerie: residSerie - - property var phaseNames: { - if (typeof Globals.Proxies.main.experiment.dataBlocksNoMeas[ - Globals.Proxies.main.experiment.currentIndex].loops._pd_phase_block !== 'undefined') { - return Globals.Proxies.main.experiment.dataBlocksNoMeas[ - Globals.Proxies.main.experiment.currentIndex].loops._pd_phase_block.map( - phase => phase.id.value) - } else if (typeof Globals.Proxies.main.experiment.dataBlocksNoMeas[ - Globals.Proxies.main.experiment.currentIndex].loops._exptl_crystal !== 'undefined') { - return Globals.Proxies.main.experiment.dataBlocksNoMeas[ - Globals.Proxies.main.experiment.currentIndex].loops._exptl_crystal.map( - phase => phase.id.value) - } else { - //console.error('No phase names found') - return [] - } - } - - property string calcSerieColor: EaStyle.Colors.chartForegrounds[0] - - property int extraMargin: -12 - property real residualToMainChartHeightRatio: 0.3 - property real mainChartHeightCoeff: 1 - residualToMainChartHeightRatio - - property bool useOpenGL: Globals.Proxies.main.fitting.isFittingNow ? - true : - EaGlobals.Vars.useOpenGL //Globals.Proxies.main.plotting.useWebGL1d - - Column { - width: parent.width - height: parent.height - 3 * EaStyle.Sizes.fontPixelSize + 2 - - /////////////////////////////////////////// - // Main chart container: Imeas, Icalc, Ibkg - /////////////////////////////////////////// - - Item { - width: parent.width - height: parent.height * mainChartHeightCoeff - - braggChart.parent.height * 0.5 - - EaCharts.QtCharts1dBase { - id: mainChart - - property var experimentDataBlocksNoMeas: Globals.Proxies.main.experiment.dataBlocksNoMeas - onExperimentDataBlocksNoMeasChanged: { - if (Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd') { - if (Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type').value === 'cwl') { - axisX.title = '2θ (degree)' - } else if (Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type').value === 'tof') { - axisX.title = 'TOF (µs)' - } else { - axisX.title = '' - } - } else if (Globals.Proxies.experimentMainParam('_sample', 'type').value === 'sg') { - axisX.title = 'sinθ/λ (Å⁻¹)' - } else { - axisX.title = '' - } - } - - anchors.topMargin: EaStyle.Sizes.toolButtonHeight - EaStyle.Sizes.fontPixelSize - 1 - anchors.bottomMargin: -12 - EaStyle.Sizes.fontPixelSize - - useOpenGL: container.useOpenGL - - axisX.titleVisible: false - axisX.labelsVisible: false - axisX.min: Globals.Proxies.rangeValue('xMin') - axisX.max: Globals.Proxies.rangeValue('xMax') - axisX.minAfterReset: Globals.Proxies.rangeValue('xMin') - axisX.maxAfterReset: Globals.Proxies.rangeValue('xMax') - axisX.onRangeChanged: alignAllCharts() - - axisY.title: Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd' ? - "Imeas, Icalc, Ibkg" : - "Imeas, Icalc" - axisY.min: Globals.Proxies.rangeValue('yMin') - axisY.max: Globals.Proxies.rangeValue('yMax') - axisY.minAfterReset: Globals.Proxies.rangeValue('yMin') - axisY.maxAfterReset: Globals.Proxies.rangeValue('yMax') - axisY.onRangeChanged: adjustResidualChartRangeY() - - backgroundColor: "transparent" - plotAreaColor: "transparent" - - // Measured points - /* - ScatterSeries { - id: measSerie - - axisX: mainChart.axisX - axisY: mainChart.axisY - - useOpenGL: mainChart.useOpenGL - - markerSize: 5 - borderWidth: 1 - color: EaStyle.Colors.chartForegroundsExtra[2] - borderColor: this.color - } - */ - LineSeries { - id: measSerie - - axisX: mainChart.axisX - axisY: mainChart.axisY - - //useOpenGL: mainChart.useOpenGL - - color: EaStyle.Colors.chartForegroundsExtra[2] - width: 2 - - //style: Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd' ? - // Qt.SolidLine : - // Qt.NoPen - pointsVisible: true - - onHovered: (point, state) => showMainTooltip(mainChart, point, state) - } - - // Background curve - LineSeries { - id: bkgSerie - - axisX: mainChart.axisX - axisY: mainChart.axisY - - //useOpenGL: mainChart.useOpenGL - - color: EaStyle.Colors.chartForegrounds[1] - width: 1 - - onHovered: (point, state) => showMainTooltip(mainChart, point, state) - } - - // Calculated curve - LineSeries { - id: calcSerie - - axisX: mainChart.axisX - axisY: mainChart.axisY - - //useOpenGL: mainChart.useOpenGL - - color: calcSerieColor - width: 2 - - //style: Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd' ? - // Qt.SolidLine : - // Qt.NoPen - //pointsVisible: Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd' ? - // false : - // true - - onHovered: (point, state) => showMainTooltip(mainChart, point, state) - } - - // Tool buttons - Row { - id: toolButtons - - x: mainChart.plotArea.x + mainChart.plotArea.width - width - y: mainChart.plotArea.y - height - EaStyle.Sizes.fontPixelSize - - spacing: 0.25 * EaStyle.Sizes.fontPixelSize - - EaElements.TabButton { - checked: Globals.Vars.showLegendOnAnalysisPage - autoExclusive: false - height: EaStyle.Sizes.toolButtonHeight - width: EaStyle.Sizes.toolButtonHeight - borderColor: EaStyle.Colors.chartAxis - fontIcon: "align-left" - ToolTip.text: Globals.Vars.showLegendOnAnalysisPage ? - qsTr("Hide legend") : - qsTr("Show legend") - onClicked: Globals.Vars.showLegendOnAnalysisPage = checked - } - - EaElements.TabButton { - checked: mainChart.allowHover - autoExclusive: false - height: EaStyle.Sizes.toolButtonHeight - width: EaStyle.Sizes.toolButtonHeight - borderColor: EaStyle.Colors.chartAxis - fontIcon: "comment-alt" - ToolTip.text: qsTr("Show coordinates tooltip on hover") - onClicked: mainChart.allowHover = !mainChart.allowHover - } - - Item { height: 1; width: 0.5 * EaStyle.Sizes.fontPixelSize } // spacer - - EaElements.TabButton { - checked: !mainChart.allowZoom - autoExclusive: false - height: EaStyle.Sizes.toolButtonHeight - width: EaStyle.Sizes.toolButtonHeight - borderColor: EaStyle.Colors.chartAxis - fontIcon: "arrows-alt" - ToolTip.text: qsTr("Enable pan") - onClicked: mainChart.allowZoom = !mainChart.allowZoom - } - - EaElements.TabButton { - checked: mainChart.allowZoom - autoExclusive: false - height: EaStyle.Sizes.toolButtonHeight - width: EaStyle.Sizes.toolButtonHeight - borderColor: EaStyle.Colors.chartAxis - fontIcon: "expand" - ToolTip.text: qsTr("Enable box zoom") - onClicked: mainChart.allowZoom = !mainChart.allowZoom - } - - EaElements.TabButton { - checkable: false - height: EaStyle.Sizes.toolButtonHeight - width: EaStyle.Sizes.toolButtonHeight - borderColor: EaStyle.Colors.chartAxis - fontIcon: "backspace" - ToolTip.text: qsTr("Reset axes") - onClicked: mainChart.resetAxes() - } - - } - // Tool buttons - } - } - - ////////////////////////////////////// - // Bragg peaks chart container: Bragg - ////////////////////////////////////// - - Item { - z: -1 - width: parent.width - height: (0.5 + 1.5 * phaseNames.length) * EaStyle.Sizes.fontPixelSize - - - /////onHeightChanged: console.info(`================== ${height} - ${phaseNames.length}`) - //visible: false - - EaCharts.QtCharts1dBase { - id: braggChart - - anchors.topMargin: -12 - EaStyle.Sizes.fontPixelSize * 1.5 - anchors.bottomMargin: -12 - EaStyle.Sizes.fontPixelSize * 1.5 - - useOpenGL: container.useOpenGL - - axisX.min: mainChart.axisX.min - axisX.max: mainChart.axisX.max - axisX.titleVisible: false - axisX.labelsVisible: false - - axisY.min: -0.5 * phaseNames.length - axisY.max: 0.5 - axisY.titleVisible: false - axisY.labelsVisible: false - axisY.tickCount: 2 - - backgroundColor: "transparent" - plotAreaColor: "transparent" - - //onSeriesAdded: { console.error(series) } - - /* - ScatterSeries { - id: braggSerie - - axisX: braggChart.axisX - axisY: braggChart.axisY - - //useOpenGL: braggChart.useOpenGL - - brush: Globals.Proxies.main.plotting.verticalLine( - 1.5 * EaStyle.Sizes.fontPixelSize, - EaStyle.Colors.chartForegroundsExtra[0]) - borderWidth: 0.001 - borderColor: 'transparent' - - Component.onCompleted: console.error(this) - } - */ - } - } - - ////////////////////////////////////////// - // Residual chart container: Imeas - Icalc - ////////////////////////////////////////// - - Item { - width: parent.width - height: parent.height * residualToMainChartHeightRatio - - braggChart.parent.height * 0.5 - - EaCharts.QtCharts1dBase { - id: residualChart - - anchors.topMargin: -12 - EaStyle.Sizes.fontPixelSize - - useOpenGL: container.useOpenGL - - axisX.min: mainChart.axisX.min - axisX.max: mainChart.axisX.max - axisX.titleVisible: false - axisX.labelsVisible: false - - axisY.min: Globals.Proxies.main.plotting.chartRanges.yMin - axisY.max: Globals.Proxies.main.plotting.chartRanges.yMax - axisY.tickType: ValueAxis.TicksFixed - axisY.tickCount: 3 - axisY.title: 'Imeas - Icalc' - - backgroundColor: "transparent" - plotAreaColor: "transparent" - - LineSeries { - id: residSerie - - axisX: residualChart.axisX - axisY: residualChart.axisY - - //useOpenGL: residualChart.useOpenGL - - color: EaStyle.Colors.chartForegrounds[2] - - onHovered: (point, state) => showMainTooltip(residualChart, point, state) - } - } - } - } - - ///////////////////////// - // X-axis chart container - ///////////////////////// - - Item { - z: -1 - width: parent.width - height: container.height - parent: container.parent - - EaCharts.QtCharts1dBase { - id: xAxisChart - - axisX.title: mainChart.axisX.title - axisX.min: mainChart.axisX.min - axisX.max: mainChart.axisX.max - axisX.lineVisible: false - axisX.gridVisible: false - - axisY.titleVisible: false - axisY.labelsVisible: false - axisY.visible: false - - LineSeries { - axisX: xAxisChart.axisX - axisY: xAxisChart.axisY - - Component.onCompleted: initialChartsSetupTimer.start() - - Timer { - id: initialChartsSetupTimer - interval: 50 - onTriggered: { - alignAllCharts() - adjustResidualChartRangeY() - } - } - } - } - } - - ///////// - // Legend - ///////// - - Rectangle { - visible: Globals.Vars.showLegendOnAnalysisPage - parent: container.parent - - x: mainChart.plotArea.x + mainChart.plotArea.width - width - 12 - EaStyle.Sizes.fontPixelSize - y: mainChart.plotArea.y - 12 + EaStyle.Sizes.fontPixelSize + mainChart.anchors.topMargin + EaStyle.Sizes.fontPixelSize - 1 - width: childrenRect.width - height: childrenRect.height - - color: EaStyle.Colors.mainContentBackgroundHalfTransparent - border.color: EaStyle.Colors.chartGridLine - - Column { - id: legendColumn - - leftPadding: EaStyle.Sizes.fontPixelSize - rightPadding: EaStyle.Sizes.fontPixelSize - topPadding: EaStyle.Sizes.fontPixelSize * 0.5 - bottomPadding: EaStyle.Sizes.fontPixelSize * 0.5 - - EaElements.Label { - text: '━ Measured (Imeas)' - color: measSerie.color - } - EaElements.Label { - text: Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd' ? - '━ Total calculated (Icalc)' : - '━ Calculated (Icalc)' - color: calcSerie.color - } - EaElements.Label { - visible: Globals.Proxies.experimentMainParam('_sample', 'type').value === 'pd' - text: '─ Background (Ibkg)' - color: bkgSerie.color - } - EaElements.Label { - text: '━ Residual (Imeas - Icalc)' - color: residSerie.color - } - /* - EaElements.Label { - text: '│ Ibragg (Bragg peaks)' - color: EaStyle.Colors.chartForegroundsExtra[0] //braggSerie.color - } - */ - } - } - - /////////// - // ToolTips - /////////// - - EaElements.ToolTip { - id: dataToolTip - - arrowLength: 0 - textFormat: Text.RichText - } - - // Save references to chart series to be accessible from Python for updating data - Component.onCompleted: { - Globals.Refs.app.analysisPage.plotView = this - Globals.Proxies.main.plotting.setQtChartsSerieRef('analysisPage', - 'measSerie', - this.measSerie) - Globals.Proxies.main.plotting.setQtChartsSerieRef('analysisPage', - 'bkgSerie', - this.bkgSerie) - Globals.Proxies.main.plotting.setQtChartsSerieRef('analysisPage', - 'totalCalcSerie', - this.calcSerie) - Globals.Proxies.main.plotting.setQtChartsSerieRef('analysisPage', - 'residSerie', - this.residSerie) - //Globals.Proxies.main.plotting.setQtChartsSerieRef('analysisPage', - // 'braggSerie', - // this.braggSerie) - createBraggSeries() - - Globals.Proxies.main.analysis.defined = true - } - - // Logic - - function residualChartMeanY() { - return 0 - } - - function residualChartHalfRangeY() { - if (mainChart.plotArea.height === 0) { - return 0.5 - } - - const mainChartRangeY = mainChart.axisY.max - mainChart.axisY.min - const residualToMainChartHeightRatio = residualChart.plotArea.height / mainChart.plotArea.height - const residualChartRangeY = mainChartRangeY * residualToMainChartHeightRatio - return 0.5 * residualChartRangeY - } - - function adjustResidualChartRangeY() { - residualChart.axisY.min = residualChartMeanY() - residualChartHalfRangeY() - residualChart.axisY.max = residualChartMeanY() + residualChartHalfRangeY() - console.debug('Residual chart Y-range has been adjusted') - } - - function alignAllCharts() { - xAxisChart.plotArea.width -= mainChart.plotArea.x - xAxisChart.plotArea.x - xAxisChart.plotArea.x = mainChart.plotArea.x - residualChart.plotArea.width = xAxisChart.plotArea.width - residualChart.plotArea.x = mainChart.plotArea.x - braggChart.plotArea.width = xAxisChart.plotArea.width - braggChart.plotArea.x = mainChart.plotArea.x - mainChart.plotArea.width = xAxisChart.plotArea.width - console.debug('All charts have been aligned') - } - - function showMainTooltip(chart, point, state) { - if (!mainChart.allowHover) { - return - } - const pos = chart.mapToPosition(Qt.point(point.x, point.y)) - dataToolTip.x = pos.x - dataToolTip.y = pos.y - dataToolTip.text = `

x: ${point.x.toFixed(2)}y: ${point.y.toFixed(2)}

` - dataToolTip.parent = chart - dataToolTip.visible = state - } - - function createBraggSeries() { - for (const phaseIdx in phaseNames) { - const phaseName = phaseNames[phaseIdx] - const serie = braggChart.createSeries(ChartView.SeriesTypeScatter, - phaseName, - braggChart.axisX, - braggChart.axisY) - const markerSize = //serie.useOpenGL ? - //5 : // don't work here... :( - 1.5 * EaStyle.Sizes.fontPixelSize - serie.useOpenGL = braggChart.useOpenGL - //serie.useOpenGL = Globals.Proxies.main.fitting.isFittingNow - serie.brush = Globals.Proxies.main.plotting.verticalLine( - markerSize, - EaStyle.Colors.models[phaseIdx]) - serie.borderWidth = 0.001 - serie.borderColor = 'transparent' - //serie.markerShape = ScatterSeries.MarkerShapeRectangle - serie.markerSize = serie.useOpenGL ? - 0 : - markerSize - - Globals.Proxies.main.plotting.setQtChartsSerieRef('analysisPage', - 'braggSeries', - serie) - - const legendItem = Qt.createQmlObject('import EasyApp.Gui.Elements as EaElements; EaElements.Label {}', legendColumn) - const textFont = `'${EaStyle.Fonts.fontFamily}'` - const iconFont = `'${EaStyle.Fonts.iconsFamily}'` - const textColor = `'${EaStyle.Colors.models[phaseIdx]}'` - const iconColor = `'${EaStyle.Colors.models[phaseIdx]}'` - const textHtmlStart = `│  Bragg peaks` - const iconHtml = `layer-group` - const textHtmlEnd = `${phaseName}` - legendItem.text = `${textHtmlStart} ${iconHtml} ${textHtmlEnd}` - legendItem.textFormat = Text.RichText - } - } - -} diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Calculator.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Calculator.qml index 8200ed16..43fb39cf 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Calculator.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Calculator.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Minimizer.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Minimizer.qml index 4f26a385..1ffc6a13 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Minimizer.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/Minimizer.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/ParamNames.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/ParamNames.qml index 5d148b89..657b2ddb 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/ParamNames.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Groups/ParamNames.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Layout.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Layout.qml index 1168f404..f43769f5 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Layout.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Advanced/Layout.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Experiments.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Experiments.qml index 0195cd68..81b3e0d3 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Experiments.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Experiments.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fittables.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fittables.qml index 1c270c77..e554935f 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fittables.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fittables.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fitting.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fitting.qml index a7f72830..e6e55391 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fitting.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Groups/Fitting.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Layout.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Layout.qml index 81b534cf..cad9d29f 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Layout.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Layout.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick diff --git a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Popups/FitStatusDialog.qml b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Popups/FitStatusDialog.qml index d294c6b6..0866adb1 100644 --- a/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Popups/FitStatusDialog.qml +++ b/EasyReflectometryApp/Gui/Pages/Analysis/Sidebar/Basic/Popups/FitStatusDialog.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Experiment/MainContent/ExperimentView.qml b/EasyReflectometryApp/Gui/Pages/Experiment/MainContent/ExperimentView.qml index 89686a64..c5be5eb3 100644 --- a/EasyReflectometryApp/Gui/Pages/Experiment/MainContent/ExperimentView.qml +++ b/EasyReflectometryApp/Gui/Pages/Experiment/MainContent/ExperimentView.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SampleView.qml b/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SampleView.qml index cce12f8d..2784801e 100644 --- a/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SampleView.qml +++ b/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SampleView.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SldView.qml b/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SldView.qml index 7d16f5af..c330a276 100644 --- a/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SldView.qml +++ b/EasyReflectometryApp/Gui/Pages/Sample/MainContent/SldView.qml @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2023 EasyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2023 Contributors to the EasyDiffraction project +// © 2023 Contributors to the EasyReflectometry project import QtQuick import QtQuick.Controls diff --git a/pyproject.toml b/pyproject.toml index a7c9f655..bd4a352d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -186,7 +186,7 @@ manual_exclude = [ 'mfc*', 'msvcp*', 'VCRUNTIME*', '*Qt*Bluetooth*', '*Qt*Bodymo '*Qt*Scxml*', '*Qt*Sensors*', '*Qt*Sql*', '*Qt*VirtualKeyboard*', '*Qt*Wayland*' ] [ci.app.setup.ftp] -host = 'ftp.easydiffraction.org' +host = 'ftp.easyreflectometry.org' port = 21 user = 'u652432322.ci' prefix = 'download' diff --git a/tools/Scripts/CheckAppExists.py b/tools/Scripts/CheckAppExists.py index 2a7c4190..d7bfe514 100644 --- a/tools/Scripts/CheckAppExists.py +++ b/tools/Scripts/CheckAppExists.py @@ -1,25 +1,29 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys +import os import pathlib -import Functions, Config +import sys +import Config +import Functions CONFIG = Config.Config() + def appExePath(): d = { 'macos': os.path.join(CONFIG.installation_dir, CONFIG.app_full_name, 'Contents', 'MacOS', CONFIG.app_name), 'ubuntu': os.path.join(CONFIG.installation_dir, CONFIG.app_name, CONFIG.app_full_name), - 'windows': os.path.join(CONFIG.installation_dir, CONFIG.app_name, CONFIG.app_full_name) + 'windows': os.path.join(CONFIG.installation_dir, CONFIG.app_name, CONFIG.app_full_name), } return d[CONFIG.os] + def checkAppExists(): Functions.printNeutralMessage(f'Check if application exe file exists: {appExePath()}') message = f'find {appExePath()}' @@ -30,5 +34,6 @@ def checkAppExists(): Functions.printFailMessage(message) sys.exit(1) -if __name__ == "__main__": + +if __name__ == '__main__': checkAppExists() diff --git a/tools/Scripts/Config.py b/tools/Scripts/Config.py index 867f1fec..5c59a9a9 100644 --- a/tools/Scripts/Config.py +++ b/tools/Scripts/Config.py @@ -1,6 +1,6 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project __author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' diff --git a/tools/Scripts/FreezeApp.py b/tools/Scripts/FreezeApp.py index 44e0583f..705d4122 100755 --- a/tools/Scripts/FreezeApp.py +++ b/tools/Scripts/FreezeApp.py @@ -1,6 +1,6 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project import glob import os diff --git a/tools/Scripts/Functions.py b/tools/Scripts/Functions.py index 0d9c7e26..02d971f7 100755 --- a/tools/Scripts/Functions.py +++ b/tools/Scripts/Functions.py @@ -1,22 +1,24 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys -import toml -import zipfile -import subprocess -import requests -import shutil +import os import platform +import shutil +import subprocess +import sys +import zipfile from distutils import dir_util +import requests +import toml # FUNCTIONS + def coloredText(message='', style='1', background_color='49m', text_color='39'): # http://ozzmaker.com/add-colour-to-text-in-python/ escape = '\033[' @@ -157,7 +159,7 @@ def createFile(path, content): return try: message = f'create file {path}' - with open(path, "w") as file: + with open(path, 'w') as file: file.write(content) except Exception as exception: printFailMessage(message, exception) @@ -256,7 +258,7 @@ def dict2xml(d, root_node=None, add_xml_version=True): elif key[0] == '@': attr = attr + ' ' + key[1::] + '="' + str(value) + '"' else: - xml = '<' + key + ">" + str(value) + '' + xml = '<' + key + '>' + str(value) + '' children.append(xml) elif isinstance(d, list): @@ -264,7 +266,7 @@ def dict2xml(d, root_node=None, add_xml_version=True): children.append(dict2xml(value, root_node=root, add_xml_version=False)) else: - raise TypeError(f"Type {type(d)} is not supported") + raise TypeError(f'Type {type(d)} is not supported') end_tag = '>' if children else '/>' @@ -272,7 +274,7 @@ def dict2xml(d, root_node=None, add_xml_version=True): xml = '<' + root + attr + end_tag if children: - xml += "".join(children) + xml += ''.join(children) if wrap: xml += '' @@ -324,7 +326,7 @@ def zip(source, destination): arcpath = os.path.join(rootdirname, parentpath) zf.write(filepath, arcpath) else: - printFailMessage(message + ": It is a special file (socket, FIFO, device file)") + printFailMessage(message + ': It is a special file (socket, FIFO, device file)') sys.exit() except Exception as exception: printFailMessage(message, exception) diff --git a/tools/Scripts/InstallApp.py b/tools/Scripts/InstallApp.py index 0938c347..63cfc86d 100644 --- a/tools/Scripts/InstallApp.py +++ b/tools/Scripts/InstallApp.py @@ -1,33 +1,33 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys -import Functions, Config +import os +import sys + +import Config +import Functions CONFIG = Config.Config(sys.argv[1], sys.argv[2]) def setupExePath(): d = { - 'macos': os.path.join(CONFIG.setup_full_name, 'Contents', 'MacOS', CONFIG.setup_name), - 'ubuntu': CONFIG.setup_full_name, - 'windows': CONFIG.setup_full_name + 'macos': os.path.join(CONFIG.setup_full_name, 'Contents', 'MacOS', CONFIG.setup_name), + 'ubuntu': CONFIG.setup_full_name, + 'windows': CONFIG.setup_full_name, } return os.path.join(CONFIG.dist_dir, d[CONFIG.os]) + def fixPermissions(): if CONFIG.os == 'macos' or 'ubuntu': try: message = f'fixing permissions for os {CONFIG.os}' - Functions.run( - 'chmod', - '+x', - setupExePath() - ) + Functions.run('chmod', '+x', setupExePath()) except Exception as exception: Functions.printFailMessage(message, exception) sys.exit(1) @@ -36,17 +36,11 @@ def fixPermissions(): else: Functions.printNeutralMessage(f'No fixing permissions needed for os {CONFIG.os}') + def runInstallerSilently(): try: message = f'install {CONFIG.app_name}' - Functions.run( - setupExePath(), - 'install', - '--verbose', - '--confirm-command', - '--default-answer', - '--accept-licenses' - ) + Functions.run(setupExePath(), 'install', '--verbose', '--confirm-command', '--default-answer', '--accept-licenses') except Exception as exception: Functions.printFailMessage(message, exception) sys.exit(1) @@ -54,6 +48,6 @@ def runInstallerSilently(): Functions.printSuccessMessage(message) -if __name__ == "__main__": +if __name__ == '__main__': fixPermissions() runInstallerSilently() diff --git a/tools/Scripts/InstallerControlScript.js b/tools/Scripts/InstallerControlScript.js index ce9107e0..6d992bd8 100644 --- a/tools/Scripts/InstallerControlScript.js +++ b/tools/Scripts/InstallerControlScript.js @@ -1,47 +1,39 @@ -// SPDX-FileCopyrightText: 2023 easyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2021-2022 Contributors to the easyDiffraction project +// © 2021-2022 Contributors to the EasyReflectometry project -function Controller() -{ +function Controller() { } -Controller.prototype.IntroductionPageCallback = function() -{ +Controller.prototype.IntroductionPageCallback = function () { var page = gui.currentPageWidget() - if (page != null) - { - if (installer.isInstaller()) - { + if (page != null) { + if (installer.isInstaller()) { var msg = "" - msg += "

Welcome to the EasyDiffraction Setup Wizard.

" - msg += "

EasyDiffraction is a scientific software for modelling and analysis of diffraction data.

" - msg += "

For more details, please visit https://easydiffraction.org

" + msg += "

Welcome to the EasyReflectometry Setup Wizard.

" + msg += "

EasyReflectometry is a scientific software for modelling and analysis of reflectivity data.

" + msg += "

For more details, please visit https://easyreflectometry.org

" page.MessageLabel.setText(msg) } - if (installer.isUninstaller()) - { + if (installer.isUninstaller()) { //gui.clickButton(buttons.NextButton) } - if (installer.isUpdater()) - { + if (installer.isUpdater()) { //gui.clickButton(buttons.NextButton) } } } -Controller.prototype.LicenseAgreementPageCallback = function() -{ +Controller.prototype.LicenseAgreementPageCallback = function () { //console.log("* enter LicenseAgreementPage") //var page = gui.currentPageWidget() //if (page != null) //{ - //page.AcceptLicenseRadioButton.setChecked(true) + //page.AcceptLicenseRadioButton.setChecked(true) //} } -Controller.prototype.FinishedPageCallback = function() -{ +Controller.prototype.FinishedPageCallback = function () { //console.log("* buttons, buttons.CommitButton:", buttons, buttons.CommitButton) // Try to hide 'Restart' button on the 'Finished' page // 1: doesn't work - TypeError: Property 'hide' of object 2 is not a function diff --git a/tools/Scripts/InstallerInstallScript.js b/tools/Scripts/InstallerInstallScript.js index f6c2c4ad..4d36d50f 100644 --- a/tools/Scripts/InstallerInstallScript.js +++ b/tools/Scripts/InstallerInstallScript.js @@ -1,9 +1,8 @@ -// SPDX-FileCopyrightText: 2023 easyDiffraction contributors +// SPDX-FileCopyrightText: 2023 EasyReflectometry contributors // SPDX-License-Identifier: BSD-3-Clause -// © 2021-2022 Contributors to the easyDiffraction project +// © 2021-2022 Contributors to the EasyReflectometry project -function Component() -{ +function Component() { //console.log("* isInstaller:", installer.isInstaller()) //console.log("* isUninstaller:", installer.isUninstaller()) //console.log("* isUpdater:", installer.isUpdater()) @@ -11,59 +10,52 @@ function Component() //if (installer.isInstaller() || installer.isUpdater()) //{ - installer.setDefaultPageVisible(QInstaller.ComponentSelection, false) - installer.installationStarted.connect(this, Component.prototype.onInstallationStarted) - if (systemInfo.productType === "windows") { installer.installationFinished.connect(this, Component.prototype.installVCRedist); } + installer.setDefaultPageVisible(QInstaller.ComponentSelection, false) + installer.installationStarted.connect(this, Component.prototype.onInstallationStarted) + if (systemInfo.productType === "windows") { installer.installationFinished.connect(this, Component.prototype.installVCRedist); } //} //installer.setDefaultPageVisible(QInstaller.LicenseCheck, false) } -Component.prototype.onInstallationStarted = function() -{ - if (component.updateRequested() || component.installationRequested()) { - if (installer.value("os") == "win") { - component.installerbaseBinaryPath = "@TargetDir@/signedmaintenancetool.exe" - } - installer.setInstallerBaseBinary(component.installerbaseBinaryPath) +Component.prototype.onInstallationStarted = function () { + if (component.updateRequested() || component.installationRequested()) { + if (installer.value("os") == "win") { + component.installerbaseBinaryPath = "@TargetDir@/signedmaintenancetool.exe" } + installer.setInstallerBaseBinary(component.installerbaseBinaryPath) + } } -Component.prototype.installVCRedist = function() -{ - var registryVC2017x64 = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Installed"))[0]; - var install_str = "No"; - var doInstall = false; - if (!registryVC2017x64) { - doInstall = true; - install_str = "Yes"; - } - else - { - var bld = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Bld"))[0]; - var elements = bld.split(" "); - bld = parseInt(elements[elements.length-1]); - if (bld < 26706) - { - doInstall = true; - } - } - if (doInstall) - { - QMessageBox.information("vcRedist.install", "Install VS Redistributables", "The application requires Visual Studio 2017 Redistributables. Please follow the steps to install it now.", QMessageBox.OK); - var dir = installer.value("TargetDir") + "/" + installer.value("ProductName"); - installer.execute(dir + "/VC_redist.x64.exe", "/norestart", "/passive"); +Component.prototype.installVCRedist = function () { + var registryVC2017x64 = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Installed"))[0]; + var install_str = "No"; + var doInstall = false; + if (!registryVC2017x64) { + doInstall = true; + install_str = "Yes"; + } + else { + var bld = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Bld"))[0]; + var elements = bld.split(" "); + bld = parseInt(elements[elements.length - 1]); + if (bld < 26706) { + doInstall = true; } + } + if (doInstall) { + QMessageBox.information("vcRedist.install", "Install VS Redistributables", "The application requires Visual Studio 2017 Redistributables. Please follow the steps to install it now.", QMessageBox.OK); + var dir = installer.value("TargetDir") + "/" + installer.value("ProductName"); + installer.execute(dir + "/VC_redist.x64.exe", "/norestart", "/passive"); + } } // here we are creating the operation chain which will be processed at the real installation part later -Component.prototype.createOperations = function() -{ +Component.prototype.createOperations = function () { // call default implementation to actually install the registeredfile component.createOperations(); // https://doc.qt.io/qtinstallerframework/operations.html - if (systemInfo.productType === "windows") - { + if (systemInfo.productType === "windows") { // Add desktop shortcut for the app component.addOperation( "CreateShortcut", @@ -83,15 +75,15 @@ Component.prototype.createOperations = function() "iconPath=@TargetDir@/@ProductName@/@ProductName@.exe", "iconId=0", "description=@ProductName@" ) - // Add shortcut for maintenance tool. - component.addOperation( - "CreateShortcut", - "@TargetDir@/maintenancetool.exe", - "@StartMenuDir@/@ProductName@/Maintenance Tool.lnk", - "workingDirectory=@TargetDir@", - "iconPath=@TargetDir@/maintenancetool.exe", - "iconId=0", - "description=Update or remove@ProductName@"); + // Add shortcut for maintenance tool. + component.addOperation( + "CreateShortcut", + "@TargetDir@/maintenancetool.exe", + "@StartMenuDir@/@ProductName@/Maintenance Tool.lnk", + "workingDirectory=@TargetDir@", + "iconPath=@TargetDir@/maintenancetool.exe", + "iconId=0", + "description=Update or remove@ProductName@"); // Add start menu shortcut for the app uninstaller /* @@ -107,19 +99,18 @@ Component.prototype.createOperations = function() } //if (systemInfo.productType === "ubuntu") - if (installer.value("os") === "x11") - { + if (installer.value("os") === "x11") { component.addOperation( "CreateDesktopEntry", "@TargetDir@/@ProductName@.desktop", - "Comment=A scientific software for modelling and analysis of the neutron diffraction data.\n"+ - "Type=Application\n"+ - "Exec=@TargetDir@/@ProductName@/@ProductName@\n"+ - "Path=@TargetDir@/@ProductName@\n"+ - "Name=@ProductName@\n"+ - "GenericName=@ProductName@\n"+ - "Icon=@TargetDir@/@ProductName@/@ProductName@App/Gui/Resources/Logo/App.png\n"+ - "Terminal=false\n"+ + "Comment=A scientific software for modelling and analysis of the neutron re data.\n" + + "Type=Application\n" + + "Exec=@TargetDir@/@ProductName@/@ProductName@\n" + + "Path=@TargetDir@/@ProductName@\n" + + "Name=@ProductName@\n" + + "GenericName=@ProductName@\n" + + "Icon=@TargetDir@/@ProductName@/@ProductName@App/Gui/Resources/Logo/App.png\n" + + "Terminal=false\n" + "Categories=Science;" ) diff --git a/tools/Scripts/MakeInstaller.py b/tools/Scripts/MakeInstaller.py index 88f3161d..afd564aa 100644 --- a/tools/Scripts/MakeInstaller.py +++ b/tools/Scripts/MakeInstaller.py @@ -1,6 +1,6 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project import os import sys @@ -112,7 +112,7 @@ def onlineRepositoryUrl(): prefix = CONFIG['ci']['app']['setup']['ftp']['prefix'] repo_subdir = CONFIG['ci']['app']['setup']['ftp']['repo_subdir'] # return f'https://{prefix}.{host}/{repo_subdir}/{CONFIG.setup_os}' - return f'ftp://u652432322.repo:easyDiffraction123@download.easydiffraction.org/{CONFIG.setup_os}' + return f'ftp://u652432322.repo:EasyReflectometry123@download.easyreflectometry.org/{CONFIG.setup_os}' def installerConfigXml(): diff --git a/tools/Scripts/RunApp.py b/tools/Scripts/RunApp.py index 601b5b15..77f4908c 100644 --- a/tools/Scripts/RunApp.py +++ b/tools/Scripts/RunApp.py @@ -1,25 +1,29 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys +import os import pathlib -import Functions, Config +import sys +import Config +import Functions CONFIG = Config.Config() + def appExePath(): d = { 'macos': os.path.join(CONFIG.installation_dir, CONFIG.app_full_name, 'Contents', 'MacOS', CONFIG.app_name), 'ubuntu': os.path.join(CONFIG.installation_dir, CONFIG.app_name, CONFIG.app_full_name), - 'windows': os.path.join(CONFIG.installation_dir, CONFIG.app_name, CONFIG.app_full_name) + 'windows': os.path.join(CONFIG.installation_dir, CONFIG.app_name, CONFIG.app_full_name), } return d[CONFIG.os] + def runApp(): Functions.printNeutralMessage(f'Installed application exe path: {appExePath()}') try: @@ -27,7 +31,7 @@ def runApp(): if len(sys.argv) == 1: Functions.run(appExePath()) else: - #if 'test' in sys.argv[1:]: + # if 'test' in sys.argv[1:]: # Functions.createDir(CONFIG.screenshots_dir) Functions.run(appExePath(), *sys.argv[1:]) except Exception as exception: @@ -37,5 +41,5 @@ def runApp(): Functions.printSuccessMessage(message) -if __name__ == "__main__": +if __name__ == '__main__': runApp() diff --git a/tools/Scripts/SignAppInstaller.py b/tools/Scripts/SignAppInstaller.py index 08079424..f8777be3 100644 --- a/tools/Scripts/SignAppInstaller.py +++ b/tools/Scripts/SignAppInstaller.py @@ -1,24 +1,26 @@ -# SPDX-FileCopyrightText: 2021 easyDiffraction contributors +# SPDX-FileCopyrightText: 2021 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021 Contributors to the easyDiffraction project +# © 2021 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' +import base64 import os import sys import time -import base64 + import Config import Functions - GIT_BRANCH = sys.argv[1] MATRIX_OS = sys.argv[2] -APPLE_CERT_DATA = sys.argv[3] # Encoded content of the .p12 certificate file (exported from certificate of Developer ID Application type) -APPLE_CERT_PASSWORD = sys.argv[4] # Password associated with the .p12 certificate -APPLE_NOTARY_USER = sys.argv[5] # Apple ID (esss.se personal account) added to https://developer.apple.com -APPLE_NOTARY_PASSWORD = sys.argv[6] # App specific password for EasyDiffraction from https://appleid.apple.com +APPLE_CERT_DATA = sys.argv[ + 3 +] # Encoded content of the .p12 certificate file (exported from certificate of Developer ID Application type) +APPLE_CERT_PASSWORD = sys.argv[4] # Password associated with the .p12 certificate +APPLE_NOTARY_USER = sys.argv[5] # Apple ID (esss.se personal account) added to https://developer.apple.com +APPLE_NOTARY_PASSWORD = sys.argv[6] # App specific password for EasyReflectometry from https://appleid.apple.com CONFIG = Config.Config(GIT_BRANCH, MATRIX_OS) @@ -27,10 +29,12 @@ def signLinux(): Functions.printNeutralMessage('Code signing on Linux is not supported yet') return + def signWindows(): Functions.printNeutralMessage('Code signing on Windows is not supported yet') return + def signMacos(): try: ########################## @@ -44,10 +48,7 @@ def signMacos(): try: sub_message = f'create keychain "{keychain_name}"' - Functions.run( - 'security', 'create-keychain', - '-p', keychain_password, - keychain_name) + Functions.run('security', 'create-keychain', '-p', keychain_password, keychain_name) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -56,9 +57,7 @@ def signMacos(): try: sub_message = f'set created keychain "{keychain_name}" to be default keychain' - Functions.run( - 'security', 'default-keychain', - '-s', keychain_name) + Functions.run('security', 'default-keychain', '-s', keychain_name) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -67,8 +66,7 @@ def signMacos(): try: sub_message = f'list keychains' - Functions.run( - 'security', 'list-keychains') + Functions.run('security', 'list-keychains') except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -77,10 +75,7 @@ def signMacos(): try: sub_message = f'unlock created keychain "{keychain_name}"' - Functions.run( - 'security', 'unlock-keychain', - '-p', keychain_password, - keychain_name) + Functions.run('security', 'unlock-keychain', '-p', keychain_password, keychain_name) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -101,11 +96,16 @@ def signMacos(): try: sub_message = f'import certificate "{mac_certificate_fname}" to created keychain "{keychain_name}"' Functions.run( - 'security', 'import', + 'security', + 'import', mac_certificate_fname, - '-k', keychain_name, - '-P', APPLE_CERT_PASSWORD, - '-T', '/usr/bin/codesign') # Without '-T ...' codesign asking to enter keychain password and thus CI freezes + '-k', + keychain_name, + '-P', + APPLE_CERT_PASSWORD, + '-T', + '/usr/bin/codesign', + ) # Without '-T ...' codesign asking to enter keychain password and thus CI freezes except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -114,9 +114,7 @@ def signMacos(): try: sub_message = f'show certificates' - Functions.run( - 'security', 'find-identity', - keychain_name) + Functions.run('security', 'find-identity', keychain_name) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -126,10 +124,15 @@ def signMacos(): try: sub_message = f'allow codesign to access certificate key from keychain "{keychain_name}"' Functions.run( - 'security', 'set-key-partition-list', - '-S', 'apple-tool:,apple:,codesign:', + 'security', + 'set-key-partition-list', + '-S', + 'apple-tool:,apple:,codesign:', '-s', - '-k', keychain_password, keychain_name) + '-k', + keychain_password, + keychain_name, + ) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -144,14 +147,18 @@ def signMacos(): sub_message = f'sign installer app "{CONFIG.setup_exe_path}" with imported certificate' Functions.run( 'codesign', - '--force', # replace any existing signature on the path(s) given - '--verbose', # set (with a numeric value) or increments the verbosity level of output - '--timestamp', # request that a default Apple timestamp authority server be contacted to authenticate the time of signin - '--options=runtime', # specify a set of option flags to be embedded in the code signature - '--keychain', keychain_name, # specify keychain name - '--identifier', CONFIG['ci']['codesign']['apple']['product_id'], # specify bundle id - '--sign', CONFIG['ci']['codesign']['apple']['team_id'], # sign the code at the path(s) given using this identity - CONFIG.setup_exe_path) + '--force', # replace any existing signature on the path(s) given + '--verbose', # set (with a numeric value) or increments the verbosity level of output + '--timestamp', # request that a default Apple timestamp authority server be contacted to authenticate the time of signin + '--options=runtime', # specify a set of option flags to be embedded in the code signature + '--keychain', + keychain_name, # specify keychain name + '--identifier', + CONFIG['ci']['codesign']['apple']['product_id'], # specify bundle id + '--sign', + CONFIG['ci']['codesign']['apple']['team_id'], # sign the code at the path(s) given using this identity + CONFIG.setup_exe_path, + ) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -160,11 +167,7 @@ def signMacos(): try: sub_message = f'display information about the code at "{CONFIG.setup_exe_path}" after signing' - Functions.run( - 'codesign', - '--display', - '--verbose', - CONFIG.setup_exe_path) + Functions.run('codesign', '--display', '--verbose', CONFIG.setup_exe_path) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -175,9 +178,10 @@ def signMacos(): sub_message = f'verify app signatures for installer "{CONFIG.setup_exe_path}" after signing' Functions.run( 'codesign', - '--verify', # verification of code signatures - '--verbose', # set (with a numeric value) or increments the verbosity level of output - CONFIG.setup_exe_path) + '--verify', # verification of code signatures + '--verbose', # set (with a numeric value) or increments the verbosity level of output + CONFIG.setup_exe_path, + ) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -190,15 +194,8 @@ def signMacos(): try: sub_message = f'create zip archive "{CONFIG.setup_zip_path_short}" of offline app installer "{CONFIG.setup_exe_path}" for notarization' - #Functions.zip(CONFIG.setup_exe_path, CONFIG.setup_zip_path_short) - Functions.run( - 'ditto', - '-c', - '-k', - '--rsrc', - '--sequesterRsrc', - CONFIG.setup_exe_path, - CONFIG.setup_zip_path_short) + # Functions.zip(CONFIG.setup_exe_path, CONFIG.setup_zip_path_short) + Functions.run('ditto', '-c', '-k', '--rsrc', '--sequesterRsrc', CONFIG.setup_exe_path, CONFIG.setup_zip_path_short) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -206,16 +203,22 @@ def signMacos(): Functions.printSuccessMessage(sub_message) try: - sub_message = f'notarize app installer "{CONFIG.setup_zip_path_short}" for distribution outside of the Mac App Store' # Notarize the app by submitting a zipped package of the app bundle + sub_message = f'notarize app installer "{CONFIG.setup_zip_path_short}" for distribution outside of the Mac App Store' # Notarize the app by submitting a zipped package of the app bundle Functions.run( - 'xcrun', 'notarytool', 'submit', - '--apple-id', APPLE_NOTARY_USER, - '--team-id', CONFIG['ci']['codesign']['apple']['team_id'], - '--password', APPLE_NOTARY_PASSWORD, + 'xcrun', + 'notarytool', + 'submit', + '--apple-id', + APPLE_NOTARY_USER, + '--team-id', + CONFIG['ci']['codesign']['apple']['team_id'], + '--password', + APPLE_NOTARY_PASSWORD, '--verbose', '--progress', '--wait', - CONFIG.setup_zip_path_short) + CONFIG.setup_zip_path_short, + ) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -236,10 +239,10 @@ def signMacos(): ###################### try: - sub_message = f'download and attach (staple) tickets for notarized executables to app installer "{CONFIG.setup_exe_path}"' - Functions.run( - 'xcrun', 'stapler', - 'staple', CONFIG.setup_exe_path) + sub_message = ( + f'download and attach (staple) tickets for notarized executables to app installer "{CONFIG.setup_exe_path}"' + ) + Functions.run('xcrun', 'stapler', 'staple', CONFIG.setup_exe_path) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -248,9 +251,7 @@ def signMacos(): try: sub_message = f'verify the stapled tickets of app installer "{CONFIG.setup_exe_path}"' - Functions.run( - 'xcrun', 'stapler', - 'validate', CONFIG.setup_exe_path) + Functions.run('xcrun', 'stapler', 'validate', CONFIG.setup_exe_path) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -259,11 +260,7 @@ def signMacos(): try: sub_message = f'verify notarization of app installer "{CONFIG.setup_exe_path}"' - Functions.run( - 'spctl', - '--assess', - '--verbose', - CONFIG.setup_exe_path) + Functions.run('spctl', '--assess', '--verbose', CONFIG.setup_exe_path) except Exception as sub_exception: Functions.printFailMessage(sub_message, sub_exception) sys.exit(1) @@ -277,7 +274,7 @@ def signMacos(): Functions.printSuccessMessage(message) -if __name__ == "__main__": +if __name__ == '__main__': if CONFIG.os == 'ubuntu': signLinux() elif CONFIG.os == 'windows': diff --git a/tools/Scripts/UnzipAppInstaller.py b/tools/Scripts/UnzipAppInstaller.py index 0b5af274..d6775cb7 100644 --- a/tools/Scripts/UnzipAppInstaller.py +++ b/tools/Scripts/UnzipAppInstaller.py @@ -1,28 +1,35 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys -import Functions, Config +import os +import sys +import Config +import Functions CONFIG = Config.Config(sys.argv[1], sys.argv[2]) + def source(): return os.path.basename(CONFIG.setup_zip_path) + def destination(): return CONFIG.dist_dir + def createDestinationDir(): Functions.createDir(CONFIG.dist_dir) + def unzipAppInstaller(): Functions.unzip(source(), destination()) -if __name__ == "__main__": + +if __name__ == '__main__': createDestinationDir() unzipAppInstaller() diff --git a/tools/Scripts/UploadToFtp.py b/tools/Scripts/UploadToFtp.py index 0753b979..07924be2 100755 --- a/tools/Scripts/UploadToFtp.py +++ b/tools/Scripts/UploadToFtp.py @@ -1,20 +1,23 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys import ftplib +import os import pathlib -import Functions, Config +import sys +import Config +import Functions CONFIG = Config.Config(sys.argv[1], sys.argv[2]) FTP_PASSWORD = sys.argv[3] + def connect(ftp, host, port): try: message = f'connect to ftp server' @@ -25,6 +28,7 @@ def connect(ftp, host, port): else: Functions.printSuccessMessage(message) + def login(ftp, user, password): try: message = f'login to ftp server' @@ -35,9 +39,11 @@ def login(ftp, user, password): else: Functions.printSuccessMessage(message) + def winToLin(path): return path.replace('\\', '/') + def makeDir(ftp, path): if pathExists(ftp, path): Functions.printNeutralMessage(f'Directory exists: {path}') @@ -52,6 +58,7 @@ def makeDir(ftp, path): else: Functions.printSuccessMessage(message) + def uploadFile(ftp, source, destination): try: destination = winToLin(destination) @@ -69,6 +76,7 @@ def uploadFile(ftp, source, destination): else: Functions.printSuccessMessage(message) + def uploadDir(ftp, source, destination): try: message = f'upload dir {source} to {destination}' @@ -86,6 +94,7 @@ def uploadDir(ftp, source, destination): else: Functions.printSuccessMessage(message) + def upload(ftp, source, destination): try: message = f'upload {source} to {destination}' @@ -102,6 +111,7 @@ def upload(ftp, source, destination): else: Functions.printSuccessMessage(message) + def pathExists(ftp, path): try: message = f'find path {path}' @@ -113,6 +123,7 @@ def pathExists(ftp, path): Functions.printSuccessMessage(message) return True + def removeDir(ftp, path): if not pathExists(ftp, path): Functions.printNeutralMessage(f"Directory doesn't exists: {path}") @@ -120,7 +131,7 @@ def removeDir(ftp, path): try: path = winToLin(path) message = f'remove directory {path}' - for (name, properties) in ftp.mlsd(path=path): + for name, properties in ftp.mlsd(path=path): if name in ['.', '..']: continue elif properties['type'] == 'file': @@ -134,6 +145,7 @@ def removeDir(ftp, path): else: Functions.printSuccessMessage(message) + def deploy(): host = CONFIG['ci']['app']['setup']['ftp']['host'] port = CONFIG['ci']['app']['setup']['ftp']['port'] @@ -146,9 +158,9 @@ def deploy(): online_repository_subdir_path = f'{prefix}/{repo_subdir}' online_repository_dir_path = f'{online_repository_subdir_path}/{CONFIG.setup_os}' - #Functions.printNeutralMessage(f'local_repository_dir_path {local_repository_dir_path}') - #Functions.printNeutralMessage(f'online_repository_dir_path {online_repository_dir_path}') - #Functions.printNeutralMessage(f'host:port {host}:{port}') + # Functions.printNeutralMessage(f'local_repository_dir_path {local_repository_dir_path}') + # Functions.printNeutralMessage(f'online_repository_dir_path {online_repository_dir_path}') + # Functions.printNeutralMessage(f'host:port {host}:{port}') ftp = ftplib.FTP() connect(ftp, host, port) @@ -158,5 +170,6 @@ def deploy(): upload(ftp, local_repository_dir_path, online_repository_subdir_path) ftp.quit() -if __name__ == "__main__": + +if __name__ == '__main__': deploy() diff --git a/tools/Scripts/VoiceApp.py b/tools/Scripts/VoiceApp.py deleted file mode 100755 index 4eb95e88..00000000 --- a/tools/Scripts/VoiceApp.py +++ /dev/null @@ -1,45 +0,0 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors -# SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project - -__author__ = "github.com/AndrewSazonov" -__version__ = '0.0.1' - -import os, sys -import re -from gtts import gTTS -import Config - - -CONFIG = Config.Config() - -def fileWithPhrases(): - return os.path.join(CONFIG.package_name, 'Gui', 'Pages', 'Home', 'MainContent.qml') - #return os.path.join(CONFIG.package_name, 'Gui', 'Components', 'UserGuides.qml') - -def phrasesList(): - pattern = "say\([\"\'](.+)[\"\']\)" - #pattern = "qsTr\([\"\'](.+)[\"\']\)" - with open(fileWithPhrases(), "r") as f: - lines = f.read() - phrases = re.findall(pattern, lines) - phrases = [p.replace('\\n', ' ') for p in phrases] - return phrases - -def audioDirPath(): - voices_dir = CONFIG['ci']['app']['audio']['dir'] - return os.path.join(CONFIG.package_name, voices_dir) - -def audioFilePath(name): - p = os.path.join(audioDirPath(), f'{name}.mp3') - p = p.replace(" ", "_") - return p - -def createAudioFiles(): - for p in phrasesList(): - print(p) - tts = gTTS(text=p, lang='en-au') - tts.save(audioFilePath(p)) - -if __name__ == "__main__": - createAudioFiles() diff --git a/tools/Scripts/ZipAppInstaller.py b/tools/Scripts/ZipAppInstaller.py index d0f6b14a..1f977cc2 100644 --- a/tools/Scripts/ZipAppInstaller.py +++ b/tools/Scripts/ZipAppInstaller.py @@ -1,24 +1,30 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project -__author__ = "github.com/AndrewSazonov" +__author__ = 'github.com/AndrewSazonov' __version__ = '0.0.1' -import os, sys -import Functions, Config +import os +import sys +import Config +import Functions CONFIG = Config.Config(sys.argv[1], sys.argv[2]) + def source(): return CONFIG.setup_exe_path + def destination(): return CONFIG.setup_zip_path + def zipAppInstaller(): Functions.zip(source(), destination()) -if __name__ == "__main__": + +if __name__ == '__main__': zipAppInstaller() diff --git a/utils.py b/utils.py index 62a90c81..d0144c4d 100755 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ -# SPDX-FileCopyrightText: 2023 easyDiffraction contributors +# SPDX-FileCopyrightText: 2023 EasyReflectometry contributors # SPDX-License-Identifier: BSD-3-Clause -# © 2021-2023 Contributors to the easyDiffraction project +# © 2021-2023 Contributors to the EasyReflectometry project import argparse import datetime