Skip to content

Commit

Permalink
explicit encoding + update wine wiki link
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelmerro committed Nov 7, 2024
1 parent 856db6c commit 9d11701
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -147,7 +147,7 @@ All of them are listed in the output as shown here:
```
usage: carafe {<carafe_name>,list} <sub_command>
Welcome to carafe 1.4.0
Welcome to carafe 1.5.0
carafe is a tiny management tool for wine bottles/carafes.
optional arguments:
Expand Down
21 changes: 10 additions & 11 deletions carafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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)


Expand All @@ -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)


Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down

0 comments on commit 9d11701

Please sign in to comment.