pendify 0.1.7__tar.gz → 0.1.9__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.
- {pendify-0.1.7/src/pendify.egg-info → pendify-0.1.9}/PKG-INFO +4 -4
- {pendify-0.1.7 → pendify-0.1.9}/README.md +3 -3
- {pendify-0.1.7 → pendify-0.1.9}/pyproject.toml +1 -1
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/client.py +111 -1
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/watcher.py +38 -11
- {pendify-0.1.7 → pendify-0.1.9/src/pendify.egg-info}/PKG-INFO +4 -4
- {pendify-0.1.7 → pendify-0.1.9}/LICENSE +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/MANIFEST.in +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/setup.cfg +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/__init__.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/__main__.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/alert.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/autostart.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/codes.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/config.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/icon.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/page.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/pairing.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/pendify.ico +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/plate_almena.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/qr.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/runfile.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/tray.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/update.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify/worker.py +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify.egg-info/SOURCES.txt +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify.egg-info/dependency_links.txt +0 -0
- {pendify-0.1.7 → pendify-0.1.9}/src/pendify.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pendify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: Pairs this PC with a phone account by a QR on a loopback page and sends it two kinds of alerts.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/ElkinDev/PendiFy
|
|
@@ -73,7 +73,7 @@ El botón de arriba a la derecha cambia entre el tema claro y el oscuro, y el pr
|
|
|
73
73
|
|
|
74
74
|
### Qué envía y a quién
|
|
75
75
|
|
|
76
|
-
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía.
|
|
76
|
+
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía. Si el juego no da su reloj, lee en su lugar el registro propio del juego en este mismo PC, solo la hora de dos clases de línea, y no guarda ni envía nada de él. Una vez empezada la partida, pregunta al cliente del juego una vez cada cinco segundos, solo para ver cuándo termina.
|
|
77
77
|
|
|
78
78
|
### `--dry`
|
|
79
79
|
|
|
@@ -138,7 +138,7 @@ The button at the top right switches between the light and the dark theme, and t
|
|
|
138
138
|
|
|
139
139
|
### What it sends and to whom
|
|
140
140
|
|
|
141
|
-
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it.
|
|
141
|
+
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it. When the game gives no clock, it reads the game's own log on this same PC instead, only the time stamps of two kinds of line, and neither keeps nor sends any of it.
|
|
142
142
|
|
|
143
143
|
### `--dry`
|
|
144
144
|
|
|
@@ -152,7 +152,7 @@ License: MIT
|
|
|
152
152
|
python -m pendify ping <kind>
|
|
153
153
|
|
|
154
154
|
The first loads the config, starts the page and opens it in the default browser, paired or not.
|
|
155
|
-
It also watches the game client on this PC: when a match is found it accepts after a short random delay, beeps, and sends the found-match alert; when the loading screen starts it beeps, and when the match itself starts it beeps and sends the started alert.
|
|
155
|
+
It also watches the game client on this PC: when a match is found it accepts after a short random delay, beeps, and sends the found-match alert; when the loading screen starts it beeps, and when the match itself starts it beeps and sends the started alert. Once the match has started it asks the game client once every five seconds, only to see the match end.
|
|
156
156
|
Add `--dry` to watch and alert without accepting. Add `--quiet` for the start by the system at logon, the line the start with Windows switch writes (`pythonw -m pendify --quiet`): it never opens the browser, a start that ends well shows no window, and a second quiet start prints `already running` and exits. One copy runs per config folder: a second start opens the page of the one that runs and exits. Ctrl+C stops the page and the watcher together.
|
|
157
157
|
The second sends one alert with the stored pair and prints one line with the answer.
|
|
158
158
|
|
|
@@ -57,7 +57,7 @@ El botón de arriba a la derecha cambia entre el tema claro y el oscuro, y el pr
|
|
|
57
57
|
|
|
58
58
|
### Qué envía y a quién
|
|
59
59
|
|
|
60
|
-
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía.
|
|
60
|
+
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía. Si el juego no da su reloj, lee en su lugar el registro propio del juego en este mismo PC, solo la hora de dos clases de línea, y no guarda ni envía nada de él. Una vez empezada la partida, pregunta al cliente del juego una vez cada cinco segundos, solo para ver cuándo termina.
|
|
61
61
|
|
|
62
62
|
### `--dry`
|
|
63
63
|
|
|
@@ -122,7 +122,7 @@ The button at the top right switches between the light and the dark theme, and t
|
|
|
122
122
|
|
|
123
123
|
### What it sends and to whom
|
|
124
124
|
|
|
125
|
-
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it.
|
|
125
|
+
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it. When the game gives no clock, it reads the game's own log on this same PC instead, only the time stamps of two kinds of line, and neither keeps nor sends any of it.
|
|
126
126
|
|
|
127
127
|
### `--dry`
|
|
128
128
|
|
|
@@ -136,7 +136,7 @@ License: MIT
|
|
|
136
136
|
python -m pendify ping <kind>
|
|
137
137
|
|
|
138
138
|
The first loads the config, starts the page and opens it in the default browser, paired or not.
|
|
139
|
-
It also watches the game client on this PC: when a match is found it accepts after a short random delay, beeps, and sends the found-match alert; when the loading screen starts it beeps, and when the match itself starts it beeps and sends the started alert.
|
|
139
|
+
It also watches the game client on this PC: when a match is found it accepts after a short random delay, beeps, and sends the found-match alert; when the loading screen starts it beeps, and when the match itself starts it beeps and sends the started alert. Once the match has started it asks the game client once every five seconds, only to see the match end.
|
|
140
140
|
Add `--dry` to watch and alert without accepting. Add `--quiet` for the start by the system at logon, the line the start with Windows switch writes (`pythonw -m pendify --quiet`): it never opens the browser, a start that ends well shows no window, and a second quiet start prints `already running` and exits. One copy runs per config folder: a second start opens the page of the one that runs and exits. Ctrl+C stops the page and the watcher together.
|
|
141
141
|
The second sends one alert with the stored pair and prints one line with the answer.
|
|
142
142
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pendify"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.9"
|
|
8
8
|
description = "Pairs this PC with a phone account by a QR on a loopback page and sends it two kinds of alerts."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -5,11 +5,14 @@ the client process's command line through PowerShell takes the place of the scri
|
|
|
5
5
|
most once every 10 s. Every failure is no client, never an exception. Nothing here prints, logs or raises
|
|
6
6
|
the client's token, and Credentials hides it from repr. The client's phase says the loading screen opened;
|
|
7
7
|
the game's own loopback port is asked one number, its clock, to tell when the match itself starts. Nothing
|
|
8
|
-
else of the live data is read, kept, printed or sent.
|
|
8
|
+
else of the live data is read, kept, printed or sent. A game that serves no clock is read from its own log on this
|
|
9
|
+
PC instead: only the stamps of its join and start lines are parsed, and nothing of the log is kept.
|
|
9
10
|
"""
|
|
10
11
|
import base64
|
|
12
|
+
import calendar
|
|
11
13
|
import http.client
|
|
12
14
|
import json
|
|
15
|
+
import os
|
|
13
16
|
import re
|
|
14
17
|
import ssl
|
|
15
18
|
import subprocess
|
|
@@ -221,3 +224,110 @@ def game_clock(base, get=get):
|
|
|
221
224
|
return float(seconds)
|
|
222
225
|
except OverflowError: # an int no float holds
|
|
223
226
|
return None
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# The game's own log, for a game that serves no clock: where it is under LOCALAPPDATA, the two marks of the lines
|
|
230
|
+
# it writes when the match starts (as it leaves its loading widget), the mark of its join line (written when the
|
|
231
|
+
# game joins its match, earlier, and no start), the most one call reads and the size of each read.
|
|
232
|
+
GAME_LOG_PARTS = ("TFT", "Saved", "Logs", "TFT.log")
|
|
233
|
+
GAME_LOG_MARKS = (b"UTFTMusicPlayerSubsystem::LoadMusicData - Loaded music",
|
|
234
|
+
b"TFTEncounterSubsystem: Setting SetZoomOutExtension")
|
|
235
|
+
GAME_LOG_JOIN = b"LogNet: Welcomed by server"
|
|
236
|
+
GAME_LOG_MAX_BYTES = 16 * 1024 * 1024
|
|
237
|
+
GAME_LOG_CHUNK = 256 * 1024
|
|
238
|
+
_GAME_LOG_STAMP = "%Y.%m.%d-%H.%M.%S" # then :mmm, in UTC
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def real_game_log(environ=os.environ):
|
|
242
|
+
"""The game's own log in a real run, <LOCALAPPDATA>/TFT/Saved/Logs/TFT.log; None when LOCALAPPDATA is unset or
|
|
243
|
+
blank."""
|
|
244
|
+
base = environ.get("LOCALAPPDATA")
|
|
245
|
+
if base is None or not base.strip():
|
|
246
|
+
return None
|
|
247
|
+
return os.path.join(base, *GAME_LOG_PARTS)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _log_stamp(line):
|
|
251
|
+
"""The epoch of the stamp between a log line's first [ and the ] after it, YYYY.MM.DD-HH.MM.SS:mmm in UTC,
|
|
252
|
+
with its milliseconds; None when it does not parse."""
|
|
253
|
+
start = line.find(b"[")
|
|
254
|
+
end = line.find(b"]", start + 1) if start >= 0 else -1
|
|
255
|
+
if end < 0:
|
|
256
|
+
return None
|
|
257
|
+
try:
|
|
258
|
+
moment, millis = line[start + 1:end].decode("ascii").split(":")
|
|
259
|
+
if len(millis) != 3 or not millis.isdigit():
|
|
260
|
+
return None
|
|
261
|
+
return calendar.timegm(time.strptime(moment, _GAME_LOG_STAMP)) + int(millis) / 1000
|
|
262
|
+
except ValueError: # not ASCII, not one colon, or not the stamp's shape; UnicodeDecodeError is a ValueError
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _holds(lines, marks, since):
|
|
267
|
+
"""True when one of `lines`, whole lines each ending in a line feed, holds one of `marks` and is stamped at or
|
|
268
|
+
after `since`: a start line with GAME_LOG_MARKS, a join line with (GAME_LOG_JOIN,). A line older than `since`,
|
|
269
|
+
or whose stamp does not parse, is skipped and the search goes on."""
|
|
270
|
+
for mark in marks:
|
|
271
|
+
at = lines.find(mark)
|
|
272
|
+
while at >= 0:
|
|
273
|
+
start = lines.rfind(b"\n", 0, at) + 1
|
|
274
|
+
stamp = _log_stamp(lines[start:lines.find(b"\n", at)])
|
|
275
|
+
if stamp is not None and stamp >= since:
|
|
276
|
+
return True
|
|
277
|
+
at = lines.find(mark, at + len(mark))
|
|
278
|
+
return False
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class GameLogStart:
|
|
282
|
+
"""Whether the game's own log shows the match started: a start line stamped at or after a time.
|
|
283
|
+
|
|
284
|
+
The log is read in binary and on from where the last call stopped: the first call from byte 0, each later one
|
|
285
|
+
from the end of the last whole line read, at most GAME_LOG_MAX_BYTES a call in GAME_LOG_CHUNK reads; a partial
|
|
286
|
+
last line is read again next time, and a file shorter than the offset, a new one, is read from its start. Only
|
|
287
|
+
the stamps of start lines and join lines are parsed; the join line, written before the start, is no start line,
|
|
288
|
+
but one stamped at or after `since` sets `joined`, the game in its match and not started yet, False again only
|
|
289
|
+
when built and after reset(). No line or part of one is kept, returned, logged or printed: between calls the
|
|
290
|
+
object keeps the offset and that bool and nothing of the file. Every failure answers False, never an exception.
|
|
291
|
+
`path` answers the log's path or None; `opener` opens it as open() does."""
|
|
292
|
+
|
|
293
|
+
def __init__(self, path=real_game_log, opener=open):
|
|
294
|
+
self._path, self._opener = path, opener
|
|
295
|
+
self._offset = 0
|
|
296
|
+
self.joined = False
|
|
297
|
+
|
|
298
|
+
def reset(self):
|
|
299
|
+
"""Forget the offset and the join: the next call reads the file from its start."""
|
|
300
|
+
self._offset = 0
|
|
301
|
+
self.joined = False
|
|
302
|
+
|
|
303
|
+
def __call__(self, since):
|
|
304
|
+
"""True when the log holds a start line stamped at or after `since`, in epoch seconds; else False."""
|
|
305
|
+
path = self._path()
|
|
306
|
+
if path is None:
|
|
307
|
+
return False
|
|
308
|
+
try:
|
|
309
|
+
with self._opener(path, "rb") as handle:
|
|
310
|
+
if handle.seek(0, os.SEEK_END) < self._offset:
|
|
311
|
+
self._offset = 0
|
|
312
|
+
handle.seek(self._offset)
|
|
313
|
+
return self._read_on(handle, since)
|
|
314
|
+
except OSError: # no file, a folder, a refused open or a read that broke
|
|
315
|
+
return False
|
|
316
|
+
|
|
317
|
+
def _read_on(self, handle, since):
|
|
318
|
+
budget, partial = GAME_LOG_MAX_BYTES, b""
|
|
319
|
+
while budget > 0:
|
|
320
|
+
chunk = handle.read(min(GAME_LOG_CHUNK, budget))
|
|
321
|
+
if not chunk:
|
|
322
|
+
return False
|
|
323
|
+
budget -= len(chunk)
|
|
324
|
+
partial += chunk
|
|
325
|
+
end = partial.rfind(b"\n") + 1 # the whole lines read so far end there
|
|
326
|
+
if end:
|
|
327
|
+
lines, partial = partial[:end], partial[end:]
|
|
328
|
+
self._offset += end
|
|
329
|
+
if not self.joined and _holds(lines, (GAME_LOG_JOIN,), since):
|
|
330
|
+
self.joined = True
|
|
331
|
+
if _holds(lines, GAME_LOG_MARKS, since):
|
|
332
|
+
return True
|
|
333
|
+
return False
|
|
@@ -7,10 +7,14 @@ and answers the pause before the next; run() is the loop around it. The script's
|
|
|
7
7
|
check (S:778, S:793) is a hold on the injected clock, so a stop never waits for it. The arrival of
|
|
8
8
|
InProgress after a read of another phase is the loading screen: it beeps on the PC only, once per game, and
|
|
9
9
|
starts a watch that asks the game's own loopback port its clock at most once a second. The clock above zero
|
|
10
|
-
is the match's true start: a beep and match_started. A game
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
no
|
|
10
|
+
is the match's true start: a beep and match_started. A game with no clock port is read from its own log, a
|
|
11
|
+
start line stamped no earlier than 30 s before the loading screen. A game that never answers its clock is
|
|
12
|
+
announced after 120 s of the watch with InProgress read; a read of a boundary phase, or 120 s with no client,
|
|
13
|
+
ends the watch with no alert. While the game's log shows a join line and no start line, the game in its match and
|
|
14
|
+
not started yet, those 120 s are held, up to 300 s from the loading screen. A reconnect is the same game. The
|
|
15
|
+
console gets fixed lines only: no phase, no port, no clock, no token. Once the match has started, or was already
|
|
16
|
+
under way when the client was found, a turn that reads InProgress with no watch running answers IN_GAME_PAUSE, so
|
|
17
|
+
the client is asked once every five seconds, only to see the game end, and a pause from the page waits up to that.
|
|
14
18
|
|
|
15
19
|
pause() and resume() come from the page's thread and only set or clear an event; the loop honors it on its own
|
|
16
20
|
thread. While paused run() makes no step, so nothing reads the client's files or process, its port or the game's
|
|
@@ -39,9 +43,15 @@ GAME_BOUNDARY_PHASES = frozenset({"None", "Lobby", "Matchmaking", READY_CHECK, "
|
|
|
39
43
|
ACCEPT_DELAY = (1.0, 2.5) # S:136
|
|
40
44
|
HOLD_SECONDS = 15.0 # S:778, S:793
|
|
41
45
|
STEP_PAUSE = 0.3 # S:799
|
|
46
|
+
# During a match no watch runs and the phase is read only to see a boundary end the game: one read every five
|
|
47
|
+
# seconds is enough, about 300 in a 25 minute match where 0.3 s made 5,000. A pause from the page waits up to this
|
|
48
|
+
# long; a stop does not, since the sleep is the stop event's wait.
|
|
49
|
+
IN_GAME_PAUSE = 5.0
|
|
42
50
|
NO_CLIENT_PAUSE = 3.0 # S:739
|
|
43
51
|
LIVE_POLL_SECONDS = 1.0 # the game's clock is asked at most once a second during the watch
|
|
44
52
|
LIVE_FALLBACK_SECONDS = 120.0 # restarted by each clock not above zero, the wait announces a game giving no clock
|
|
53
|
+
LIVE_LOG_GRACE_SECONDS = 30.0 # a start line in the game's log counts from this long before the loading screen
|
|
54
|
+
LIVE_JOINED_CEILING_SECONDS = 300.0 # a game whose log shows its join holds the wait up to this long from the loading
|
|
45
55
|
QUEUE_FOUND, MATCH_STARTED = worker.KINDS
|
|
46
56
|
LOG_LINES = 50 # the events the log keeps, the newest
|
|
47
57
|
|
|
@@ -83,10 +93,12 @@ def _phase(raw):
|
|
|
83
93
|
class Watcher:
|
|
84
94
|
def __init__(self, credentials, alert, *, accept=True, addresses=client.real_addresses, get=client.get,
|
|
85
95
|
post=client.post, clock=time.monotonic, wall=time.time, sleep=None, delay=accept_delay,
|
|
86
|
-
log=None, stop=None, live=client.real_live_address, game_clock=client.game_clock):
|
|
96
|
+
log=None, stop=None, live=client.real_live_address, game_clock=client.game_clock, game_log=None):
|
|
87
97
|
self._credentials, self._alert, self._accept = credentials, alert, accept
|
|
88
98
|
self._addresses, self._get, self._post = addresses, get, post
|
|
89
99
|
self._live, self._game_clock = live, game_clock
|
|
100
|
+
# The game's own log, asked on the clock's turns when the clock gives no start; a callable with reset().
|
|
101
|
+
self._game_log = game_log if game_log is not None else client.GameLogStart()
|
|
90
102
|
self._clock, self._wall, self._delay = clock, wall, delay
|
|
91
103
|
self._stop = stop if stop is not None else threading.Event()
|
|
92
104
|
self._sleep = sleep if sleep is not None else self._stop.wait
|
|
@@ -100,6 +112,8 @@ class Watcher:
|
|
|
100
112
|
self._last_alert = None
|
|
101
113
|
self._watch_since = None # the injected clock when the loading screen opened; None with no watch on
|
|
102
114
|
self._next_live = None # the injected clock from which the game's clock may be asked again
|
|
115
|
+
self._watch_wall = None # the wall clock when the loading screen opened, the game's log read against it
|
|
116
|
+
self._watch_began = None # the injected clock when the loading screen opened, never moved by a clock restart
|
|
103
117
|
self._paused = threading.Event() # set and cleared by the page's thread, read by the loop
|
|
104
118
|
self._pauses = 0 # every pause counted by the page's thread, under the lock; the loop compares it
|
|
105
119
|
self._honored = 0 # the count of the last pause the loop has rested for; read and written by it only
|
|
@@ -201,6 +215,8 @@ class Watcher:
|
|
|
201
215
|
self._forget()
|
|
202
216
|
phase = None
|
|
203
217
|
self._watch(phase)
|
|
218
|
+
if phase == IN_PROGRESS and self._watch_since is None: # the match under way: read only to see its end
|
|
219
|
+
return IN_GAME_PAUSE
|
|
204
220
|
return STEP_PAUSE
|
|
205
221
|
|
|
206
222
|
def snapshot(self):
|
|
@@ -283,12 +299,16 @@ class Watcher:
|
|
|
283
299
|
self._last_alert = (LOADING, self._wall())
|
|
284
300
|
self._log(LOADING_LINE)
|
|
285
301
|
self._note(LOADING)
|
|
286
|
-
self._watch_since = self._next_live = self._clock()
|
|
302
|
+
self._watch_since = self._next_live = self._watch_began = self._clock()
|
|
303
|
+
self._watch_wall = self._wall()
|
|
304
|
+
self._game_log.reset()
|
|
287
305
|
|
|
288
306
|
def _watch(self, phase):
|
|
289
307
|
"""One turn of the watch: the game's clock asked when due, its value above zero the start and any other
|
|
290
|
-
number a restart of the wait;
|
|
291
|
-
|
|
308
|
+
number a restart of the wait; with no start from the clock, the game's own log asked on that same turn, a
|
|
309
|
+
start line stamped no earlier than LIVE_LOG_GRACE_SECONDS before the loading screen the start; then the wait,
|
|
310
|
+
which fires on a step whose phase read was InProgress and ends with no alert with no client, held while the
|
|
311
|
+
game's log shows its join and no start, up to LIVE_JOINED_CEILING_SECONDS from the loading screen."""
|
|
292
312
|
if self._watch_since is None:
|
|
293
313
|
return
|
|
294
314
|
now = self._clock()
|
|
@@ -301,7 +321,13 @@ class Watcher:
|
|
|
301
321
|
return
|
|
302
322
|
if seconds is not None:
|
|
303
323
|
self._watch_since = now
|
|
324
|
+
if self._game_log(self._watch_wall - LIVE_LOG_GRACE_SECONDS):
|
|
325
|
+
self._watch_since = None
|
|
326
|
+
self._fire(MATCH_STARTED, STARTED_LINE)
|
|
327
|
+
return
|
|
304
328
|
if now >= self._watch_since + LIVE_FALLBACK_SECONDS:
|
|
329
|
+
if self._game_log.joined and now < self._watch_began + LIVE_JOINED_CEILING_SECONDS:
|
|
330
|
+
return # joined and not started yet: the watch goes on, the log still asked on each due turn
|
|
305
331
|
if phase == IN_PROGRESS:
|
|
306
332
|
self._watch_since = None
|
|
307
333
|
self._fire(MATCH_STARTED, STARTED_ON_WAIT_LINE)
|
|
@@ -333,11 +359,12 @@ class Watcher:
|
|
|
333
359
|
self._set_client(WAITING)
|
|
334
360
|
|
|
335
361
|
def _rest(self):
|
|
336
|
-
"""The first paused turn: the client, the watch, the hold and the start latch are dropped
|
|
337
|
-
after a resume is a fresh connection."""
|
|
362
|
+
"""The first paused turn: the client, the watch, the hold and the start latch are dropped and the reader of
|
|
363
|
+
the game's log reset, so the turn after a resume is a fresh connection."""
|
|
338
364
|
self._resting = True
|
|
339
365
|
self._forget()
|
|
340
|
-
self._watch_since = self._next_live = None
|
|
366
|
+
self._watch_since = self._next_live = self._watch_wall = self._watch_began = None
|
|
367
|
+
self._game_log.reset()
|
|
341
368
|
self._hold_until = None
|
|
342
369
|
self._start_alerted = False
|
|
343
370
|
self._log(PAUSED_LINE)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pendify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: Pairs this PC with a phone account by a QR on a loopback page and sends it two kinds of alerts.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/ElkinDev/PendiFy
|
|
@@ -73,7 +73,7 @@ El botón de arriba a la derecha cambia entre el tema claro y el oscuro, y el pr
|
|
|
73
73
|
|
|
74
74
|
### Qué envía y a quién
|
|
75
75
|
|
|
76
|
-
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía.
|
|
76
|
+
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía. Si el juego no da su reloj, lee en su lugar el registro propio del juego en este mismo PC, solo la hora de dos clases de línea, y no guarda ni envía nada de él. Una vez empezada la partida, pregunta al cliente del juego una vez cada cinco segundos, solo para ver cuándo termina.
|
|
77
77
|
|
|
78
78
|
### `--dry`
|
|
79
79
|
|
|
@@ -138,7 +138,7 @@ The button at the top right switches between the light and the dark theme, and t
|
|
|
138
138
|
|
|
139
139
|
### What it sends and to whom
|
|
140
140
|
|
|
141
|
-
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it.
|
|
141
|
+
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it. When the game gives no clock, it reads the game's own log on this same PC instead, only the time stamps of two kinds of line, and neither keeps nor sends any of it.
|
|
142
142
|
|
|
143
143
|
### `--dry`
|
|
144
144
|
|
|
@@ -152,7 +152,7 @@ License: MIT
|
|
|
152
152
|
python -m pendify ping <kind>
|
|
153
153
|
|
|
154
154
|
The first loads the config, starts the page and opens it in the default browser, paired or not.
|
|
155
|
-
It also watches the game client on this PC: when a match is found it accepts after a short random delay, beeps, and sends the found-match alert; when the loading screen starts it beeps, and when the match itself starts it beeps and sends the started alert.
|
|
155
|
+
It also watches the game client on this PC: when a match is found it accepts after a short random delay, beeps, and sends the found-match alert; when the loading screen starts it beeps, and when the match itself starts it beeps and sends the started alert. Once the match has started it asks the game client once every five seconds, only to see the match end.
|
|
156
156
|
Add `--dry` to watch and alert without accepting. Add `--quiet` for the start by the system at logon, the line the start with Windows switch writes (`pythonw -m pendify --quiet`): it never opens the browser, a start that ends well shows no window, and a second quiet start prints `already running` and exits. One copy runs per config folder: a second start opens the page of the one that runs and exits. Ctrl+C stops the page and the watcher together.
|
|
157
157
|
The second sends one alert with the stored pair and prints one line with the answer.
|
|
158
158
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|