Splatlogger 1.3.0__tar.gz → 1.3.1.post1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {splatlogger-1.3.0/src/Splatlogger.egg-info → splatlogger-1.3.1.post1}/PKG-INFO +31 -11
  2. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/README.md +29 -9
  3. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/pyproject.toml +2 -2
  4. {splatlogger-1.3.0 → splatlogger-1.3.1.post1/src/Splatlogger.egg-info}/PKG-INFO +31 -11
  5. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/Splatlogger.egg-info/requires.txt +1 -1
  6. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/__init__.py +1 -1
  7. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/cemu_gecko.py +0 -2
  8. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/match_logger.py +9 -7
  9. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/splatlogger.py +20 -24
  10. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/tcpgecko.py +9 -0
  11. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/tuples.py +0 -5
  12. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/utility_functions.py +54 -34
  13. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/LICENSE +0 -0
  14. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/setup.cfg +0 -0
  15. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/Splatlogger.egg-info/SOURCES.txt +0 -0
  16. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/Splatlogger.egg-info/dependency_links.txt +0 -0
  17. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/Splatlogger.egg-info/entry_points.txt +0 -0
  18. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/Splatlogger.egg-info/top_level.txt +0 -0
  19. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/__main__.py +0 -0
  20. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/cli.py +0 -0
  21. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/enums.py +0 -0
  22. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/errors.py +0 -0
  23. {splatlogger-1.3.0 → splatlogger-1.3.1.post1}/src/splatlogger/resources/names.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Splatlogger
3
- Version: 1.3.0
3
+ Version: 1.3.1.post1
4
4
  Summary: PID Grabber and player/match information logging tool for Splatoon
5
5
  Author-email: Shadow Doggo <shadowdoggo@protonmail.com>
6
6
  License-Expression: MIT
@@ -14,7 +14,7 @@ Requires-Dist: tomli>=1.1.0; python_version < "3.11"
14
14
  Requires-Dist: userpaths>=0.1.3
15
15
  Requires-Dist: requests>=2.28.0
16
16
  Requires-Dist: colorama>=0.4.6
17
- Requires-Dist: clean-text>=0.7.1
17
+ Requires-Dist: ftfy<7.0,>=6.0
18
18
  Requires-Dist: prompt_toolkit>=3.0.0
19
19
  Provides-Extra: cemu
20
20
  Requires-Dist: psutil>=5.9.0; extra == "cemu"
