From 9d11701c75f61a170f1c272d0493bb2fa63e1645 Mon Sep 17 00:00:00 2001 From: Jelmer van Arnhem Date: Thu, 7 Nov 2024 14:50:56 +0100 Subject: [PATCH] explicit encoding + update wine wiki link --- README.md | 4 ++-- carafe.py | 21 ++++++++++----------- pyproject.toml | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0999189..e706582 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ There is one trade-off to all these advantages: - A regression in a new version of wine can break compatibility until a new wine version is released -The [wine wiki](https://wiki.winehq.org/FAQ#Which_version_of_Wine_should_I_use.3F) recommends to use a recent or even the latest version of wine, +The [wine wiki](https://gitlab.winehq.org/wine/wine/-/wikis/FAQ#which-version-of-wine-should-i-use) recommends to use a recent or even the latest version of wine, which is automatically configured by using carafe. #### Changing a wine version @@ -147,7 +147,7 @@ All of them are listed in the output as shown here: ``` usage: carafe {,list} -Welcome to carafe 1.4.0 +Welcome to carafe 1.5.0 carafe is a tiny management tool for wine bottles/carafes. optional arguments: diff --git a/carafe.py b/carafe.py index 9f07876..fc046c5 100755 --- a/carafe.py +++ b/carafe.py @@ -6,7 +6,7 @@ # See README.md for more details and usage instructions __license__ = "MIT" # See LICENSE for more details and exact terms -__version__ = "1.4.0" +__version__ = "1.5.0" # See https://github.com/jelmerro/carafe for repo and updates import argparse @@ -32,7 +32,7 @@ def read_config(): return {} if not os.path.isfile(CONFIG_FILE): return {} - with open(CONFIG_FILE) as f: + with open(CONFIG_FILE, encoding="utf-8") as f: config = json.load(f) if config == {}: try: @@ -51,7 +51,7 @@ def remove_config(name): except OSError: pass else: - with open(CONFIG_FILE, "w") as f: + with open(CONFIG_FILE, "w", encoding="utf-8") as f: json.dump(config, f) @@ -61,7 +61,7 @@ def modify_config(name, field, value): config[name] = {} config[name][field] = value os.makedirs(CONFIG_FOLDER, exist_ok=True) - with open(CONFIG_FILE, "w") as f: + with open(CONFIG_FILE, "w", encoding="utf-8") as f: json.dump(config, f) @@ -295,14 +295,14 @@ def shortcut(self, args): else: file_name = f"{self.name}.desktop" output_file = os.path.join(args.output_folder, file_name) - with open(output_file, "w") as f: + with open(output_file, "w", encoding="utf-8") as f: f.write(shortcut_contents) def log(self, _args): self.exists() log_file = os.path.join(self.prefix, "log") if os.path.isfile(log_file): - with open(log_file) as f: + with open(log_file, encoding="utf-8") as f: print(f.read()) else: print(f"No logs for '{self.name}' carafe yet") @@ -318,9 +318,7 @@ def winecfg(self, _args): def winetricks(self, args): self.exists() check_for_tool("winetricks", WINETRICKS) - arg_string = " " - for arg in args.arguments: - arg_string += f"{arg} " + arg_string = " ".join(args.arguments) self.run_command(f"{WINETRICKS} {arg_string}") # Class helper functions @@ -359,9 +357,10 @@ def run_command(self, command, cwd=None): env["WINEPREFIX"] = self.prefix if self.arch: env["WINEARCH"] = self.arch - with open(os.path.join(self.prefix, "log"), "wb") as log_file: + log_file = os.path.join(self.prefix, "log") + with open(log_file, "wb", encoding="utf-8") as output: subprocess.run( - command, shell=True, stderr=log_file, stdout=log_file, + command, shell=True, stderr=output, stdout=output, cwd=cwd, env=env) def try_to_sanitize_location(self, loc): diff --git a/pyproject.toml b/pyproject.toml index bfd7b35..bbc52a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name="carafe" -version="1.4.0" +version="1.5.0" authors=[{name="Jelmer van Arnhem"}] description="carafe is a tiny management tool for wine bottles/carafes" license={text="MIT"}