Skip to content

Commit 845a5ac

Browse files
authored
[region-editor] Transition to Tcl/Tk for GUI #181 (#182)
This allows for better control over window events and makes input handling more consistent across platforms. It also allows better customization, for example, the system undo/redo commands are used instead of key binds. There is still much work to do, however this is a good starting point, and has feature parity with the existing editor.
1 parent 171a349 commit 845a5ac

24 files changed

+1695
-1008
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ site/
99
build/
1010
# Working directory for distribution assembly
1111
dist/dvr-scan/*
12-
dist/dvr-scan*
13-
dist/dvr_scan*
12+
dist/dvr-scan-*
13+
dist/dvr_scan-*
1414

1515
# Location where docs are built before assembling distributions
1616
dvr_scan/docs/

MANIFEST.in

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
recursive-exclude .github *
2-
recursive-exclude dist *
3-
recursive-exclude tests *
41
exclude *
5-
recursive-include
62
include dist/package-info.rst
73
include dvr_scan/LICENSE
84
recursive-include dvr_scan/docs
9-
include dvr-scan.cfg
5+
include dvr_scan/dvr-scan.cfg
6+
include dvr_scan/dvr-scan.ico
7+
include dvr_scan/dvr-scan.png
8+
include dvr_scan/dvr-scan-logo.png
109
include LICENSE
1110
include pyproject.toml
1211
include README.md

dist/dvr-scan.spec

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
block_cipher = None
44

5-
a = Analysis(['../dvr_scan/__main__.py'],
5+
cli = Analysis(['../dvr_scan/__main__.py'],
66
pathex=['.'],
77
binaries=None,
88
datas=[
9-
('../dvr-scan.cfg', 'dvr-scan'),
10-
('../dist/dvr-scan.ico', 'dvr-scan'),
11-
('../dist/README.txt', 'dvr-scan'),
12-
('../dvr_scan/LICENSE*', 'dvr-scan'),
9+
('../dvr_scan/dvr-scan.ico', 'dvr_scan'),
10+
('../dvr_scan/dvr-scan-logo.png', 'dvr_scan'),
11+
('../dvr_scan/LICENSE*', 'dvr_scan'),
1312
],
1413
hiddenimports=[],
1514
hookspath=[],
@@ -19,22 +18,24 @@ a = Analysis(['../dvr_scan/__main__.py'],
1918
win_private_assemblies=False,
2019
cipher=block_cipher)
2120

22-
pyz = PYZ(a.pure, a.zipped_data,
21+
cli_pyz = PYZ(cli.pure, cli.zipped_data,
2322
cipher=block_cipher)
24-
exe = EXE(pyz,
25-
a.scripts,
23+
24+
cli_exe = EXE(cli_pyz,
25+
cli.scripts,
2626
exclude_binaries=True,
2727
name='dvr-scan',
2828
debug=False,
2929
strip=False,
3030
upx=True,
3131
console=True,
3232
version='.version_info',
33-
icon='dvr-scan.ico')
34-
coll = COLLECT(exe,
35-
a.binaries,
36-
a.zipfiles,
37-
a.datas,
33+
icon='../dvr_scan/dvr-scan.ico')
34+
35+
coll = COLLECT(cli_exe,
36+
cli.binaries,
37+
cli.zipfiles,
38+
cli.datas,
3839
strip=False,
3940
upx=True,
4041
name='dvr-scan')

dist/installer/DVR-Scan.aip

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<ROW Directory="LocalAppDataFolder" Directory_Parent="TARGETDIR" DefaultDir="LOCALA~1|LocalAppDataFolder" IsPseudoRoot="1"/>
6161
<ROW Directory="Mexico_Dir" Directory_Parent="tzdata_Dir" DefaultDir="Mexico"/>
6262
<ROW Directory="North_Dakota_Dir" Directory_Parent="America_Dir" DefaultDir="NORTH_~1|North_Dakota"/>
63+
<ROW Directory="PIL_Dir" Directory_Parent="_internal_Dir" DefaultDir="PIL"/>
6364
<ROW Directory="Pacific_Dir" Directory_Parent="tzdata_Dir" DefaultDir="Pacific"/>
6465
<ROW Directory="SystemV_Dir" Directory_Parent="tzdata_Dir" DefaultDir="SystemV"/>
6566
<ROW Directory="TARGETDIR" DefaultDir="SourceDir"/>
@@ -72,6 +73,7 @@
7273
<ROW Directory="cv2_Dir" Directory_Parent="_internal_Dir" DefaultDir="cv2"/>
7374
<ROW Directory="data_Dir" Directory_Parent="cv2_Dir" DefaultDir="data"/>
7475
<ROW Directory="docs_Dir" Directory_Parent="APPDIR" DefaultDir="docs"/>
76+
<ROW Directory="dvrscan_Dir" Directory_Parent="_internal_Dir" DefaultDir="dvr_scan"/>
7577
<ROW Directory="encoding_Dir" Directory_Parent="_tcl_data_Dir" DefaultDir="encoding"/>
7678
<ROW Directory="fft_Dir" Directory_Parent="numpy_Dir" DefaultDir="fft"/>
7779
<ROW Directory="gapi_Dir" Directory_Parent="cv2_Dir" DefaultDir="gapi"/>
@@ -120,7 +122,6 @@
120122
<ROW Component="Indianapolis" ComponentId="{8608A342-2888-4A1C-9EDD-7C5F3C8053E5}" Directory_="Indiana_Dir" Attributes="0" KeyPath="Indianapolis" Type="0"/>
121123
<ROW Component="LICENSE" ComponentId="{72CE02CB-34F8-4662-9A9D-CE17C62EFCE7}" Directory_="APPDIR" Attributes="0" KeyPath="LICENSE" Type="0"/>
122124
<ROW Component="LICENSEFFMPEG" ComponentId="{7FF009E0-E703-4184-A411-754BF36869CA}" Directory_="APPDIR" Attributes="0" KeyPath="LICENSEFFMPEG"/>
123-
<ROW Component="LICENSETHIRDPARTY" ComponentId="{B83DCCDB-6E77-4561-A446-03035E5DA7C8}" Directory_="APPDIR" Attributes="0" KeyPath="LICENSETHIRDPARTY"/>
124125
<ROW Component="Longyearbyen" ComponentId="{E6D75BF6-A209-4CC1-8812-C3F531C7F159}" Directory_="Arctic_Dir" Attributes="0" KeyPath="Longyearbyen" Type="0"/>
125126
<ROW Component="Louisville" ComponentId="{2CF12F54-8910-4C81-99CA-C4CAA06F792C}" Directory_="Kentucky_Dir" Attributes="0" KeyPath="Louisville" Type="0"/>
126127
<ROW Component="ProductInformation" ComponentId="{C45D033C-5DD4-40D4-AABA-C6639AF83796}" Directory_="APPDIR" Attributes="4" KeyPath="Version"/>
@@ -131,6 +132,7 @@
131132
<ROW Component="__init__.py_2" ComponentId="{CC81E13B-98B6-4123-B58B-508564936E49}" Directory_="mat_wrapper_Dir" Attributes="0" KeyPath="__init__.py_2" Type="0"/>
132133
<ROW Component="__init__.py_3" ComponentId="{19547ADA-5843-4723-8981-D734D6E2C993}" Directory_="typing_Dir" Attributes="0" KeyPath="__init__.py_4" Type="0"/>
133134
<ROW Component="__init__.py_4" ComponentId="{5C768E9C-4B68-4767-B916-01019FE7E779}" Directory_="utils_Dir" Attributes="0" KeyPath="__init__.py_5" Type="0"/>
135+
<ROW Component="_imaging.cp313win_amd64.pyd" ComponentId="{AE5F8B25-77F8-4A00-B377-383C04518134}" Directory_="PIL_Dir" Attributes="256" KeyPath="_imaging.cp313win_amd64.pyd" Type="0"/>
134136
<ROW Component="_multiarray_tests.cp313win_amd64.pyd" ComponentId="{1B5C3446-2796-4F07-9C5A-029986CA6FD2}" Directory_="_core_Dir" Attributes="256" KeyPath="_multiarray_tests.cp313win_amd64.pyd" Type="0"/>
135137
<ROW Component="_pocketfft_umath.cp313win_amd64.pyd" ComponentId="{F38BD11F-54AE-410A-ACF9-057065D807F7}" Directory_="fft_Dir" Attributes="256" KeyPath="_pocketfft_umath.cp313win_amd64.pyd" Type="0"/>
136138
<ROW Component="_umath_linalg.cp313win_amd64.pyd" ComponentId="{9DDB3DD3-4795-4C0B-BD3B-106E2EBADAE0}" Directory_="linalg_Dir" Attributes="256" KeyPath="_umath_linalg.cp313win_amd64.pyd" Type="0"/>
@@ -186,6 +188,7 @@
186188
<ROW Component="cs.msg" ComponentId="{F24A8C57-F6F8-447B-93DA-551D1537AEB6}" Directory_="msgs_1_Dir" Attributes="0" KeyPath="cs.msg_1" Type="0"/>
187189
<ROW Component="dvrscan.cfg" ComponentId="{18A37A49-86C6-42DF-A130-DC5499CD6677}" Directory_="DVRScan_Dir" Attributes="16" KeyPath="dvrscan.cfg_1" Type="0"/>
188190
<ROW Component="dvrscan.exe" ComponentId="{BFAC0A4B-76D6-4EF9-B2B5-DFB8B5AC8885}" Directory_="APPDIR" Attributes="256" KeyPath="dvrscan.exe"/>
191+
<ROW Component="dvrscanlogo.png" ComponentId="{E99B7CDA-3F11-4A2A-8329-41CF25B01541}" Directory_="dvrscan_Dir" Attributes="0" KeyPath="dvrscanlogo.png_1" Type="0"/>
189192
<ROW Component="ffmpeg.exe" ComponentId="{BBCE1F27-65DC-461F-B81C-CF84ED2D7201}" Directory_="APPDIR" Attributes="256" KeyPath="ffmpeg.exe"/>
190193
<ROW Component="html" ComponentId="{4C35D225-4654-4A96-BABB-5A69EF7F4260}" Directory_="docs_Dir" Attributes="0" KeyPath="html" Type="0"/>
191194
<ROW Component="http.tcl" ComponentId="{10B85E89-AAB5-47BE-9CCA-FA767C015062}" Directory_="http1.0_Dir" Attributes="0" KeyPath="http.tcl" Type="0"/>
@@ -217,9 +220,7 @@
217220
<ROW File="dvrscan.exe" Component_="dvrscan.exe" FileName="dvr-scan.exe" Attributes="0" SourcePath="..\dvr-scan\dvr-scan.exe" SelfReg="false"/>
218221
<ROW File="LICENSE" Component_="LICENSE" FileName="LICENSE" Attributes="0" SourcePath="..\dvr-scan\LICENSE" SelfReg="false"/>
219222
<ROW File="LICENSEFFMPEG" Component_="LICENSEFFMPEG" FileName="LICENS~1|LICENSE-FFMPEG" Attributes="0" SourcePath="..\dvr-scan\LICENSE-FFMPEG" SelfReg="false"/>
220-
<ROW File="LICENSETHIRDPARTY" Component_="LICENSETHIRDPARTY" FileName="LICENS~2|LICENSE-THIRDPARTY" Attributes="0" SourcePath="..\dvr-scan\LICENSE-THIRDPARTY" SelfReg="false"/>
221223
<ROW File="dvrscan.cfg" Component_="LICENSE" FileName="dvr-scan.cfg" Attributes="0" SourcePath="..\dvr-scan\dvr-scan.cfg" SelfReg="false"/>
222-
<ROW File="dvrscan.ico" Component_="LICENSE" FileName="dvr-scan.ico" Attributes="0" SourcePath="..\dvr-scan\dvr-scan.ico" SelfReg="false"/>
223224
<ROW File="apimswincoreconsolel110.dll" Component_="apimswincoreconsolel110.dll" FileName="API-MS~1.DLL|api-ms-win-core-console-l1-1-0.dll" Attributes="0" SourcePath="..\dvr-scan\_internal\api-ms-win-core-console-l1-1-0.dll" SelfReg="false"/>
224225
<ROW File="apimswincoredatetimel110.dll" Component_="apimswincoredatetimel110.dll" FileName="API-MS~2.DLL|api-ms-win-core-datetime-l1-1-0.dll" Attributes="0" SourcePath="..\dvr-scan\_internal\api-ms-win-core-datetime-l1-1-0.dll" SelfReg="false"/>
225226
<ROW File="apimswincoredebugl110.dll" Component_="apimswincoredebugl110.dll" FileName="API-MS~3.DLL|api-ms-win-core-debug-l1-1-0.dll" Attributes="0" SourcePath="..\dvr-scan\_internal\api-ms-win-core-debug-l1-1-0.dll" SelfReg="false"/>
@@ -1246,12 +1247,18 @@
12461247
<ROW File="palette.ecc896b0.min.css" Component_="main.eebd395e.min.css" FileName="PALETT~1.CSS|palette.ecc896b0.min.css" Attributes="0" SourcePath="..\dvr-scan\docs\assets\stylesheets\palette.ecc896b0.min.css" SelfReg="false"/>
12471248
<ROW File="changelog.html" Component_="html" FileName="CHANGE~1.HTM|changelog.html" Attributes="0" SourcePath="..\dvr-scan\docs\changelog.html" SelfReg="false"/>
12481249
<ROW File="docs.html" Component_="html" FileName="DOCS~1.HTM|docs.html" Attributes="0" SourcePath="..\dvr-scan\docs\docs.html" SelfReg="false"/>
1249-
<ROW File="download.html" Component_="html" FileName="DOWNLO~1.HTM|download.html" Attributes="0" SourcePath="..\dvr-scan\docs\download.html" SelfReg="false"/>
12501250
<ROW File="faq.html" Component_="html" FileName="FAQ~1.HTM|faq.html" Attributes="0" SourcePath="..\dvr-scan\docs\faq.html" SelfReg="false"/>
12511251
<ROW File="guide.html" Component_="html" FileName="GUIDE~1.HTM|guide.html" Attributes="0" SourcePath="..\dvr-scan\docs\guide.html" SelfReg="false"/>
12521252
<ROW File="index.html" Component_="html" FileName="INDEX~1.HTM|index.html" Attributes="0" SourcePath="..\dvr-scan\docs\index.html" SelfReg="false"/>
12531253
<ROW File="resources.html" Component_="html" FileName="RESOUR~1.HTM|resources.html" Attributes="0" SourcePath="..\dvr-scan\docs\resources.html" SelfReg="false"/>
12541254
<ROW File="style.css" Component_="html" FileName="style.css" Attributes="0" SourcePath="..\dvr-scan\docs\style.css" SelfReg="false"/>
1255+
<ROW File="dvrscanlogo.png_1" Component_="dvrscanlogo.png" FileName="DVR-SC~1.PNG|dvr-scan-logo.png" Attributes="0" SourcePath="..\dvr-scan\_internal\dvr_scan\dvr-scan-logo.png" SelfReg="false"/>
1256+
<ROW File="dvrscan.ico" Component_="dvrscanlogo.png" FileName="dvr-scan.ico" Attributes="0" SourcePath="..\dvr-scan\_internal\dvr_scan\dvr-scan.ico" SelfReg="false"/>
1257+
<ROW File="_imaging.cp313win_amd64.pyd" Component_="_imaging.cp313win_amd64.pyd" FileName="_IMAGI~1.PYD|_imaging.cp313-win_amd64.pyd" Attributes="0" SourcePath="..\dvr-scan\_internal\PIL\_imaging.cp313-win_amd64.pyd" SelfReg="false"/>
1258+
<ROW File="_imagingcms.cp313win_amd64.pyd" Component_="_imaging.cp313win_amd64.pyd" FileName="_IMAGI~2.PYD|_imagingcms.cp313-win_amd64.pyd" Attributes="0" SourcePath="..\dvr-scan\_internal\PIL\_imagingcms.cp313-win_amd64.pyd" SelfReg="false"/>
1259+
<ROW File="_imagingmath.cp313win_amd64.pyd" Component_="_imaging.cp313win_amd64.pyd" FileName="_IMAGI~3.PYD|_imagingmath.cp313-win_amd64.pyd" Attributes="0" SourcePath="..\dvr-scan\_internal\PIL\_imagingmath.cp313-win_amd64.pyd" SelfReg="false"/>
1260+
<ROW File="_imagingtk.cp313win_amd64.pyd" Component_="_imaging.cp313win_amd64.pyd" FileName="_IMAGI~4.PYD|_imagingtk.cp313-win_amd64.pyd" Attributes="0" SourcePath="..\dvr-scan\_internal\PIL\_imagingtk.cp313-win_amd64.pyd" SelfReg="false"/>
1261+
<ROW File="_webp.cp313win_amd64.pyd" Component_="_imaging.cp313win_amd64.pyd" FileName="_WEBPC~1.PYD|_webp.cp313-win_amd64.pyd" Attributes="0" SourcePath="..\dvr-scan\_internal\PIL\_webp.cp313-win_amd64.pyd" SelfReg="false"/>
12551262
</COMPONENT>
12561263
<COMPONENT cid="caphyon.advinst.msicomp.AiPersistentDataComponent">
12571264
<ROW PersistentRow="dvrscan.cfg_1" Type="0" Condition="1"/>
@@ -1485,7 +1492,6 @@
14851492
<ROW Feature_="DVRScan" Component_="af.msg"/>
14861493
<ROW Feature_="DVRScan" Component_="optparse.tcl"/>
14871494
<ROW Feature_="DVRScan" Component_="Abidjan"/>
1488-
<ROW Feature_="DVRScan" Component_="LICENSETHIRDPARTY"/>
14891495
<ROW Feature_="ffmpeg" Component_="LICENSEFFMPEG"/>
14901496
<ROW Feature_="DVRScan" Component_="Adak"/>
14911497
<ROW Feature_="DVRScan" Component_="Buenos_Aires"/>
@@ -1517,6 +1523,8 @@
15171523
<ROW Feature_="DVRScan" Component_="boundingbox.gif"/>
15181524
<ROW Feature_="DVRScan" Component_="bundle.220ee61c.min.js"/>
15191525
<ROW Feature_="DVRScan" Component_="main.eebd395e.min.css"/>
1526+
<ROW Feature_="DVRScan" Component_="dvrscanlogo.png"/>
1527+
<ROW Feature_="DVRScan" Component_="_imaging.cp313win_amd64.pyd"/>
15201528
</COMPONENT>
15211529
<COMPONENT cid="caphyon.advinst.msicomp.MsiIconsComponent">
15221530
<ROW Name="dvr_scan_icon.exe" SourcePath="dvr_scan_icon.ico" Index="0"/>

dist/post_release.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import glob
1515
import os
1616
import shutil
17+
from pathlib import Path
1718

1819

1920
def finalize_exe_distribution():
@@ -29,17 +30,17 @@ def finalize_exe_distribution():
2930
"imageio_ffmpeg",
3031
"importlib_metadata-*.dist-info",
3132
"matplotlib",
32-
"PIL",
3333
"PyQt5",
3434
"pip-*.dist-info",
3535
"psutil",
3636
"pyinstaller-*.dist-info",
3737
"setuptools-*.dist-info",
3838
"tcl8",
39+
"pywin32_system32",
3940
"wheel-*.dist-info",
41+
"win32",
4042
"wx",
4143
]
42-
4344
FILE_GLOBS = [
4445
"_bz2.pyd",
4546
"_decimal.pyd",
@@ -66,13 +67,15 @@ def finalize_exe_distribution():
6667
for file_path in glob.glob(os.path.join(BASE_PATH, file_glob)):
6768
os.remove(file_path)
6869

69-
# Collect self dependencies.
70-
# TODO: See if the following can be added to COLLECT instead of including
71-
# these files as part of the .spec file Analysis step.
72-
for f in glob.glob(os.path.join(BASE_PATH, "dvr-scan/*")):
73-
shutil.move(f, DIST_PATH)
74-
os.rmdir(os.path.join(BASE_PATH, "dvr-scan"))
75-
shutil.copytree("dvr_scan/docs", "dist/dvr-scan/docs", dirs_exist_ok=True)
70+
shutil.copytree("dvr_scan/docs", Path(DIST_PATH).joinpath("docs"), dirs_exist_ok=True)
71+
72+
EXE_ASSETS = [
73+
"dist/README.txt",
74+
"dvr_scan/LICENSE",
75+
"dvr-scan.cfg",
76+
]
77+
for asset in EXE_ASSETS:
78+
shutil.copy(asset, DIST_PATH)
7679

7780

7881
if __name__ == "__main__":

dist/pre_release.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def build_docs(use_local_images=True):
9191
index_path = tmp.joinpath("docs", "index.md")
9292
new_index = tmp.joinpath("docs", "index_docs.md")
9393
new_index.replace(index_path)
94+
tmp.joinpath("docs", "download.md").unlink()
9495

9596
mkdocs_path = tmp.joinpath("mkdocs.yml")
9697
curr_mkdocs_path = tmp.joinpath("docs", "mkdocs.yml")
@@ -143,6 +144,7 @@ def build_docs(use_local_images=True):
143144
docs_build_path.joinpath(path).unlink(missing_ok=False)
144145

145146
for to_remove in (
147+
"requirements.txt",
146148
"sitemap.xml",
147149
"sitemap.xml.gz",
148150
"assets/images",
@@ -170,5 +172,9 @@ def remove_mapping():
170172

171173

172174
if __name__ == "__main__":
175+
if not (len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == "--use-local-images")):
176+
print("Usage: pre_release.py [--use-local-images]")
177+
raise SystemExit(1)
178+
173179
write_version_info_for_windows_exe()
174180
build_docs(use_local_images=bool(len(sys.argv) == 2 and sys.argv[1] == "--use-local-images"))

dist/requirements_windows.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
numpy
55
opencv-python==4.10.0.84
66
opencv-contrib-python==4.10.0.84
7+
pillow
78
platformdirs
89
pyinstaller>=6.0
910
pytest

docs/changelog.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
----------------------------------------------------------
55

6-
## DVR-Scan 1.7
6+
## DVR-Scan 1.6
77

8-
### 1.7 (In Development)
8+
### 1.6.2 (In Development)
99

1010
- [general] Add new `variance-threshold` [config option](https://www.dvr-scan.com/docs/#config-file) to control how MOG2 controls which pixels are described by the current background model [#163](https://github.com/Breakthrough/DVR-Scan/issues/163)
11-
12-
13-
## DVR-Scan 1.6
11+
- [feature] Rework region editor to provide more consistent experience across all platforms
12+
- The region editor is now much more usable and has UI controls in addition to keyboard shortcuts
13+
- System-specific shortcuts like undo/redo now work as expected
14+
- Various performance and usability improvements including zoom/pan and shape selection
1415

1516
### 1.6.1 (May 18, 2024)
1617

dvr_scan/__init__.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
``platform``: library/platform specific helpers
3232
"""
3333

34-
import os
3534
import pkgutil
3635
import sys
3736

@@ -46,32 +45,11 @@
4645

4746
def get_license_info() -> str:
4847
"""Get license/copyright information for the package or standalone executable."""
49-
try:
50-
# If we're running a frozen/standalone executable distribution, make sure we include
51-
# the license information for the third-party components we redistribute.
52-
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
53-
app_folder = os.path.abspath(os.path.dirname(sys.executable))
54-
license_files = ["LICENSE", "LICENSE-THIRDPARTY"]
55-
license_text = "\n".join(
56-
[
57-
open(os.path.join(app_folder, license_file), "rb")
58-
.read()
59-
.decode("ascii", "ignore")
60-
for license_file in license_files
61-
]
62-
)
63-
# Use the LICENSE file included with the package distribution.
64-
else:
65-
license_text = pkgutil.get_data(__name__, "LICENSE").decode("ascii", "ignore")
66-
return license_text
67-
# During development this is normal since the package paths won't be correct.
68-
except FileNotFoundError:
69-
pass
70-
return (
71-
"[DVR-Scan] Error: Missing LICENSE files.\n"
72-
"See the following URL for license/copyright information:\n"
73-
" < https://www.dvr-scan.com/resources >\n"
74-
)
48+
license_text = pkgutil.get_data(__name__, "LICENSE").decode()
49+
# Include additional third-party license text if they were bundled into this release.
50+
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
51+
license_text += pkgutil.get_data(__name__, "LICENSE-THIRDPARTY").decode()
52+
return license_text
7553

7654

7755
# Initialize logger.

dvr_scan/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def main():
3333
sys.exit(EXIT_ERROR)
3434
logger = logging.getLogger("dvr_scan")
3535
redirect = FakeTqdmLoggingRedirect if settings.get("quiet-mode") else logging_redirect_tqdm
36+
# TODO: Use Python __debug__ mode instead of hard-coding as config option.
3637
debug_mode = settings.get("debug")
3738
show_traceback = getattr(logging, settings.get("verbosity").upper()) == logging.DEBUG
3839
with redirect(loggers=[logger]):
@@ -47,6 +48,7 @@ def main():
4748
if debug_mode:
4849
raise
4950
except KeyboardInterrupt:
51+
# TODO: This doesn't always work when the GUI is running.
5052
logger.info("Stopping (interrupt received)...", exc_info=show_traceback)
5153
if debug_mode:
5254
raise

0 commit comments

Comments
 (0)