Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main module improvements, build improvements and other bits #1302

Merged
merged 64 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5cd82cc
t_main: Put all imports to the top of the file, remove ctypes and SDL…
C0rn3j Nov 15, 2024
1600a59
t_main: Convert first 5Kloc from spaces to tabs
C0rn3j Nov 18, 2024
1bc556d
t_main: Add missing imports
C0rn3j Nov 18, 2024
9655012
Bump Gtk import to 4.0 to fix an import error/crash
C0rn3j Nov 18, 2024
601c77f
t_main: Partially migrate to logging and improve exceptions
C0rn3j Nov 18, 2024
956e676
t_main: Fix pylast import
C0rn3j Nov 18, 2024
f89ac4c
t_main: Add missing import
C0rn3j Nov 18, 2024
9bd629a
t_main: Logging improvements
C0rn3j Nov 18, 2024
63dd33a
t_main: Split migration code into t_db_migrate
C0rn3j Nov 18, 2024
ba238d3
t_main: Fix always trying to cast with undefined enc parameter
C0rn3j Nov 18, 2024
9f055d8
t_draw+t_extra: Stop duping alpha_blend function
C0rn3j Nov 18, 2024
7e6c2fd
t_main: Remove t_launch star import
C0rn3j Nov 18, 2024
7f9b676
requirements_optional.txt: Add rest of optdepends
C0rn3j Nov 18, 2024
f763381
t_stream: Add docstring and fully use logging module
C0rn3j Nov 18, 2024
f28547e
t_main: Stop star importing from t_stream
C0rn3j Nov 18, 2024
9028d01
tauon.py: Move to src/tauon/
C0rn3j Nov 18, 2024
1ccf568
tauon.py: Use logging for everything but initial version and copyrigh…
C0rn3j Nov 18, 2024
9488e79
Bump up copyright string
C0rn3j Nov 18, 2024
fc83b37
tauon.py: Migrate to pathlib
C0rn3j Nov 18, 2024
8e374e7
tauon.py: Properly crash when assets don't exist
C0rn3j Nov 18, 2024
8c4e5f0
Packaging: Properly package most assets and modules as such
C0rn3j Nov 18, 2024
20a128a
t_main: Add missing SDL_Rect import
C0rn3j Nov 18, 2024
085cf71
t_main/reqs: Make natsort, opencc and setproctitle truly optional
C0rn3j Nov 18, 2024
72f7b1c
t_main: Add hopefully all missing SDL imports
C0rn3j Nov 18, 2024
d19b34b
t_main: Remove all star imports
C0rn3j Nov 18, 2024
a449af8
run.sh: Remove tauon_music_box.egg-info on start
C0rn3j Nov 18, 2024
3eff510
t_main: Delete macOS "tap.stop()" which seemed completely useless as …
C0rn3j Nov 18, 2024
7ee323b
t_main: Fix transfer-playtime-to not copying flags
C0rn3j Nov 18, 2024
75a1d02
t_main: Fix Windows version check accidentally running on other platf…
C0rn3j Nov 18, 2024
7a721a8
t_extra: Stop spamming a 2021 line in the logs
C0rn3j Nov 18, 2024
6417a04
t_extra: Use logging
C0rn3j Nov 18, 2024
ea5c94c
t_main: Add missing bs4 import
C0rn3j Nov 19, 2024
2cda889
t_main: Add colored_traceback to optdepends
C0rn3j Nov 19, 2024
9013a2a
t_main: Define current_date and current_title
C0rn3j Nov 19, 2024
ff1b968
t_main: Also add current_artist to reload_albums()
C0rn3j Nov 19, 2024
67cce7b
t_main: Add nicer warnings to module import errors
C0rn3j Nov 19, 2024
150b709
t_draw: Add the same import improvements from t_main
C0rn3j Nov 19, 2024
ca5ed98
t_main: Improve logging for pychromecast import
C0rn3j Nov 19, 2024
c5e12f5
t_main: Logging improvements
C0rn3j Nov 19, 2024
2f024aa
t_main+migrate: Don't return None, raise a ValueError instead
C0rn3j Nov 19, 2024
0caed0b
Migrate theme directory under src/tauon
C0rn3j Nov 19, 2024
56c18e9
t_main: Only run migrations when version isn't 0 too
C0rn3j Nov 19, 2024
9427a66
t_main: Remove duplicated mutagen import
C0rn3j Nov 20, 2024
8b8d5b3
t_main: Log all exceptions
C0rn3j Nov 20, 2024
167e67d
Move templates to src/tauon
C0rn3j Nov 20, 2024
d4d61b7
tauon.py: Upgrade logs, now with colors, on UNIX systems anyway
C0rn3j Nov 20, 2024
6570a0f
Convert all remaining bare print statements into logging
C0rn3j Nov 20, 2024
aab878d
t_main: Move input.txt template to templates directory
C0rn3j Nov 20, 2024
5787ad9
t_main: Spaces to tabs til 7k & remove one else indent
C0rn3j Nov 20, 2024
0f967f7
t_main: Add a docstring to PlayerCtl and do not attempt to close none…
C0rn3j Nov 20, 2024
874da2c
t_spot: Improve tekore module load
C0rn3j Nov 20, 2024
ddace2c
t_main + t_extra: Unify quotes
C0rn3j Nov 20, 2024
967a8fb
t_main: Convert part of SDL code from spaces to tabs, log rest of use…
C0rn3j Nov 20, 2024
400cb9e
t_main: Fix setting xcursor when the env vars are empty
C0rn3j Nov 20, 2024
96e79a4
t_main: Fix var typo
C0rn3j Nov 20, 2024
6f169b7
t_main: Only set Xcursor if both XCURSOR_THEME and XCURSOR_SIZE are set
C0rn3j Nov 20, 2024
b723cdc
t_main: Catch errors for and simplify loading Star, Album Star and St…
C0rn3j Nov 20, 2024
cabb31a
t_main: Fix mishandling SDL_WINDOWEVENT_DISPLAY_CHANGED causing the G…
C0rn3j Nov 20, 2024
9ef2879
win-build.sh: Attempt to fix it up for current state of things
C0rn3j Nov 20, 2024
6a61a3b
Move Windows requirements to /requirements_windows.txt
C0rn3j Nov 20, 2024
6c68d5e
requirements_windows.txt: Sort and add PyGObject otherwise we lack gi
C0rn3j Nov 20, 2024
02a2c82
phazor.c: Fix opusfile include
C0rn3j Nov 21, 2024
29245a3
hook-pylast.py: Spacing and quotes
C0rn3j Nov 21, 2024
98dad4a
Merge remote-tracking branch 'upstream/master' into devel
C0rn3j Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
t_extra: Use logging
  • Loading branch information
