Repository navigation
Expand file tree
/
Copy pathgithub_release_tracker.py
More file actions
1927 lines (1731 loc) · 84 KB
/
Copy pathgithub_release_tracker.py
File metadata and controls
1927 lines (1731 loc) · 84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
GitHub Release Tracker (portable)
=================================
A small portable Windows desktop app (Python + tkinter, standard library only)
that tracks the latest release of GitHub projects and tells you when a new one
has been published since you last acknowledged it.
How it works
- Add a project by pasting a GitHub URL or "owner/repo".
- The list shows project name, owner/repo, latest release, publish date, status.
- "Check for updates" reads each project's public release feed
(github.com/owner/repo/releases.atom): no login or token needed and it does not
use the GitHub API rate limit. The API is only a fallback.
- A project whose latest release differs from the one you last acknowledged is
highlighted as "Update available: old -> new".
- "Mark as seen" acknowledges the current release (clears the highlight).
- The app never downloads or installs anything; it opens the release page.
- "Import" / "Export" read and write a .json file (merge or replace on import).
- The moon / sun button toggles the dark / light theme; the choice is remembered.
- Hover a row and click the pencil (or press F2, or right-click > Rename) to give a
project your own display name. Reset name brings the GitHub name back.
Portable: no installer, no registry writes. Data lives in projects.json next to
the .exe (or this script). Only if that folder is read-only does the app fall
back to %APPDATA%\\GitHubReleaseTracker.
Build the single-file portable .exe on Windows: double-click build.bat, or run
pip install pyinstaller
pyinstaller --onefile --windowed --icon icon.ico --name GitHubReleaseTracker github_release_tracker.py
The exe appears in the dist folder.
"""
import base64
import json
import os
import queue
import re
import struct
import sys
import threading
import urllib.error
import urllib.parse
import urllib.request
import xml.etree.ElementTree as ET
import webbrowser
import zlib
from datetime import datetime
import tkinter as tk
from tkinter import filedialog, messagebox, ttk
APP_NAME = "GitHub Release Tracker"
# Keep in step with the release tag: tag v1.1.1 <-> APP_VERSION "1.1.1" (build.bat checks the format).
APP_VERSION = "1.1.1"
APP_ID = "santosasarno-code.GitHubReleaseTracker" # Windows taskbar identity (so the taskbar shows our icon)
REPO_URL = "https://github.com/santosasarno-code/github-release-tracker"
NO_DESCRIPTION = "No description, website, or topics provided." # same wording GitHub shows for an empty About box
API = "https://api.github.com"
MAX_PROJECTS = 500
MAX_IMPORT_BYTES = 5 * 1024 * 1024
MAX_CUSTOM_NAME = 80
# --- BEGIN GENERATED ICON DATA (tools/make_icons.py) ---
# Toolbar icons: zlib-compressed 8-bit alpha masks, base64. Window icon: 64 px PNG, base64.
ICON_MASKS = {
"refresh": {
16: (
"eNpjYAADRkYGRgY4YGZiYGBhNBSBigF5PLwMDA/CGJkh3MDd7z9um/1/MQMzmNvy///Tp/+BQBbIYWbw+//Uk4194eEZeZJA"
"Y5kYDvx3AxrEBbWIgefTUyaQBczsrIwIPiML1G6YegaHdCGgdrh5ni//e6Da1wByGMw973cHwn0Aci8PA1QW5h8mZgYkwAhT"
"CwBdBy28"
),
24: (
"eNpjYEADTAxYASOGOhYgYGRiyJdDlmNkhsoq/YtkZEE2VC68ujpcnmHt/7UMzAhhiTmf/gPBp21//32RgNnNxKD/8D8U/P7x"
"P5sBYhATk9iT//+/LUxPn/cNJLWLEaKemWHe/7+3dIEs3osHp2TayjBCTZH5/u+rJgMbC4uAAJLDWRgi//9fyMAK8wUzI0y8"
"5t//FIijGZH8hCwOFGZhxGIOE0oAwu1lY9A+VyjJCNWBcCeD7s3//ydBvYXkr4VAfz2QZGRiwAyHh/pIliDCbY4Emt2QcJZD"
"j0dYvDBjj0cckU4EAAARF2gZ"
),
},
"eye": {
16: (
"eNpjYCAIGJlZWJhBmBHMZUbIgJhMDAwm+TPXrp2ZbwLiMDEEXPwPBRcDgNz0/x973Xf9/r3Lvffj/3QGga9X+Bk0/wGBJgP/"
"la8C6Hx09RjmodmH4R4M9+IHADTyQCU="
),
24: (
"eNpjYKALYGRmAQNmRmRBFiYEh4kFJsUMxBIOaQ39/Q1pDhJQARDJmbz9zX8oeLM9mRMswczgdx0k8PPH798/foJY1/2AgswM"
"mUDm1amRTT///v3ZFDn1KpCbCRTW/f//URgbA+uT/3///n/CysAW9uj/f10GhpZ/v8wZWFmi///+D0TRLKwM5r/+teAWx2EO"
"TntxuBOnv3CGA85wwxnOtAQAc0yQHQ=="
),
},
"ext": {
16: (
"eNpjYAADZhYWFmZmJgbsgJEppX/SwtU7pzM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+pjDNmUn/NTe3lZVXp15x3"
"Nr948u/84e97kcihScJb3zCHjy5+I6qKFVPnbhcIGnDGcOefdvHhH/6cwXKFlkw06eXmptZ1UgXgpEKe36x5L9/9/RPseK6P"
"BbNm8KG3LCCfiajpJPXMN0QEK4brtzzMNXduJXaOQhzhg/73t8EqCNCWjfnU2855+RueOjrvg2KNkIbAJ3t+w433PUZbSw6p"
"3fuf5AG1owJUFf8i+lkxdXU+DVXK9w4WufT7P+XXT+5meiFfzTqnIqT1a8ISXIMOTEec/+PeXlZ+7y6eer6PztY8iZ/6a33X"
"3K19Rxa76S25ujjf1NVgNcusZn3Xb3mY93znx5RTTyGOjinlPa4Y0AixO24AaJTY1QWA6prU0av+a14bJnZjA6CEifYJZVy1"
"zs9Y26h+3oaJ3Vjt9E5hQMR0jNcp5lXJxxk2Pbide3c+04A3Qy/Qf9uufxJU6y52R5ouUQ0DDtiNtR0kYUwmqCqRM+zsPcj2"
"Z/c39CC0Nc4gYuoudi8bpHDWEMJuB3q/GHu2SkXH66dRhThy5DKu4TuAqtLg/iMVY1Eq9zsDt2uafHIiOUE13eVEMKNpgoHb"
"zcDTs7apTx+TTFwbPTvhzUsmRn362MDTs7YZelZ4QdZjI2k895oiv1ZsJIKsp2eFt3R3m/IXr9ke/+y+Lsnm59RGZswJ6nwq"
"2bzT0tC2Q9ddcSWMtMqKINjVmlT6cZFD1Z+Azntc5DSp9At29Uit/oofm6syoKfH093tBjZctUUqpWUgfZLNO5S0NnzIcTs4"
"qaSSzTuQPqmUlg1suGoL3d2Onh7Pf4zIbN0a6O525S997m+ZhUvuwNj5ks2eJkaEkI6Mzo5wptlHZwNgJBOLZGKjSbJFh4cu"
"OrThs38Ye3SW/w9P80ocn/835VdnC4YtbSsAAAAASUVORK5CYII="
)
# --- END GENERATED ICON DATA ---
def app_dir():
if getattr(sys, "frozen", False):
return os.path.dirname(sys.executable)
return os.path.dirname(os.path.abspath(__file__))
def data_dir():
"""Prefer the folder next to the exe (portable); fall back if read-only."""
base = app_dir()
probe = os.path.join(base, ".write_test_%d" % os.getpid())
try:
with open(probe, "w") as f:
f.write("x")
os.remove(probe)
return base
except OSError:
root = os.environ.get("APPDATA") or os.path.expanduser("~")
path = os.path.join(root, "GitHubReleaseTracker")
try:
os.makedirs(path, exist_ok=True)
return path
except OSError:
return base
DATA_FILE = os.path.join(data_dir(), "projects.json")
# --------------------------------------------------------------------------
# GitHub API helpers
# --------------------------------------------------------------------------
class GitHubError(Exception):
pass
class NotFoundError(GitHubError):
pass
class RateLimitError(GitHubError):
pass
# Remaining API calls reported by the last response (None = unknown).
last_rate_remaining = None
def api_get(path, token=""):
global last_rate_remaining
headers = {
"Accept": "application/vnd.github+json",
"User-Agent": "GitHubReleaseTracker",
"X-GitHub-Api-Version": "2022-11-28",
}
if token:
headers["Authorization"] = "Bearer " + token
req = urllib.request.Request(API + path, headers=headers)
try:
with urllib.request.urlopen(req, timeout=15) as resp:
remaining = resp.headers.get("X-RateLimit-Remaining")
if remaining is not None and remaining.isdigit():
last_rate_remaining = int(remaining)
return json.load(resp)
except urllib.error.HTTPError as e:
remaining = e.headers.get("X-RateLimit-Remaining") if e.headers else None
if e.code in (403, 429) and remaining == "0":
reset = e.headers.get("X-RateLimit-Reset", "")
when = ""
if reset.isdigit():
when = " Resets at " + datetime.fromtimestamp(int(reset)).strftime("%H:%M") + "."
last_rate_remaining = 0
raise RateLimitError("GitHub API rate limit reached." + when +
" Add a token in Settings for a higher limit.")
if e.code == 404:
raise NotFoundError("Not found (wrong name, or a private repository).")
if e.code == 401:
raise GitHubError("GitHub rejected the token (401). Check it in Settings.")
raise GitHubError("GitHub returned HTTP %d." % e.code)
except urllib.error.URLError as e:
raise GitHubError("Network error: %s" % e.reason)
except (TimeoutError, OSError) as e:
raise GitHubError("Network error: %s" % e)
except ValueError:
raise GitHubError("Unexpected response from GitHub.")
def parse_repo(text):
"""Accept https://github.com/owner/repo[/...] or owner/repo."""
text = (text or "").strip()
m = re.match(r"^(?:https?://)?(?:www\.)?github\.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)", text)
if not m:
m = re.match(r"^([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)$", text)
if not m:
return None
owner, repo = m.group(1), m.group(2)
if repo.endswith(".git"):
repo = repo[:-4]
if not repo:
return None
return owner, repo
def fetch_repo_info(owner, repo, token=""):
d = api_get("/repos/%s/%s" % (owner, repo), token)
full = d.get("full_name") or "%s/%s" % (owner, repo)
real_owner, real_repo = full.split("/", 1)
return {
"owner": real_owner,
"repo": real_repo,
"title": d.get("name") or real_repo,
"description": d.get("description") or "",
"html_url": d.get("html_url") or "https://github.com/" + full,
}
def _release_dict(r):
return {
"id": r.get("id"),
"tag": r.get("tag_name") or "",
"name": r.get("name") or "",
"published_at": r.get("published_at") or r.get("created_at") or "",
"url": r.get("html_url") or "",
"prerelease": bool(r.get("prerelease")),
"source": "release",
}
def _newest_release(owner, repo, token):
"""Newest non-draft release, pre-releases included. None if there are none."""
try:
data = api_get("/repos/%s/%s/releases?per_page=10" % (owner, repo), token)
except NotFoundError:
return None
for r in data:
if not r.get("draft"):
return _release_dict(r)
return None
def _newest_tag(owner, repo, token):
"""First tag GitHub returns. Used only when no GitHub Release exists at all.
Caveat: the tags endpoint does not guarantee newest-first ordering, and
tags carry no publish date.
"""
try:
data = api_get("/repos/%s/%s/tags?per_page=1" % (owner, repo), token)
except NotFoundError:
return None
if not data:
return None
t = data[0]
name = t.get("name") or ""
sha = (t.get("commit") or {}).get("sha") or name
return {
"id": sha,
"tag": name,
"name": "",
"published_at": "",
"url": "https://github.com/%s/%s/releases/tag/%s" % (owner, repo, urllib.parse.quote(name, safe="")),
"prerelease": False,
"source": "tag",
}
def fetch_latest_release(owner, repo, token="", include_prereleases=False):
"""Return the latest version info dict, or None if the project has nothing.
Order of preference:
1. newest stable GitHub Release (or newest incl. pre-releases if enabled)
2. newest pre-release, when no stable release exists
3. newest git tag, when no GitHub Release exists at all
"""
if not include_prereleases:
try:
return _release_dict(api_get("/repos/%s/%s/releases/latest" % (owner, repo), token))
except NotFoundError:
pass # no stable release; fall through to pre-releases / tags
rel = _newest_release(owner, repo, token)
if rel:
return rel
return _newest_tag(owner, repo, token)
FEED_NS = "{http://www.w3.org/2005/Atom}"
def fetch_latest_from_feed(owner, repo):
"""Newest release from the public releases.atom feed (no token, no API quota).
The feed lists every published release, pre-releases included, newest first.
It does not say which entries are pre-releases. Returns None if it is empty.
"""
url = "https://github.com/%s/%s/releases.atom" % (owner, repo)
req = urllib.request.Request(url, headers={
"User-Agent": "GitHubReleaseTracker",
"Accept": "application/atom+xml, application/xml;q=0.9, */*;q=0.8",
})
try:
with urllib.request.urlopen(req, timeout=15) as resp:
body = resp.read()
except urllib.error.HTTPError as e:
if e.code == 404:
raise NotFoundError("Not found (wrong name, or a private repository).")
if e.code == 429:
raise GitHubError("GitHub is rate-limiting the release feed (429). Try again later.")
raise GitHubError("Release feed returned HTTP %d." % e.code)
except urllib.error.URLError as e:
raise GitHubError("Network error: %s" % e.reason)
except (TimeoutError, OSError) as e:
raise GitHubError("Network error: %s" % e)
try:
root = ET.fromstring(body)
except ET.ParseError:
raise GitHubError("Release feed was not valid XML.")
entry = root.find(FEED_NS + "entry")
if entry is None:
return None
entry_id = (entry.findtext(FEED_NS + "id") or "").strip()
title = (entry.findtext(FEED_NS + "title") or "").strip()
updated = (entry.findtext(FEED_NS + "updated") or "").strip()
href = ""
for link in entry.findall(FEED_NS + "link"):
if link.get("rel", "alternate") == "alternate":
href = link.get("href") or ""
break
marker = "/releases/tag/"
if marker in href:
tag = urllib.parse.unquote(href.split(marker, 1)[1])
else:
m = re.search(r"Repository/\d+/(.+)$", entry_id)
tag = m.group(1) if m else ""
if not (entry_id or tag):
return None
return {
"id": entry_id or tag,
"tag": tag,
"name": title,
"published_at": updated,
"url": href or "https://github.com/%s/%s/releases" % (owner, repo),
"prerelease": False, # not reported by the feed
"source": "feed",
}
def get_latest(owner, repo, token="", include_prereleases=True):
"""Feed first (free, no quota); GitHub API as fallback.
Stable-only mode needs the API, because the feed does not mark pre-releases.
"""
if include_prereleases:
try:
rel = fetch_latest_from_feed(owner, repo)
if rel:
return rel
except GitHubError:
pass # feed unavailable or repo has no releases: try the API
return fetch_latest_release(owner, repo, token, include_prereleases)
def apply_result(p, latest, err, now):
"""Store one check result on project p, without inventing false updates."""
p["last_checked"] = now
if err:
p["error"] = err
return
p["error"] = None
if latest:
if p.get("seen_tag") and p["seen_tag"] == latest["tag"]:
# Same release as the one already seen; only the ID scheme differs
# (API release ID vs feed entry ID), so carry the acknowledgement over.
p["seen_id"] = latest["id"]
elif p.get("fmt") != 2 and p.get("seen_id") is None:
# Entry saved by an older version that found nothing: treat what
# exists now as the baseline instead of flagging it.
p["seen_id"], p["seen_tag"] = latest["id"], latest["tag"]
p["latest"] = latest
p["fmt"] = 2
# --------------------------------------------------------------------------
# Storage, import and export (all input is treated as untrusted)
# --------------------------------------------------------------------------
NAME_RE = re.compile(r"^[A-Za-z0-9_.-]{1,100}$")
def _s(value, limit=300):
return value.strip()[:limit] if isinstance(value, str) else ""
def safe_github_url(url, fallback):
"""Only ever open https://github.com/... links, whatever a JSON file says."""
if (isinstance(url, str) and url.startswith("https://github.com/") and len(url) < 500
and not any(c.isspace() for c in url)):
return url
return fallback
def _id_value(value):
if isinstance(value, bool) or not isinstance(value, (int, str)):
return None
return value[:300] if isinstance(value, str) else value
def normalize_release(r, owner, repo):
if not isinstance(r, dict):
return None
tag = _s(r.get("tag"), 200)
rid = _id_value(r.get("id"))
if rid is None:
rid = tag or None
if rid is None:
return None
source = r.get("source")
return {
"id": rid,
"tag": tag,
"name": _s(r.get("name"), 300),
"published_at": _s(r.get("published_at"), 40),
"url": safe_github_url(r.get("url"), "https://github.com/%s/%s/releases" % (owner, repo)),
"prerelease": bool(r.get("prerelease")),
"source": source if source in ("release", "tag", "feed") else "release",
}
def clean_name(value):
"""A user-chosen display name: one line, single spaces, at most MAX_CUSTOM_NAME characters."""
if not isinstance(value, str):
return ""
return " ".join(value.split())[:MAX_CUSTOM_NAME].strip()
def display_name(p):
"""What the Project column shows: the user's own name if set, else the GitHub name."""
return p.get("custom_name") or p.get("title") or p["repo"]
def normalize_project(raw):
"""Return a clean project dict from untrusted input, or None if unusable."""
if isinstance(raw, str):
parsed = parse_repo(raw)
if not parsed:
return None
raw = {"owner": parsed[0], "repo": parsed[1]}
if not isinstance(raw, dict):
return None
owner, repo = raw.get("owner"), raw.get("repo")
if not (isinstance(owner, str) and isinstance(repo, str)
and NAME_RE.match(owner) and NAME_RE.match(repo)):
return None
fmt = raw.get("fmt")
out = {
"owner": owner,
"repo": repo,
"title": _s(raw.get("title"), 200) or repo,
"description": _s(raw.get("description"), 500),
"html_url": safe_github_url(raw.get("html_url"), "https://github.com/%s/%s" % (owner, repo)),
"include_prereleases": bool(raw.get("include_prereleases", True)),
"fmt": fmt if fmt == 2 else None,
"latest": normalize_release(raw.get("latest"), owner, repo),
"seen_id": _id_value(raw.get("seen_id")),
"seen_tag": _s(raw.get("seen_tag"), 200) or None,
"last_checked": _s(raw.get("last_checked"), 40),
"error": _s(raw.get("error"), 300) or None,
}
custom = clean_name(raw.get("custom_name"))
if custom: # only present when the user renamed the project
out["custom_name"] = custom
return out
def parse_import(raw):
"""Return (projects, skipped_count), or (None, 0) if there is no project list.
Accepts this app's file ({"projects": [...]}), a bare list, and lists of
plain "owner/repo" strings or GitHub URLs.
"""
items = raw.get("projects") if isinstance(raw, dict) else raw
if not isinstance(items, list):
return None, 0
seen, out, skipped = set(), [], max(0, len(items) - MAX_PROJECTS)
for item in items[:MAX_PROJECTS]:
p = normalize_project(item)
if not p or project_key(p) in seen:
skipped += 1
continue
seen.add(project_key(p))
out.append(p)
return out, skipped
def merge_projects(existing, incoming):
"""Add incoming projects that are not already listed. Returns how many were added."""
keys = {project_key(p) for p in existing}
added = 0
for p in incoming:
k = project_key(p)
if k not in keys:
existing.append(p)
keys.add(k)
added += 1
return added
def build_export(projects):
"""Export payload. The access token is deliberately never included."""
return {
"app": APP_NAME,
"format": 2,
"exported_at": datetime.now().isoformat(timespec="seconds"),
"projects": projects,
}
SORTABLE = ("name", "repo", "published", "status") # columns whose header can be clicked
def _title_key(p):
return display_name(p).casefold()
def status_rank(p):
"""Order of the Status column. Same precedence as status_text()."""
if p.get("error"):
return 1 # Error
if not p.get("latest"):
return 2 # No releases published
return 0 if has_update(p) else 3 # Update available / Up to date
def sort_projects(projects, col, asc):
"""Return projects sorted by column. col "" = default (updates first, then A-Z).
Projects without a publish date (no release, or a tag) always stay at the
bottom for "published", whichever direction is chosen.
Status: ascending = Update available, Error, No releases, Up to date;
descending = the reverse, so "Up to date" comes first. Projects with the
same status are always A-Z.
"""
if col == "status":
sign = 1 if asc else -1
return sorted(projects, key=lambda p: (sign * status_rank(p), _title_key(p), project_key(p)))
if col == "name":
return sorted(projects, key=lambda p: (_title_key(p), project_key(p)), reverse=not asc)
if col == "repo":
return sorted(projects, key=project_key, reverse=not asc)
if col == "published":
dated = [p for p in projects if (p.get("latest") or {}).get("published_at")]
undated = [p for p in projects if not (p.get("latest") or {}).get("published_at")]
dated.sort(key=lambda p: (p["latest"]["published_at"], _title_key(p)), reverse=not asc)
undated.sort(key=_title_key)
return dated + undated
return sorted(projects, key=lambda p: (not has_update(p), _title_key(p)))
def default_data():
return {"settings": {"token": "", "check_on_launch": False, "theme": "",
"sort_col": "", "sort_asc": True}, "projects": []}
def load_data():
if not os.path.exists(DATA_FILE):
return default_data()
try:
with open(DATA_FILE, "r", encoding="utf-8-sig") as f:
d = json.load(f)
if not isinstance(d, dict) or not isinstance(d.get("projects", []), list):
raise ValueError("bad structure")
except (OSError, ValueError, RecursionError):
try:
os.replace(DATA_FILE, DATA_FILE + ".bak")
except OSError:
pass
return default_data()
base = default_data()
s = d.get("settings")
if isinstance(s, dict):
base["settings"]["token"] = _s(s.get("token"), 200)
base["settings"]["check_on_launch"] = bool(s.get("check_on_launch"))
base["settings"]["theme"] = s.get("theme") if s.get("theme") in ("light", "dark") else ""
base["settings"]["sort_col"] = s.get("sort_col") if s.get("sort_col") in SORTABLE else ""
base["settings"]["sort_asc"] = s.get("sort_asc") is not False
projects, _ = parse_import(d)
base["projects"] = projects or []
return base
def write_json_atomic(path, obj):
tmp = path + ".tmp"
with open(tmp, "w", encoding="utf-8") as f:
json.dump(obj, f, indent=2, ensure_ascii=False)
os.replace(tmp, path)
def save_data(data):
write_json_atomic(DATA_FILE, data)
def project_key(p):
return ("%s/%s" % (p["owner"], p["repo"])).lower()
def has_update(p):
latest = p.get("latest")
return bool(latest) and latest.get("id") != p.get("seen_id")
def status_text(p):
if p.get("error"):
return "Error: " + p["error"]
latest = p.get("latest")
if not latest:
return "No releases published"
if has_update(p):
old = p.get("seen_tag")
new = latest.get("tag") or latest.get("name") or "new release"
return "Update available: %s -> %s" % (old, new) if old else "Update available: " + new
return "Up to date"
# --------------------------------------------------------------------------
# Theme
# --------------------------------------------------------------------------
THEMES = {
"light": dict(bg="#f3f3f3", fg="#1b1b1b", field="#ffffff", sel_bg="#0078d4", sel_fg="#ffffff",
head_bg="#e5e5e5", btn_bg="#e1e1e1", btn_active="#d0d0d0", border="#bdbdbd",
update_bg="#fff3cd", update_fg="#1b1b1b", error_fg="#b00020",
none_fg="#777777", sub_fg="#666666", line="#d4d4d4", tip_bg="#ffffe1", tip_fg="#1b1b1b"),
"dark": dict(bg="#202124", fg="#e8eaed", field="#2b2d31", sel_bg="#2f6fbf", sel_fg="#ffffff",
head_bg="#33363b", btn_bg="#3a3d42", btn_active="#4a4d52", border="#4a4d52",
update_bg="#4d4210", update_fg="#ffe9a6", error_fg="#ff8a80",
none_fg="#9aa0a6", sub_fg="#9aa0a6", line="#3d4046", tip_bg="#3a3d42", tip_fg="#e8eaed"),
}
def system_theme():
"""Windows' own app theme (dark/light); light if it cannot be read."""
try:
import winreg
key = r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key) as k:
return "light" if winreg.QueryValueEx(k, "AppsUseLightTheme")[0] else "dark"
except Exception: # noqa: BLE001 - not Windows / value missing
return "light"
def set_titlebar_dark(win, dark):
"""Best effort: dark title bar on Windows 10/11. May show after a repaint."""
try:
import ctypes
win.update_idletasks()
hwnd = ctypes.windll.user32.GetParent(win.winfo_id())
value = ctypes.c_int(1 if dark else 0)
for attr in (20, 19): # 20 = current, 19 = older Windows 10 builds
if ctypes.windll.dwmapi.DwmSetWindowAttribute(
hwnd, attr, ctypes.byref(value), ctypes.sizeof(value)) == 0:
break
except Exception: # noqa: BLE001
pass
# --------------------------------------------------------------------------
# Icons (drawn from embedded alpha masks; no image files, no extra packages)
# --------------------------------------------------------------------------
def make_png(w, h, rgba):
"""Encode raw RGBA bytes as a PNG (standard library only)."""
raw = b"".join(b"\x00" + rgba[y * w * 4:(y + 1) * w * 4] for y in range(h))
def chunk(kind, body):
crc = zlib.crc32(kind + body) & 0xFFFFFFFF
return struct.pack(">I", len(body)) + kind + body + struct.pack(">I", crc)
return (b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", w, h, 8, 6, 0, 0, 0))
+ chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b""))
def icon_image(master, name, size, color):
"""A PhotoImage of a toolbar icon in the given color, or None if anything goes wrong
(the buttons then simply show their text without an icon)."""
try:
mask = zlib.decompress(base64.b64decode(ICON_MASKS[name][size]))
r, g, b = (int(color[i:i + 2], 16) for i in (1, 3, 5))
rgba = b"".join(bytes((r, g, b, a)) for a in mask)
return tk.PhotoImage(master=master, data=base64.b64encode(make_png(size, size, rgba)))
except Exception: # noqa: BLE001
return None
class Tooltip:
"""A small hover label for a widget (used on the icon-only theme button)."""
def __init__(self, widget, text_fn, colors_fn):
self.widget, self.text_fn, self.colors_fn = widget, text_fn, colors_fn
self.tip, self.job = None, None
widget.bind("<Enter>", self._schedule, add="+")
widget.bind("<Leave>", self._hide, add="+")
widget.bind("<ButtonPress>", self._hide, add="+")
def _schedule(self, _e=None):
self._hide()
self.job = self.widget.after(500, self._show)
def _show(self):
self.job = None
bg, fg = self.colors_fn()
tip = self.tip = tk.Toplevel(self.widget)
tip.wm_overrideredirect(True)
tk.Label(tip, text=self.text_fn(), bg=bg, fg=fg, bd=1, relief="solid", padx=6, pady=2).pack()
tip.update_idletasks()
x = self.widget.winfo_rootx()
y = self.widget.winfo_rooty() + self.widget.winfo_height() + 4
x = max(0, min(x, self.widget.winfo_screenwidth() - tip.winfo_reqwidth() - 4))
tip.wm_geometry("+%d+%d" % (x, y))
def _hide(self, _e=None):
if self.job:
self.widget.after_cancel(self.job)
self.job = None
if self.tip:
self.tip.destroy()
self.tip = None
# --------------------------------------------------------------------------
# GUI
# --------------------------------------------------------------------------
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title("%s v%s" % (APP_NAME, APP_VERSION))
self.geometry("1260x560") # replaced below by a screen-aware size
self.app_icon = None
try: # window / taskbar icon (the .exe's own icon comes from build.bat --icon)
self.app_icon = tk.PhotoImage(master=self, data=APP_ICON_PNG)
self.iconphoto(True, self.app_icon)
except Exception: # noqa: BLE001 - cosmetic only
self.app_icon = None
# Toolbar icons: 16 px normally, 24 px on high-DPI screens (150% and up).
try:
self.icon_px = 24 if self.winfo_fpixels("1i") / 96.0 >= 1.4 else 16
except tk.TclError:
self.icon_px = 16
self._btn_icons = [] # (button, icon name) pairs, recolored when the theme changes
self._icon_refs = [] # PhotoImages must stay referenced or Tk blanks them
self._pencil_imgs = {}
self._editor = None # inline rename box: (entry, row id, project)
self._suppress_select = False # True while render() restores the selection (see _on_select)
self._col_base, self._col_min = {}, {} # preferred / minimum column widths (see _layout_columns)
self._tree_w, self._col_drag = 0, False
self._lines, self._lines_job = [], None
self._vlines, self._head_h = [], None # column lines; measured height of the header row
self._hsb_shown = False
self._xorg = 2
self.data = load_data()
self.theme_name = self.data["settings"].get("theme") or system_theme()
self.sort_col = self.data["settings"].get("sort_col") or ""
self.sort_asc = self.data["settings"].get("sort_asc") is not False
self.busy = False
self.q = queue.Queue()
self._build_ui()
self.apply_theme()
self.render()
# Never let the window get narrower than the toolbar needs (buttons overlapped).
self.update_idletasks()
min_w, min_h = max(700, self.toolbar.winfo_reqwidth() + 20), 340
self.minsize(min_w, min_h)
# Normal start size: wide enough that every column fits (no horizontal scrollbar),
# but never bigger than the screen, never below the minimum; opens centered.
sw, sh = self.winfo_screenwidth(), self.winfo_screenheight()
w = max(min(1260, sw - 40), min_w)
h = max(min(560, sh - 120), min_h)
self.geometry("%dx%d+%d+%d" % (w, h, max(0, (sw - w) // 2), max(0, (sh - h) // 3)))
self.after(100, self._poll)
if self.data["settings"].get("check_on_launch") and self.data["projects"]:
self.after(400, self.check_updates)
# ---- layout ----------------------------------------------------------
def _build_ui(self):
self.style = ttk.Style(self)
try:
self.style.theme_use("clam") # the only built-in theme that is fully recolorable
except tk.TclError:
pass
top = ttk.Frame(self, padding=(10, 10, 10, 4))
top.pack(fill="x")
ttk.Label(top, text="GitHub project (URL or owner/repo):").pack(side="left")
self.entry = ttk.Entry(top)
self.entry.pack(side="left", fill="x", expand=True, padx=8)
self.entry.bind("<Return>", lambda e: self.add_project())
self.btn_add = self._button(top, "Add project", "plus", self.add_project)
self.btn_add.pack(side="left")
bar = ttk.Frame(self, padding=(10, 4, 10, 6))
bar.pack(fill="x")
self.toolbar = bar
self.btn_check = self._button(bar, "Check for updates", "refresh", self.check_updates)
self.btn_check.pack(side="left")
self._button(bar, "Mark as seen", "eye", self.mark_seen).pack(side="left", padx=(8, 0))
self._button(bar, "Open release page", "ext", self.open_release).pack(side="left", padx=(8, 0))
self._button(bar, "Remove", "trash", self.remove_selected).pack(side="left", padx=(8, 0))
self._button(bar, "Settings", "gear", self.open_settings).pack(side="right")
# Icon-only: shows the mode you will switch TO (moon = go dark, sun = go light).
self.btn_theme = self._button(bar, "", "moon", self.toggle_theme)
self.btn_theme.pack(side="right", padx=(0, 8))
Tooltip(self.btn_theme,
lambda: "Switch to light mode" if self.theme_name == "dark" else "Switch to dark mode",
lambda: (THEMES[self.theme_name]["tip_bg"], THEMES[self.theme_name]["tip_fg"]))
self._button(bar, "Export", "export", self.export_json).pack(side="right", padx=(0, 8))
self._button(bar, "Import", "import", self.import_json).pack(side="right", padx=(0, 8))
frame = ttk.Frame(self, padding=(10, 0, 10, 0))
frame.pack(fill="both", expand=True)
cols = ("name", "repo", "release", "published", "status", "checked")
self.tree = ttk.Treeview(frame, columns=cols, show="headings", selectmode="extended")
heads = [
("name", "Project", 230, 120),
("repo", "Repository", 280, 120),
("release", "Current release", 150, 90),
("published", "Published", 125, 115), # wide enough for the sort arrow
("status", "Status", 260, 120),
("checked", "Last checked", 140, 110),
]
self.head_text = {cid: text for cid, text, _w, _mw in heads}
for cid, text, w, mw in heads:
if cid in SORTABLE: # Current release / Last checked: not clickable
self.tree.heading(cid, text=text, anchor="w", command=lambda c=cid: self.sort_by(c))
else:
self.tree.heading(cid, text=text, anchor="w")
# No Tk "stretch": _layout_columns() resizes every column in proportion to the window.
self.tree.column(cid, width=w, minwidth=mw, stretch=False)
self._col_base[cid], self._col_min[cid] = w, mw
self.update_headings()
# Grid (not pack) so the scrollbars always keep their own space: with pack the
# list took the full width of its columns and pushed the scrollbar out of view.
self.vsb = ttk.Scrollbar(frame, orient="vertical", command=self.tree.yview)
self.hsb = ttk.Scrollbar(frame, orient="horizontal", command=self.tree.xview)
self.tree.configure(yscrollcommand=self._on_yscroll, xscrollcommand=self._on_xscroll)
frame.rowconfigure(0, weight=1)
frame.columnconfigure(0, weight=1)
self.tree.grid(row=0, column=0, sticky="nsew")
self.vsb.grid(row=0, column=1, sticky="ns")
self.hsb.grid(row=1, column=0, sticky="ew")
self.hsb.grid_remove() # shown only when the columns do not fit (see _on_xscroll)
self.tree.bind("<Double-1>", self._on_double_click)
self.tree.bind("<<TreeviewSelect>>", self._on_select)
self.tree.bind("<Button-3>", self._popup)
self.tree.bind("<Delete>", lambda e: self.remove_selected())
self.tree.bind("<F2>", lambda e: self.rename_selected())
self.tree.bind("<Button-1>", self._on_tree_click, add="+")
self.tree.bind("<Configure>", self._schedule_lines, add="+")
self.tree.bind("<Configure>", self._layout_columns, add="+")
self.tree.bind("<ButtonPress-1>", self._col_press, add="+")
self.tree.bind("<ButtonRelease-1>", self._col_release, add="+")
self.tree.bind("<B1-Motion>", lambda e: self._schedule_lines() if self._col_drag else None, add="+")
self.tree.bind("<Motion>", self._on_motion, add="+")
self.tree.bind("<Leave>", self._on_leave, add="+")
self.tree.bind("<MouseWheel>", lambda e: self._hide_pencil(), add="+")
# Hover pencil (rename). A Label placed over the list: Treeview cannot hold widgets in cells.