@@ -50,8 +50,13 @@ or any other app with the TCPGecko server.
50
50
  On Aroma, use [TCPGecko-Plugin](https://github.com/PinkDiamondTeam/TCPGecko-Plugin).
51
51
 
52
52
  ## Usage
53
+ Splatlogger uses a command-line interface (CLI), you will need to run it within a terminal.
54
+
55
+ On Windows, it's best to use [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/install)
56
+ or [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows), as the Command Prompt can't properly display certain characters.
57
+
53
58
  ### Running the executable
54
- Windows and Linux executables are provided on the [Releases](https://codeberg.org/ShadowDoggo/Splatlogger/releases/latest) page.
59
+ Executables for Windows, Linux and macOS are provided on the [Releases](https://codeberg.org/ShadowDoggo/Splatlogger/releases/latest) page.
55
60
 
56
61
  Run Splatlogger with:
57
62
  ```
@@ -60,9 +65,29 @@ path/to/Splatlogger-executable --ip IP [options] / --cemu [PID] [options]
60
65
  Use the `--ip` target where `IP` is your Wii U's LAN IP address,
61
66
  or the `-c` / `--cemu` target to enable Cemu mode where `PID` is the process ID of the Cemu process (optional, should be detected automatically).
62
67
 
63
- Open a command prompt/terminal window and drag the executable into it to automatically get the path.
68
+ Drag the executable into the terminal window to automatically get the path.
69
+
70
+ On Linux and macOS, you might need to make the file executable first with `chmod +x path/to/Splatlogger-executable`
71
+
72
+ ### Unsigned executable warning
73
+
74
+ Windows and macOS may display security warnings when you try to run Splatlogger. This is expected and does not necessarily mean that the application is malicious.
75
+
76
+ **Windows**
77
+
78
+ If Windows SmartScreen displays a warning saying *"Windows protected your PC"*:
64
79
 
65
- On Linux, you might need to make the file executable first with `chmod +x path/to/Splatlogger-executable`
80
+ - Click **More info**.
81
+ - Click **Run anyway**.
82
+
83
+ **macOS**
84
+
85
+ If macOS blocks the application because it cannot verify the developer:
86
+
87
+ - Open **System Settings → Privacy & Security**.
88
+ - Scroll down and click **Open Anyway** next to the warning about Splatlogger.
89
+
90
+ These warnings occur because the executables have not been signed with a trusted developer certificate. Only bypass these warnings if you downloaded Splatlogger from a trusted source.
66
91
 
67
92
  ### Running with Python
68
93
  You can install Splatlogger as a package from PyPI:
@@ -174,9 +199,6 @@ If it keeps failing to connect, make sure that:
174
199
  - Port 7331 isn't blocked by the firewall.
175
200
  - TCPGecko is running.
176
201
 
177
- There's an issue with TCPGecko where opening an applet such as the Friend List and going back into the game causes memory
178
- reads to fail. If auto-logging is enabled, you'll need to restart Splatlogger after returning to the game.
179
-
180
202
  For Cemu users on Linux, if you have ptrace protection enabled, you'll need to run Python as root.
181
203
  In that case, it's best to run the package from source or use the executable instead.
182
204
 
@@ -200,9 +222,7 @@ python scripts/build.py [--upx-dir path/to/upx]
200
222
  ```
201
223
  use `--upx-dir` if you're using UPX to compress the executable.
202
224
 
203
- You can also use `build.bat` on Windows and `build.sh` on Linux to handle everything automatically.
204
-
205
- (No builds or build script are provided for macOS as I don't have a Mac to test, and my attempts at virtualizing macOS have been unsuccessful.)
225
+ You can also use `build.bat` on Windows and `build.sh` on Linux/macOS to handle everything automatically.
206
226
 
207
227
  ## Acknowledgments
208
228
  - NWPlayer123 for the reference implementation of a TCPGecko library.
@@ -25,8 +25,13 @@ or any other app with the TCPGecko server.
25
25
  On Aroma, use [TCPGecko-Plugin](https://github.com/PinkDiamondTeam/TCPGecko-Plugin).
26
26
 
27
27
  ## Usage
28
+ Splatlogger uses a command-line interface (CLI), you will need to run it within a terminal.
29
+
30
+ On Windows, it's best to use [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/install)
31
+ or [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows), as the Command Prompt can't properly display certain characters.
32
+
28
33
  ### Running the executable
29
- Windows and Linux executables are provided on the [Releases](https://codeberg.org/ShadowDoggo/Splatlogger/releases/latest) page.
34
+ Executables for Windows, Linux and macOS are provided on the [Releases](https://codeberg.org/ShadowDoggo/Splatlogger/releases/latest) page.
30
35
 
31
36
  Run Splatlogger with:
32
37
  ```
@@ -35,9 +40,29 @@ path/to/Splatlogger-executable --ip IP [options] / --cemu [PID] [options]
35
40
  Use the `--ip` target where `IP` is your Wii U's LAN IP address,
36
41
  or the `-c` / `--cemu` target to enable Cemu mode where `PID` is the process ID of the Cemu process (optional, should be detected automatically).
37
42
 
38
- Open a command prompt/terminal window and drag the executable into it to automatically get the path.
43
+ Drag the executable into the terminal window to automatically get the path.
44
+
45
+ On Linux and macOS, you might need to make the file executable first with `chmod +x path/to/Splatlogger-executable`
46
+
47
+ ### Unsigned executable warning
48
+
49
+ Windows and macOS may display security warnings when you try to run Splatlogger. This is expected and does not necessarily mean that the application is malicious.
50
+
51
+ **Windows**
52
+
53
+ If Windows SmartScreen displays a warning saying *"Windows protected your PC"*:
39
54
 
40
- On Linux, you might need to make the file executable first with `chmod +x path/to/Splatlogger-executable`
55
+ - Click **More info**.
56
+ - Click **Run anyway**.
57
+
58
+ **macOS**
59
+
60
+ If macOS blocks the application because it cannot verify the developer:
61
+
62
+ - Open **System Settings → Privacy & Security**.
63
+ - Scroll down and click **Open Anyway** next to the warning about Splatlogger.
64
+
65
+ These warnings occur because the executables have not been signed with a trusted developer certificate. Only bypass these warnings if you downloaded Splatlogger from a trusted source.
41
66
 
42
67
  ### Running with Python
43
68
  You can install Splatlogger as a package from PyPI:
@@ -149,9 +174,6 @@ If it keeps failing to connect, make sure that:
149
174
  - Port 7331 isn't blocked by the firewall.
150
175
  - TCPGecko is running.
151
176
 
152
- There's an issue with TCPGecko where opening an applet such as the Friend List and going back into the game causes memory
153
- reads to fail. If auto-logging is enabled, you'll need to restart Splatlogger after returning to the game.
154
-
155
177
  For Cemu users on Linux, if you have ptrace protection enabled, you'll need to run Python as root.
156
178
  In that case, it's best to run the package from source or use the executable instead.
157
179
 
@@ -175,9 +197,7 @@ python scripts/build.py [--upx-dir path/to/upx]
175
197
  ```
176
198
  use `--upx-dir` if you're using UPX to compress the executable.
177
199
 
178
- You can also use `build.bat` on Windows and `build.sh` on Linux to handle everything automatically.
179
-
180
- (No builds or build script are provided for macOS as I don't have a Mac to test, and my attempts at virtualizing macOS have been unsuccessful.)
200
+ You can also use `build.bat` on Windows and `build.sh` on Linux/macOS to handle everything automatically.
181
201
 
182
202
  ## Acknowledgments
183
203
  - NWPlayer123 for the reference implementation of a TCPGecko library.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "Splatlogger"
7
- version = "1.3.0"
7
+ version = "1.3.1.post1"
8
8
  authors = [
9
9
  { name="Shadow Doggo", email="shadowdoggo@protonmail.com" }
10
10
  ]
@@ -16,7 +16,7 @@ dependencies = [
16
16
  "userpaths>=0.1.3",
17
17
  "requests>=2.28.0",
18
18
  "colorama>=0.4.6",
19
- "clean-text>=0.7.1",
19
+ "ftfy>=6.0,<7.0",
20
20
  "prompt_toolkit>=3.0.0"
21
21
  ]
22
22
  classifiers = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Splatlogger
3
- Version: 1.3.0
3
+ Version: 1.3.1.post1
4
4
  Summary: PID Grabber and player/match information logging tool for Splatoon
5
5
  Author-email: Shadow Doggo <shadowdoggo@protonmail.com>
6
6
  License-Expression: MIT
@@ -14,7 +14,7 @@ Requires-Dist: tomli>=1.1.0; python_version < "3.11"
14
14
  Requires-Dist: userpaths>=0.1.3
15
15
  Requires-Dist: requests>=2.28.0
16
16
  Requires-Dist: colorama>=0.4.6
17
- Requires-Dist: clean-text>=0.7.1
17
+ Requires-Dist: ftfy<7.0,>=6.0
18
18
  Requires-Dist: prompt_toolkit>=3.0.0
19
19
  Provides-Extra: cemu
20
20
  Requires-Dist: psutil>=5.9.0; extra == "cemu"
@@ -50,8 +50,13 @@ or any other app with the TCPGecko server.
50
50
  On Aroma, use [TCPGecko-Plugin](https://github.com/PinkDiamondTeam/TCPGecko-Plugin).
51
51
 
52
52
  ## Usage
53
+ Splatlogger uses a command-line interface (CLI), you will need to run it within a terminal.
54
+
55
+ On Windows, it's best to use [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/install)
56
+ or [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows), as the Command Prompt can't properly display certain characters.
57
+
53
58
  ### Running the executable
54
- Windows and Linux executables are provided on the [Releases](https://codeberg.org/ShadowDoggo/Splatlogger/releases/latest) page.
59
+ Executables for Windows, Linux and macOS are provided on the [Releases](https://codeberg.org/ShadowDoggo/Splatlogger/releases/latest) page.
55
60
 
56
61
  Run Splatlogger with:
57
62
  ```
@@ -60,9 +65,29 @@ path/to/Splatlogger-executable --ip IP [options] / --cemu [PID] [options]
60
65
  Use the `--ip` target where `IP` is your Wii U's LAN IP address,
61
66
  or the `-c` / `--cemu` target to enable Cemu mode where `PID` is the process ID of the Cemu process (optional, should be detected automatically).
62
67
 
63
- Open a command prompt/terminal window and drag the executable into it to automatically get the path.
68
+ Drag the executable into the terminal window to automatically get the path.
69
+
70
+ On Linux and macOS, you might need to make the file executable first with `chmod +x path/to/Splatlogger-executable`
71
+
72
+ ### Unsigned executable warning
73
+
74
+ Windows and macOS may display security warnings when you try to run Splatlogger. This is expected and does not necessarily mean that the application is malicious.
75
+
76
+ **Windows**
77
+
78
+ If Windows SmartScreen displays a warning saying *"Windows protected your PC"*:
64
79
 
65
- On Linux, you might need to make the file executable first with `chmod +x path/to/Splatlogger-executable`
80
+ - Click **More info**.
81
+ - Click **Run anyway**.
82
+
83
+ **macOS**
84
+
85
+ If macOS blocks the application because it cannot verify the developer:
86
+
87
+ - Open **System Settings → Privacy & Security**.
88
+ - Scroll down and click **Open Anyway** next to the warning about Splatlogger.
89
+
90
+ These warnings occur because the executables have not been signed with a trusted developer certificate. Only bypass these warnings if you downloaded Splatlogger from a trusted source.
66
91
 
67
92
  ### Running with Python
68
93
  You can install Splatlogger as a package from PyPI:
@@ -174,9 +199,6 @@ If it keeps failing to connect, make sure that:
174
199
  - Port 7331 isn't blocked by the firewall.
175
200
  - TCPGecko is running.
176
201
 
177
- There's an issue with TCPGecko where opening an applet such as the Friend List and going back into the game causes memory
178
- reads to fail. If auto-logging is enabled, you'll need to restart Splatlogger after returning to the game.
179
-
180
202
  For Cemu users on Linux, if you have ptrace protection enabled, you'll need to run Python as root.
181
203
  In that case, it's best to run the package from source or use the executable instead.
182
204
 
@@ -200,9 +222,7 @@ python scripts/build.py [--upx-dir path/to/upx]
200
222
  ```
201
223
  use `--upx-dir` if you're using UPX to compress the executable.
202
224
 
203
- You can also use `build.bat` on Windows and `build.sh` on Linux to handle everything automatically.
204
-
205
- (No builds or build script are provided for macOS as I don't have a Mac to test, and my attempts at virtualizing macOS have been unsuccessful.)
225
+ You can also use `build.bat` on Windows and `build.sh` on Linux/macOS to handle everything automatically.
206
226
 
207
227
  ## Acknowledgments
208
228
  - NWPlayer123 for the reference implementation of a TCPGecko library.
@@ -1,7 +1,7 @@
1
1
  userpaths>=0.1.3
2
2
  requests>=2.28.0
3
3
  colorama>=0.4.6
4
- clean-text>=0.7.1
4
+ ftfy<7.0,>=6.0
5
5
  prompt_toolkit>=3.0.0
6
6
 
7
7
  [:python_version < "3.11"]
@@ -1,2 +1,2 @@
1
- __version__ = "1.3.0"
1
+ __version__ = "1.3.1"
2
2
  __author__ = "Shadow Doggo"
@@ -74,11 +74,9 @@ class CemuGecko:
74
74
  def resolve_pointer_chain(self, base_address: int, offsets: list[int]) -> int:
75
75
  """Follow a pointer chain to its destination address starting from base_address and applying offsets."""
76
76
  current_address = self.peek32(base_address)
77
-
78
77
  for offset in offsets[:-1]:
79
78
  if current_address == 0:
80
79
  return 0
81
-
82
80
  current_address = self.peek32(current_address + offset)
83
81
 
84
82
  if current_address != 0 and offsets:
@@ -12,7 +12,7 @@ import userpaths # type: ignore[import-untyped]
12
12
 
13
13
  from . import utility_functions as uf
14
14
  from .enums import OffsetChains, Offsets, Pointers, VSMode, VSRule
15
- from .tuples import AccountInfo, AppContext, CommonAddresses, PlayerInfo, PlayerStats, MatchResults
15
+ from .tuples import AccountInfo, AppContext, PlayerInfo, PlayerStats, MatchResults
16
16
 
17
17
 
18
18
  def get_resource_path(relative_path: str | Path) -> Path:
@@ -66,8 +66,7 @@ class MatchLogger:
66
66
 
67
67
  return log_dir / f"{self._date.strftime('%Y-%m-%d')}"
68
68
 
69
- def log_match(self, date: datetime, session_id: int, match_count: int, player_info_list: list[PlayerInfo],
70
- adrs: CommonAddresses) -> None:
69
+ def log_match(self, date: datetime, session_id: int, match_count: int, player_info_list: list[PlayerInfo]) -> None:
71
70
  """Write player and match data to the log file.
72
71
  A log file must be initialized before calling this method."""
73
72
  disconnect = False
@@ -87,7 +86,7 @@ class MatchLogger:
87
86
  stats: list[PlayerStats] = []
88
87
  match_results: MatchResults | None = None
89
88
  if self._ctx.options.log_level == "full":
90
- if self._wait_for_results(adrs, dcd_players):
89
+ if self._wait_for_results(dcd_players):
91
90
  stats = self._get_player_stats()
92
91
  match_results = self._get_match_results(versus_rule)
93
92
  else:
@@ -101,8 +100,11 @@ class MatchLogger:
101
100
  if self._ctx.options.log_level == "full" and not disconnect:
102
101
  if (player_stats := stats_by_idx.get(player_info.idx)) is not None:
103
102
  match_log += self._format_stats_log(
104
- player_info, match_results.winning_team if match_results else None,
105
- versus_rule, player_stats, dcd_players
103
+ player_info,
104
+ match_results.winning_team if match_results else None,
105
+ versus_rule,
106
+ player_stats,
107
+ dcd_players
106
108
  )
107
109
 
108
110
  if match_results:
@@ -223,7 +225,7 @@ class MatchLogger:
223
225
  f"{indent}Bravo points: {match_results.bravo_points}\n"
224
226
  )
225
227
 
226
- def _wait_for_results(self, adrs: CommonAddresses, dcd_players: set[int]) -> bool:
228
+ def _wait_for_results(self, dcd_players: set[int]) -> bool:
227
229
  id_mgr_adr = self._ctx.gecko.resolve_pointer_chain(
228
230
  Pointers.FRAMEWORK.convert(self._ctx.options.platform),
229
231
  OffsetChains.ID_MANAGER.offsets
@@ -4,7 +4,6 @@ from __future__ import annotations
4
4
 
5
5
  import binascii
6
6
  import ipaddress
7
- import logging
8
7
  import threading
9
8
  import time
10
9
  from base64 import b64decode
@@ -20,16 +19,11 @@ from .enums import Offsets, Pointers
20
19
  from .errors import SplatloggerError
21
20
  from .match_logger import MatchLogger
22
21
  from .tcpgecko import GeckoConnectionFailedError, TCPGecko
23
- from .tuples import AccountInfo, AppContext, CommonAddresses, Options, PlayerInfo
22
+ from .tuples import AccountInfo, AppContext, Options, PlayerInfo
24
23
 
25
24
  if TYPE_CHECKING:
26
25
  from .cemu_gecko import CemuGecko
27
26
 
28
- # Hack to remove the unidecode warning from clean-text
29
- logging.disable(logging.CRITICAL)
30
- from cleantext import clean # type: ignore[import-untyped]
31
- logging.disable(logging.NOTSET)
32
-
33
27
 
34
28
  def main(options: Options, listener: Callable[[AppContext], None] | None = None) -> None:
35
29
  with create_tcpgecko_instance(options) as gecko:
@@ -152,7 +146,7 @@ def create_tcpgecko_instance(options: Options) -> TCPGecko | CemuGecko:
152
146
  uf.print_error(str(e))
153
147
  continue
154
148
 
155
- raise SplatloggerError("\nFailed after 2 tries.")
149
+ raise SplatloggerError("\nFailed after two attempts.")
156
150
 
157
151
 
158
152
  @uf.handle_gecko_errors
@@ -160,10 +154,10 @@ def get_static_mem_adr(gecko: TCPGecko | CemuGecko, options: Options) -> int:
160
154
  static_mem_adr = gecko.peek32(Pointers.STATIC_MEM.convert(options.platform))
161
155
  if static_mem_adr == 0:
162
156
  msg = (
163
- "Successfully opened Cemu process but could not read StaticMem address. "
157
+ "Successfully opened Cemu process but could not read StaticMem address.\n"
164
158
  "This is likely caused by ptrace protection (see README)."
165
159
  if options.platform == "cemu" else
166
- "Connected successfully but could not find StaticMem address. "
160
+ "Connected successfully but could not find StaticMem address.\n"
167
161
  "Please open Splatoon first."
168
162
  )
169
163
  raise SplatloggerError(msg)
@@ -202,14 +196,14 @@ def splatlog(ctx: AppContext, match_logger: MatchLogger | None, match_count: int
202
196
  match_date = date or datetime.now()
203
197
  adrs = get_common_addresses(ctx)
204
198
  session_id = get_session_id(ctx)
205
- player_count = get_player_count(ctx, adrs.main_mgr_base_adr)
199
+ player_count = get_player_count(ctx, main_mgr_base_adr=adrs[0])
206
200
 
207
201
  print_if_not_silent(ctx, uf.player_table_header(ctx.options.service == "altendo"))
208
202
 
209
203
  player_info_list: list[PlayerInfo] = []
210
204
  request_errors: list[str] = []
211
205
 
212
- for player_info, act_info in collect_player_info(ctx, player_count, adrs.player_info_ary_adr):
206
+ for player_info, act_info in collect_player_info(ctx, player_count, player_info_ary_adr=adrs[1]):
213
207
  if act_info.request_error and act_info.request_error not in request_errors:
214
208
  request_errors.append(act_info.request_error)
215
209
 
@@ -225,13 +219,15 @@ def splatlog(ctx: AppContext, match_logger: MatchLogger | None, match_count: int
225
219
  f"Fetched at: {match_date.strftime('%Y-%m-%d %H:%M:%S')} (UTC {uf.get_utc_offset(match_date):+})")
226
220
 
227
221
  if match_logger:
228
- match_logger.log_match(match_date, session_id, match_count, player_info_list, adrs)
222
+ match_logger.log_match(match_date, session_id, match_count, player_info_list)
229
223
 
230
224
 
231
225
  @uf.handle_gecko_errors
232
- def get_common_addresses(ctx: AppContext) -> CommonAddresses:
233
- return CommonAddresses(ctx.gecko.peek32(Pointers.MAIN_MGR_BASE.convert(ctx.options.platform)),
234
- ctx.gecko.peek32(ctx.static_mem_adr + Offsets.STATICMEM_PLAYER_INFO_ARY_PTR))
226
+ def get_common_addresses(ctx: AppContext) -> tuple[int, int]:
227
+ return (
228
+ ctx.gecko.peek32(Pointers.MAIN_MGR_BASE.convert(ctx.options.platform)),
229
+ ctx.gecko.peek32(ctx.static_mem_adr + Offsets.STATICMEM_PLAYER_INFO_ARY_PTR)
230
+ )
235
231
 
236
232
 
237
233
  @uf.handle_gecko_errors
@@ -256,7 +252,7 @@ def get_player_count(ctx: AppContext, main_mgr_base_adr: int) -> int:
256
252
  if 1 <= player_count <= 8:
257
253
  return player_count
258
254
  else:
259
- uf.print_warning("You are currently not in a match. Logging previous match data "
255
+ uf.print_warning("You are currently not in a match.\nLogging previous match data "
260
256
  "(Player 1 data will be your own, Session ID will be the current one).\n")
261
257
 
262
258
  return 8
@@ -295,13 +291,10 @@ def get_player_info(ctx: AppContext, player_idx: int,
295
291
 
296
292
 
297
293
  def decode_player_name(player_info_raw: bytes) -> str:
298
- return clean(
294
+ return uf.clean_text(
299
295
  player_info_raw[Offsets.PLAYER_INFO_NAME:Offsets.PLAYER_INFO_NAME + Offsets.PLAYER_INFO_NAME_LENGTH]
300
296
  .decode("utf-16-be", errors="replace")
301
- .split("\u0000")[0],
302
- to_ascii=False,
303
- lower=False,
304
- no_line_breaks=True
297
+ .split("\u0000")[0]
305
298
  )
306
299
 
307
300
 
@@ -462,8 +455,11 @@ def get_altendo_account_info(player_pid: int) -> AccountInfo:
462
455
 
463
456
  try:
464
457
  mii_data = b64decode(mii_data_response.text.replace("\\n", "").replace("\\r", ""))
465
- mii_name = clean(mii_data[26:46].decode("utf-16", errors="replace").split("\u0000")[0],
466
- to_ascii=False, lower=False, no_line_breaks=True)
458
+ mii_name = uf.clean_text(
459
+ mii_data[26:46]
460
+ .decode("utf-16", errors="replace")
461
+ .split("\u0000")[0]
462
+ )
467
463
  except (binascii.Error, UnicodeDecodeError):
468
464
  request_error = "Failed to decode Mii name."
469
465
  time.sleep(1)
@@ -28,6 +28,8 @@ class TCPGecko:
28
28
  """Python library for use with TCPGecko."""
29
29
 
30
30
  def __init__(self, ip: str, *, port: int = DEFAULT_PORT, timeout: int = DEFAULT_TIMEOUT) -> None:
31
+ self._address = (ip, port)
32
+ self._timeout = timeout
31
33
  self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
32
34
  self._socket.settimeout(timeout)
33
35
  try:
@@ -50,6 +52,13 @@ class TCPGecko:
50
52
  """Close the TCPGecko connection."""
51
53
  self._socket.close()
52
54
 
55
+ def reconnect(self) -> None:
56
+ self.close()
57
+ try:
58
+ self._socket = socket.create_connection(self._address, timeout=self._timeout)
59
+ except OSError as e:
60
+ raise GeckoConnectionFailedError(f"Reconnection failed: {e}") from e
61
+
53
62
  def peek_raw(self, address: int, length: int) -> bytes:
54
63
  """Read raw memory starting at address and ending at address + length.
55
64
  Returns a bytes object.
@@ -35,11 +35,6 @@ class AppContext:
35
35
  prompt_session: PromptSession | None = None
36
36
 
37
37
 
38
- class CommonAddresses(NamedTuple):
39
- main_mgr_base_adr: int
40
- player_info_ary_adr: int
41
-
42
-
43
38
  class AccountInfo(NamedTuple):
44
39
  network_id: str
45
40
  mii_name: str
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import logging
6
5
  import re
7
6
  import time
8
7
  from datetime import datetime
@@ -12,18 +11,18 @@ from xml.etree import ElementTree
12
11
 
13
12
  import requests
14
13
  from colorama import Fore, Style
14
+ from ftfy import fix_text
15
15
 
16
16
  from .errors import SplatloggerError
17
- from .tcpgecko import GeckoConnectionClosedError, GeckoReadMemError, TCPGeckoError
17
+ from .tcpgecko import GeckoConnectionClosedError, GeckoReadMemError, TCPGecko, TCPGeckoError
18
18
  from .tuples import AccountInfo, PlayerInfo
19
19
 
20
20
  if TYPE_CHECKING:
21
21
  from .match_logger import MatchLogger
22
22
 
23
- # Hack to remove the unidecode warning from clean-text
24
- logging.disable(logging.CRITICAL)
25
- from cleantext import clean # type: ignore[import-untyped]
26
- logging.disable(logging.NOTSET)
23
+
24
+ def clean_text(text: str) -> str:
25
+ return " ".join(fix_text(text).split())
27
26
 
28
27
 
29
28
  def player_table_header(altendo: bool) -> str:
@@ -47,34 +46,55 @@ def read_int(data: bytes, offset: int, length: int, *, signed: bool = False) ->
47
46
  def handle_gecko_errors(func: Callable[..., Any]) -> Any:
48
47
  @wraps(func)
49
48
  def wrapper(*args: Any, **kwargs: Any):
50
- for _ in range(3):
49
+ first = args[0] if args else kwargs.get("ctx", kwargs.get("gecko"))
50
+ gecko = getattr(first, "gecko", first)
51
+ stop_event = getattr(first, "stop_event", None)
52
+ reconnect = False
53
+ last_error = None
54
+
55
+ for attempt in range(2):
51
56
  try:
57
+ if reconnect:
58
+ gecko.reconnect()
59
+ reconnect = False
60
+
52
61
  return func(*args, **kwargs)
53
- except ConnectionResetError:
54
- msg = "Connection reset abruptly."
55
- break
56
- except BrokenPipeError:
57
- msg = "Socket operation failed. Connection was closed abruptly."
58
- break
59
- except GeckoConnectionClosedError:
60
- msg = "Connection closed by the server."
61
- break
62
- except ProcessLookupError:
63
- msg = "Cemu process was closed."
64
- break
65
- except GeckoReadMemError as e:
66
- print_warning(f"\nReading memory failed: {e}\nRetrying in 10 seconds...")
67
- time.sleep(10)
68
- except TimeoutError:
69
- print_warning(f"\nSocket operation timed out.\nRetrying in 10 seconds...")
70
- time.sleep(10)
71
- except (OSError, TCPGeckoError) as e:
72
- print_warning(f"\nAn error has occurred: {e}\nRetrying in 10 seconds...")
73
- time.sleep(10)
74
- else:
75
- msg = "Failed after 3 tries."
76
-
77
- raise SplatloggerError(msg)
62
+ except ProcessLookupError as ex:
63
+ raise SplatloggerError("Cemu process was closed.") from ex
64
+ except (OSError, TCPGeckoError) as ex:
65
+ last_error = ex
66
+
67
+ if isinstance(gecko, TCPGecko):
68
+ reconnect = True
69
+ try:
70
+ gecko.close()
71
+ except OSError:
72
+ pass
73
+
74
+ if attempt == 1:
75
+ break
76
+
77
+ if isinstance(ex, ConnectionResetError):
78
+ message = "Connection reset abruptly."
79
+ elif isinstance(ex, BrokenPipeError):
80
+ message = "Socket operation failed. Connection was closed abruptly."
81
+ elif isinstance(ex, GeckoConnectionClosedError):
82
+ message = "Connection closed by the server."
83
+ elif isinstance(ex, GeckoReadMemError):
84
+ message = f"Reading memory failed: {ex}"
85
+ elif isinstance(ex, TimeoutError):
86
+ message = "Socket operation timed out."
87
+ else:
88
+ message = f"An error has occurred: {ex}"
89
+
90
+ print_warning(f"\n{message}\nRetrying in 10 seconds... (Use 'q' or Ctrl+C to abort)")
91
+
92
+ if stop_event is None:
93
+ time.sleep(10)
94
+ elif stop_event.wait(10):
95
+ raise SplatloggerError("Stopped while waiting to retry.") from ex
96
+
97
+ raise SplatloggerError("Second attempt failed.") from last_error
78
98
 
79
99
  return wrapper
80
100
 
@@ -96,13 +116,13 @@ def process_response(response: requests.Response, altendo: bool) -> tuple[str, s
96
116
  name = root[0].find("name")
97
117
  assert isinstance(name, ElementTree.Element) and name.text is not None
98
118
 
99
- return user_id.text, clean(name.text, to_ascii=False, lower=False, no_line_breaks=True)
119
+ return user_id.text, clean_text(name.text)
100
120
  except (ElementTree.ParseError, AssertionError):
101
121
  return None
102
122
 
103
123
 
104
124
  def compare_names(name1: str, name2: str) -> bool:
105
- return clean(name1) == clean(name2)
125
+ return clean_text(name1).casefold() == clean_text(name2).casefold()
106
126
 
107
127
 
108
128
  def get_last_match_count(match_logger: MatchLogger) -> int:
File without changes
File without changes