C0rn3j committed Nov 18, 2024
commit 6417a049d92e2f0e7833a83e6c61bfdc53372914
49 changes: 25 additions & 24 deletions src/tauon/t_modules/t_extra.py
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import colorsys
import glob
import locale
import logging
import math
import os
import random
@@ -422,16 +423,16 @@ def is_music_related(string: str) -> bool:
def archive_file_scan(path: str, extensions: str, launch_prefix: str="") -> float:
"""Get ratio of given file extensions in archive"""
ext = os.path.splitext(path)[1][1:].lower()
# print(path)
# print(ext)
#logging.info(path)
#logging.info(ext)
try:
if ext == "rar":
matches = 0
count = 0
line = launch_prefix + "unrar lb -p- " + shlex.quote(path) + " " + shlex.quote(os.path.dirname(path)) + os.sep
result = subprocess.run(shlex.split(line), stdout=subprocess.PIPE)
file_list = result.stdout.decode("utf-8", "ignore").split("\n")
# print(file_list)
#logging.info(file_list)
for fi in file_list:
for ty in extensions:
if fi[len(ty) * -1:].lower() == ty:
@@ -444,16 +445,16 @@ def archive_file_scan(path: str, extensions: str, launch_prefix: str="") -> floa
matches += 5
count += 1
if count > 200:
#print("RAR archive has many files")
#print(" --- " + path)
#logging.info("RAR archive has many files")
#logging.info(" --- " + path)
return 0
if matches == 0:
#print("RAR archive does not appear to contain audio files")
#print(" --- " + path)
#logging.info("RAR archive does not appear to contain audio files")
#logging.info(" --- " + path)
return 0
if count == 0:
#print("Archive has no files")
#print(" --- " + path)
#logging.info("Archive has no files")
#logging.info(" --- " + path)
return 0

elif ext == "7z":
@@ -462,7 +463,7 @@ def archive_file_scan(path: str, extensions: str, launch_prefix: str="") -> floa
line = launch_prefix + "7z l " + shlex.quote(path) # + " " + shlex.quote(os.path.dirname(path)) + os.sep
result = subprocess.run(shlex.split(line), stdout=subprocess.PIPE)
file_list = result.stdout.decode("utf-8", "ignore").split("\n")
# print(file_list)
#logging.info(file_list)

for fi in file_list:

@@ -480,24 +481,24 @@ def archive_file_scan(path: str, extensions: str, launch_prefix: str="") -> floa
count += 1

if count > 200:
#print("7z archive has many files")
#print(" --- " + path)
#logging.info("7z archive has many files")
#logging.info(" --- " + path)
return 0
if matches == 0:
#print("7z archive does not appear to contain audio files")
#print(" --- " + path)
#logging.info("7z archive does not appear to contain audio files")
#logging.info(" --- " + path)
return 0
if count == 0:
#print("7z archive has no files")
#print(" --- " + path)
#logging.info("7z archive has no files")
#logging.info(" --- " + path)
return 0

elif ext == "zip":

zip_ref = zipfile.ZipFile(path, "r")
matches = 0
count = 0
#print(zip_ref.namelist())
#logging.info(zip_ref.namelist())
for fi in zip_ref.namelist():
for ty in extensions:
if fi[len(ty) * -1:].lower() == ty:
@@ -510,22 +511,22 @@ def archive_file_scan(path: str, extensions: str, launch_prefix: str="") -> floa
matches += 5
count += 1
if count == 0:
#print("Archive has no files")
#print(" --- " + path)
#logging.info("Archive has no files")
#logging.info(" --- " + path)
return 0
if count > 300:
#print("Zip archive has many files")
#print(" --- " + path)
#logging.info("Zip archive has many files")
#logging.info(" --- " + path)
return 0
if matches == 0:
#print("Zip archive does not appear to contain audio files")
#print(" --- " + path)
#logging.info("Zip archive does not appear to contain audio files")
#logging.info(" --- " + path)
return 0
else:
return 0

except Exception:
print("Archive test error")
logging.exception("Archive test error")

return 0