Skip to content

Commit

Permalink
Merge pull request #406 from linien-org/release/v2.0.3
Browse files Browse the repository at this point in the history
Release v2.0.3
  • Loading branch information
bleykauf authored May 29, 2024
2 parents 16dee16 + 379cacf commit 8bca16f
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-linien/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
using: "composite"
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/install-linien/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
using: "composite"
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pyinstaller-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.3] - 2024-05-29

### Fixed
* Now compatible with Python 3.12 by bumping version of `fabric` by @bleykauf in https://github.com/linien-org/linien/pull/406, thanks to @systemofapwne for reporting this issue

### Added
* Handle corrupted json files by @bleykauf in https://github.com/linien-org/linien/pull/399


## [2.0.2] - 2024-05-14

### Fixed
Expand Down Expand Up @@ -216,7 +225,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* **Bug fixes and performance improvements**

[Unreleased]: https://github.com/linien-org/linien/compare/v2.0.1...v2.0.2
[2.0.3]: https://github.com/linien-org/linien/compare/v2.0.2...v2.0.3
[2.0.2]: https://github.com/linien-org/linien/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/linien-org/linien/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/linien-org/linien/compare/v1.0.2...v2.0.0
[1.0.2]: https://github.com/linien-org/linien/compare/v1.0.1...v1.0.2
Expand Down
6 changes: 3 additions & 3 deletions linien-client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-client"
version = "2.0.2"
version = "2.0.3"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand All @@ -23,9 +23,9 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"fabric>=2.7.0,<3.0",
"fabric>=3.2.2,<4.0",
"typing_extensions>=4.5.0,<5.0",
"linien-common==2.0.2",
"linien-common==2.0.3",
]

[project.readme]
Expand Down
18 changes: 17 additions & 1 deletion linien-common/linien_common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
#
# You should have received a copy of the GNU General Public License
# along with Linien. If not, see <http://www.gnu.org/licenses/>.

import logging
from pathlib import Path

from appdirs import AppDirs

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

ACQUISITION_PORT = 19321
SERVER_PORT = 18862
DEFAULT_SWEEP_SPEED = (125 * 2048) << 6
Expand All @@ -29,3 +32,16 @@

LOG_FILE_PATH = USER_DATA_PATH / "linien.log"
LOG_FILE_PATH.parent.mkdir(parents=True, exist_ok=True)


def create_backup_file(filename: Path) -> None:
"""Rename the file to a unique filename."""
i = 0
while True:
backup_filename = filename.parent / f"{filename.stem}.backup{i}"
if not backup_filename.exists():
break
i += 1

filename.rename(backup_filename)
logger.info(f"{filename} has been saved as {backup_filename}.")
6 changes: 5 additions & 1 deletion linien-common/linien_common/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
from dataclasses import dataclass

from .config import USER_DATA_PATH
from .config import USER_DATA_PATH, create_backup_file

CREDENTIAL_STORE_FILENAME = "influxdb_credentials.json"

Expand Down Expand Up @@ -69,3 +69,7 @@ def restore_credentials() -> InfluxDBCredentials:
)
except FileNotFoundError:
return InfluxDBCredentials()
except json.JSONDecodeError:
logger.error(f"Credentials file {filename} was corrupted.")
create_backup_file(filename)
return InfluxDBCredentials()
2 changes: 1 addition & 1 deletion linien-common/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-common"
version = "2.0.2"
version = "2.0.3"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand Down
13 changes: 8 additions & 5 deletions linien-gui/linien_gui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
from pathlib import Path
from typing import Callable, Iterator, Tuple

from linien_common.config import USER_DATA_PATH
from linien_common.config import USER_DATA_PATH, create_backup_file

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

UI_PATH = Path(__file__).parents[0].resolve() / "ui"

SETTINGS_STORE_FILENAME = "settings.json"
# don't plot more often than once per `DEFAULT_PLOT_RATE_LIMIT` seconds
DEFAULT_PLOT_RATE_LIMIT = 0.1

Expand Down Expand Up @@ -118,19 +118,22 @@ def __iter__(self) -> Iterator[Tuple[str, Setting]]:

def save_settings(settings: Settings) -> None:
data = {name: setting.value for name, setting in settings}
with open(USER_DATA_PATH / "settings.json", "w") as f:
with open(USER_DATA_PATH / SETTINGS_STORE_FILENAME, "w") as f:
json.dump(data, f, indent=0)


def load_settings() -> Settings:
settings = Settings()
filename = USER_DATA_PATH / SETTINGS_STORE_FILENAME
try:
with open(USER_DATA_PATH / "settings.json", "r") as f:
with open(filename, "r") as f:
data = json.load(f)
for name, value in data.items():
if name in settings.__dict__:
getattr(settings, name).value = value
except FileNotFoundError:
save_settings(settings)

except json.JSONDecodeError:
logger.error(f"Settings file {filename} was corrupted.")
create_backup_file(filename)
return settings
4 changes: 2 additions & 2 deletions linien-gui/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-gui"
version = "2.0.2"
version = "2.0.3"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand All @@ -28,7 +28,7 @@ dependencies = [
"PyQt5>=5.12.0,<6.0",
"requests>=2.31.0,<3.0",
"superqt>=0.2.3",
"linien_client==2.0.2",
"linien_client==2.0.3",
]

[project.readme]
Expand Down
6 changes: 5 additions & 1 deletion linien-server/linien_server/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import linien_server
from linien_common.common import AutolockMode, MHz, PSDAlgorithm, Vpp
from linien_common.config import USER_DATA_PATH
from linien_common.config import USER_DATA_PATH, create_backup_file

PARAMETER_STORE_FILENAME = "parameters.json"

Expand Down Expand Up @@ -667,6 +667,10 @@ def restore_parameters(parameters: Parameters) -> Parameters:
except FileNotFoundError:
logger.info(f"Couldn't find {filename}. Using default parameters.")
return parameters
except json.JSONDecodeError:
logger.error(f"Parameters file {filename} was corrupted.")
create_backup_file(filename)
return parameters

for name, attributes in data["parameters"].items():
try:
Expand Down
4 changes: 2 additions & 2 deletions linien-server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-server"
version = "2.0.2"
version = "2.0.3"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand All @@ -28,7 +28,7 @@ dependencies = [
"influxdb-client[ciso]>=1.9,<2.0",
"pylpsd>=0.1.4",
"pyrp3>=2.0.1,<3.0;platform_machine=='armv7l'",
"linien-common==2.0.2",
"linien-common==2.0.3",
]

[project.readme]
Expand Down

0 comments on commit 8bca16f

Please sign in to comment.