From c66d56552d1a7533549ba228b149c233d6597640 Mon Sep 17 00:00:00 2001 From: giumas Date: Thu, 16 May 2024 21:15:31 +0200 Subject: [PATCH] minor fixes --- .github/workflows/kng_on_linux.yml | 44 +++++++++++++++++++++ .github/workflows/kng_on_windows.yml | 43 ++++++++++++++++++++ .travis.yml | 54 ------------------------- appveyor.yml | 59 ---------------------------- hyo2/kng/__init__.py | 5 ++- hyo2/kng/app/sis_emu/controlpanel.py | 9 ++--- hyo2/kng/app/sis_emu/mainwin.py | 10 ++--- hyo2/kng/lib/kng_all.py | 2 +- hyo2/kng/lib/kng_kmall.py | 4 +- setup.py | 3 +- 10 files changed, 104 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/kng_on_linux.yml create mode 100644 .github/workflows/kng_on_windows.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/kng_on_linux.yml b/.github/workflows/kng_on_linux.yml new file mode 100644 index 0000000..78c733c --- /dev/null +++ b/.github/workflows/kng_on_linux.yml @@ -0,0 +1,44 @@ +name: Kng on Linux + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: setup-conda + uses: s-weigand/setup-conda@v1.2.1 + with: + update-conda: true + python-version: 3.11 + - name: Install dependencies + run: | + conda config --add channels conda-forge + conda install appdirs cartopy gdal matplotlib-base numpy psutil pyproj qt-material + pip install PySide6 + pip install hyo2.abc2 + sudo apt-get install -y libegl1 + pip install --no-deps . + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 ./hyo2/kng --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 ./hyo2/kng --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + continue-on-error: true + - name: Test with pytest + run: | + pip install coveralls PyYAML pytest pytest-cov + py.test --cov + coverage report -m + coveralls + continue-on-error: false diff --git a/.github/workflows/kng_on_windows.yml b/.github/workflows/kng_on_windows.yml new file mode 100644 index 0000000..55ef9af --- /dev/null +++ b/.github/workflows/kng_on_windows.yml @@ -0,0 +1,43 @@ +name: Kng on Windows + +on: [push] + +jobs: + build: + runs-on: windows-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: setup-conda + uses: s-weigand/setup-conda@v1.2.1 + with: + update-conda: true + python-version: 3.11 + - name: Install dependencies + run: | + conda config --add channels conda-forge + conda install appdirs cartopy gdal matplotlib-base numpy psutil pyproj qt-material + pip install PySide6 + pip install hyo2.abc2 + pip install --no-deps . + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 .\hyo2\kng --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 .\hyo2\kng --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + continue-on-error: true + - name: Test with pytest + run: | + pip install coveralls PyYAML pytest pytest-cov + py.test --cov + coverage report -m + coveralls + continue-on-error: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0b31d78..0000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -language: cpp # Travis-CI does not currently support Python and Mac OS X - -os: - - linux - - osx - -env: - - PYTHON_VERSION=3.8 - - PYTHON_VERSION=3.9 - -matrix: - fast_finish: true - allow_failures: - - os: osx - - env: PYTHON_VERSION=3.9 - -install: - - "export DISPLAY=:99.0" - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ( sudo Xvfb :99 -ac -screen 0 1024x768x8; echo ok )& - curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh; - else - sudo apt-get update; - sh -e /etc/init.d/xvfb start; - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - fi - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda config --add channels conda-forge - - conda update -q conda - # Useful for debugging any issues with conda - - conda info -a - - - conda create -q -n test-environment python=$PYTHON_VERSION - - source activate test-environment - - pip install PySide6 - - conda install numpy matplotlib-base gdal pyproj scipy basemap netCDF4 pillow - - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then - conda remove --force PyQt Qt sip; - export LD_LIBRARY_PATH=$HOME/miniconda/envs/test-environment/lib:$LD_LIBRARY_PATH; - fi - - pip install coveralls - - pip install https://github.com/hydroffice/hyo2_abc2/archive/master.zip - - pip install . - - conda list --show-channel-urls - -script: - - python data/download_data.py - - coverage run --source hyo2 setup.py test - -after_success: - - coveralls diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ab7dc49..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,59 +0,0 @@ -version: 0.1.{build}-{branch} - -environment: - - matrix: - - - PYTHON_VERSION: 3.8 - PYTHON_ARCH: x64 - MINICONDA: C:\Miniconda36-x64 - - - PYTHON_VERSION: 3.9 - PYTHON_ARCH: x64 - MINICONDA: C:\Miniconda36-x64 - -matrix: - - allow_failures: - - - PYTHON_VERSION: 3.9 - PYTHON_ARCH: x64 - MINICONDA: C:\Miniconda36-x64 - -install: - - set PATH=%MINICONDA%;%MINICONDA%\Scripts;%PATH% - - # Install the build and runtime dependencies of the project. - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - conda info -a - - conda config --add channels conda-forge - - conda create -q -n test-environment python=%PYTHON_VERSION% - - activate test-environment - - pip install wheel - - # Check that we have the expected version of Python - - python --version - - - pip install coveralls PyYAML - - pip install PySide6 - - conda install numpy matplotlib-base gdal pyproj scipy basemap netCDF4 pillow - - pip install https://github.com/hydroffice/hyo2_abc2/archive/master.zip - -build: off -build_script: - - pip install . - - conda list --show-channel-urls - -test: off -test_script: - - python data/download_data.py - - coverage run --source hyo2 setup.py test - - coverage report -m - - coveralls - -after_test: - - python setup.py bdist_wheel - -artifacts: - - path: dist\* diff --git a/hyo2/kng/__init__.py b/hyo2/kng/__init__.py index 67de80a..b7f50b8 100644 --- a/hyo2/kng/__init__.py +++ b/hyo2/kng/__init__.py @@ -7,7 +7,7 @@ logger.addHandler(logging.NullHandler()) name = "Kng" -__version__ = "1.3.0" +__version__ = "1.3.1" __author__ = "gmasetti@ccom.unh.edu" pkg_info = PkgInfo( @@ -24,6 +24,7 @@ latest_url="https://www.hydroffice.org/latest/sis_emu.txt", deps_dict={ "hyo2.abc2": "hyo2.abc2", - "PySide6": "PySide6" + "PySide6": "PySide6", + "numpy": "numpy" } ) diff --git a/hyo2/kng/app/sis_emu/controlpanel.py b/hyo2/kng/app/sis_emu/controlpanel.py index bc8aa43..948e2da 100644 --- a/hyo2/kng/app/sis_emu/controlpanel.py +++ b/hyo2/kng/app/sis_emu/controlpanel.py @@ -1,6 +1,5 @@ import logging import os -from typing import Union from PySide6 import QtCore, QtGui, QtWidgets @@ -57,7 +56,7 @@ def __init__(self): self.viewer.ensureCursorVisible() # create a monospace font font = QtGui.QFont("Courier New") - font.setStyleHint(QtGui.QFont.TypeWriter) + font.setStyleHint(QtGui.QFont.StyleHint.TypeWriter) font.setFixedPitch(True) font.setPointSize(9) self.viewer.document().setDefaultFont(font) @@ -166,7 +165,7 @@ def _make_sis_settings(self): self.set_timing.setMaximum(5) self.set_timing.setTickInterval(1) self.set_timing.setValue(1) - self.set_timing.setTickPosition(QtWidgets.QSlider.TicksBelow) + self.set_timing.setTickPosition(QtWidgets.QSlider.TickPosition.TicksBelow) # noinspection PyUnresolvedReferences self.set_timing.valueChanged.connect(self.on_replay_timing) hbox.addWidget(self.set_timing) @@ -304,7 +303,7 @@ def _add_source_files(self): logger.debug('adding files') settings = QtCore.QSettings() - source_folder = settings.value("source_folder", self.here) # type: Union[object,str] + source_folder = settings.value("source_folder", self.here) # type: object | str # ask the file path to the user if self.sis_4.isChecked(): @@ -338,7 +337,7 @@ def _add_source_files(self): # noinspection PyCallByClass,PyArgumentList,PyTypeChecker QtWidgets.QMessageBox.warning(self, "File Duplication", "Attempt to add a listed file:\n%s" % os.path.basename(f), - QtWidgets.QMessageBox.Ok) + QtWidgets.QMessageBox.StandardButton.Ok) continue item = QtWidgets.QListWidgetItem(f) self.list_files.addItem(item) diff --git a/hyo2/kng/app/sis_emu/mainwin.py b/hyo2/kng/app/sis_emu/mainwin.py index 46d7626..62be3be 100644 --- a/hyo2/kng/app/sis_emu/mainwin.py +++ b/hyo2/kng/app/sis_emu/mainwin.py @@ -72,22 +72,22 @@ def _check_latest_release(cls): except Exception as e: logger.warning(e) - def _do_you_really_want(self, title="Quit", text="quit"): + def _do_you_really_want(self, title="Quit", text="quit") -> int: """helper function that show to the user a message windows asking to confirm an action""" msg_box = QtWidgets.QMessageBox(self) msg_box.setWindowTitle(title) msg_box.setIconPixmap(QtGui.QPixmap(app_info.app_icon_path).scaled(QtCore.QSize(36, 36))) msg_box.setText('Do you really want to %s?' % text) # noinspection PyUnresolvedReferences - msg_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) - msg_box.setDefaultButton(QtWidgets.QMessageBox.No) + msg_box.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No) + msg_box.setDefaultButton(QtWidgets.QMessageBox.StandardButton.No) return msg_box.exec() - def closeEvent(self, event): + def closeEvent(self, event: QtGui.QCloseEvent) -> None: """ actions to be done before close the app """ reply = self._do_you_really_want("Quit", "quit %s" % self.name) - if reply == QtWidgets.QMessageBox.Yes: + if reply == QtWidgets.QMessageBox.StandardButton.Yes: event.accept() self.panel.stop_emulation() diff --git a/hyo2/kng/lib/kng_all.py b/hyo2/kng/lib/kng_all.py index d0bfb32..c354c42 100644 --- a/hyo2/kng/lib/kng_all.py +++ b/hyo2/kng/lib/kng_all.py @@ -1,7 +1,7 @@ import enum import logging import struct -from typing.io import BinaryIO +from typing import BinaryIO logger = logging.getLogger(__name__) diff --git a/hyo2/kng/lib/kng_kmall.py b/hyo2/kng/lib/kng_kmall.py index 57247ea..9c145da 100644 --- a/hyo2/kng/lib/kng_kmall.py +++ b/hyo2/kng/lib/kng_kmall.py @@ -2,7 +2,7 @@ import logging import struct from datetime import datetime, timedelta -from typing.io import BinaryIO +from typing import BinaryIO logger = logging.getLogger(__name__) @@ -72,4 +72,4 @@ def read(self, file_input: BinaryIO, file_size: int) -> Flags: @classmethod def kmall_datetime(cls, dgm_time_sec: int, dgm_time_nanosec: int = 0): return datetime.utcfromtimestamp(dgm_time_sec) + \ - timedelta(microseconds=(dgm_time_nanosec / 1000.0)) \ No newline at end of file + timedelta(microseconds=(dgm_time_nanosec / 1000.0)) diff --git a/setup.py b/setup.py index 32ec374..ff18ebf 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def find_version(*file_paths): install_requires=[ "hyo2.abc2", "numpy", - # "PySide6" + "PySide6" ], python_requires='>=3.8', entry_points={ @@ -77,6 +77,7 @@ def find_version(*file_paths): "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", 'Topic :: Scientific/Engineering :: GIS', 'Topic :: Office/Business :: Office Suites', ],