TonieToolbox 0.1.3__tar.gz → 0.1.5__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.
- {tonietoolbox-0.1.3/TonieToolbox.egg-info → tonietoolbox-0.1.5}/PKG-INFO +1 -1
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/__init__.py +1 -1
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/__main__.py +6 -0
- tonietoolbox-0.1.5/TonieToolbox/version_handler.py +125 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5/TonieToolbox.egg-info}/PKG-INFO +1 -1
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox.egg-info/SOURCES.txt +1 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/LICENSE.md +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/MANIFEST.in +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/README.md +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/audio_conversion.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/constants.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/dependency_manager.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/filename_generator.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/logger.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/ogg_page.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/opus_packet.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/tonie_analysis.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/tonie_file.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/tonie_header.proto +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox/tonie_header_pb2.py +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox.egg-info/dependency_links.txt +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox.egg-info/entry_points.txt +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox.egg-info/requires.txt +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/TonieToolbox.egg-info/top_level.txt +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/pyproject.toml +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/setup.cfg +0 -0
- {tonietoolbox-0.1.3 → tonietoolbox-0.1.5}/setup.py +0 -0
@@ -15,6 +15,7 @@ from .tonie_analysis import check_tonie_file, split_to_opus_files
|
|
15
15
|
from .dependency_manager import get_ffmpeg_binary, get_opus_binary
|
16
16
|
from .logger import setup_logging, get_logger
|
17
17
|
from .filename_generator import guess_output_filename
|
18
|
+
from .version_handler import check_for_updates
|
18
19
|
|
19
20
|
def main():
|
20
21
|
"""Entry point for the TonieToolbox application."""
|
@@ -44,6 +45,8 @@ def main():
|
|
44
45
|
help='Compare input file with another .taf file for debugging')
|
45
46
|
parser.add_argument('--detailed-compare', action='store_true',
|
46
47
|
help='Show detailed OGG page differences when comparing files')
|
48
|
+
parser.add_argument('--skip-update-check', action='store_true',
|
49
|
+
help='Skip checking for updates')
|
47
50
|
|
48
51
|
log_group = parser.add_argument_group('Logging Options')
|
49
52
|
log_level_group = log_group.add_mutually_exclusive_group()
|
@@ -68,6 +71,9 @@ def main():
|
|
68
71
|
setup_logging(log_level)
|
69
72
|
logger = get_logger('main')
|
70
73
|
logger.debug("Starting TonieToolbox with log level: %s", logging.getLevelName(log_level))
|
74
|
+
|
75
|
+
if not args.skip_update_check:
|
76
|
+
check_for_updates(quiet=args.silent or args.quiet)
|
71
77
|
|
72
78
|
ffmpeg_binary = args.ffmpeg
|
73
79
|
if ffmpeg_binary is None:
|
@@ -0,0 +1,125 @@
|
|
1
|
+
"""
|
2
|
+
Version handler to check if the latest version of TonieToolbox is being used.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import json
|
6
|
+
import logging
|
7
|
+
import os
|
8
|
+
import time
|
9
|
+
from urllib import request
|
10
|
+
from urllib.error import URLError
|
11
|
+
|
12
|
+
from . import __version__
|
13
|
+
from .logger import get_logger
|
14
|
+
|
15
|
+
CACHE_DIR = os.path.join(os.path.expanduser("~"), ".tonietoolbox")
|
16
|
+
CACHE_FILE = os.path.join(CACHE_DIR, "version_cache.json")
|
17
|
+
CACHE_EXPIRY = 86400 # 24 hours in seconds
|
18
|
+
|
19
|
+
|
20
|
+
def get_pypi_version():
|
21
|
+
"""
|
22
|
+
Get the latest version of TonieToolbox from PyPI.
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
tuple: (latest_version, None) on success, (current_version, error_message) on failure
|
26
|
+
"""
|
27
|
+
logger = get_logger("version_handler")
|
28
|
+
|
29
|
+
try:
|
30
|
+
if os.path.exists(CACHE_FILE):
|
31
|
+
try:
|
32
|
+
with open(CACHE_FILE, "r") as f:
|
33
|
+
cache_data = json.load(f)
|
34
|
+
|
35
|
+
if time.time() - cache_data.get("timestamp", 0) < CACHE_EXPIRY:
|
36
|
+
logger.debug("Using cached version info: %s", cache_data["version"])
|
37
|
+
return cache_data["version"], None
|
38
|
+
except (json.JSONDecodeError, KeyError) as e:
|
39
|
+
logger.debug("Cache file corrupt, will fetch from PyPI: %s", e)
|
40
|
+
|
41
|
+
logger.debug("Fetching latest version from PyPI")
|
42
|
+
with request.urlopen("https://pypi.org/pypi/TonieToolbox/json", timeout=2) as response:
|
43
|
+
pypi_data = json.loads(response.read().decode("utf-8"))
|
44
|
+
latest_version = pypi_data["info"]["version"]
|
45
|
+
|
46
|
+
if not os.path.exists(CACHE_DIR):
|
47
|
+
os.makedirs(CACHE_DIR, exist_ok=True)
|
48
|
+
|
49
|
+
with open(CACHE_FILE, "w") as f:
|
50
|
+
json.dump({
|
51
|
+
"version": latest_version,
|
52
|
+
"timestamp": time.time()
|
53
|
+
}, f)
|
54
|
+
|
55
|
+
logger.debug("Latest version from PyPI: %s", latest_version)
|
56
|
+
return latest_version, None
|
57
|
+
|
58
|
+
except (URLError, json.JSONDecodeError) as e:
|
59
|
+
logger.debug("Failed to fetch version from PyPI: %s", e)
|
60
|
+
return __version__, f"Failed to check for updates: {str(e)}"
|
61
|
+
except Exception as e:
|
62
|
+
logger.debug("Unexpected error checking for updates: %s", e)
|
63
|
+
return __version__, f"Unexpected error checking for updates: {str(e)}"
|
64
|
+
|
65
|
+
|
66
|
+
def compare_versions(v1, v2):
|
67
|
+
"""
|
68
|
+
Compare two version strings.
|
69
|
+
|
70
|
+
Args:
|
71
|
+
v1: First version string
|
72
|
+
v2: Second version string
|
73
|
+
|
74
|
+
Returns:
|
75
|
+
int: -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2
|
76
|
+
"""
|
77
|
+
v1_parts = [int(x) for x in v1.split('.')]
|
78
|
+
v2_parts = [int(x) for x in v2.split('.')]
|
79
|
+
|
80
|
+
for i in range(max(len(v1_parts), len(v2_parts))):
|
81
|
+
v1_part = v1_parts[i] if i < len(v1_parts) else 0
|
82
|
+
v2_part = v2_parts[i] if i < len(v2_parts) else 0
|
83
|
+
|
84
|
+
if v1_part < v2_part:
|
85
|
+
return -1
|
86
|
+
elif v1_part > v2_part:
|
87
|
+
return 1
|
88
|
+
|
89
|
+
return 0
|
90
|
+
|
91
|
+
|
92
|
+
def check_for_updates(quiet=False):
|
93
|
+
"""
|
94
|
+
Check if the current version of TonieToolbox is the latest.
|
95
|
+
|
96
|
+
Args:
|
97
|
+
quiet: If True, will not log any information messages
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
tuple: (is_latest, latest_version, message)
|
101
|
+
is_latest: boolean indicating if the current version is the latest
|
102
|
+
latest_version: string with the latest version
|
103
|
+
message: string message about the update status or error
|
104
|
+
"""
|
105
|
+
logger = get_logger("version_handler")
|
106
|
+
current_version = __version__
|
107
|
+
|
108
|
+
latest_version, error = get_pypi_version()
|
109
|
+
|
110
|
+
if error:
|
111
|
+
return True, current_version, error
|
112
|
+
|
113
|
+
is_latest = compare_versions(current_version, latest_version) >= 0
|
114
|
+
|
115
|
+
if is_latest:
|
116
|
+
message = f"You are using the latest version of TonieToolbox ({current_version})"
|
117
|
+
if not quiet:
|
118
|
+
logger.debug(message)
|
119
|
+
else:
|
120
|
+
message = f"Update available! Current version: {current_version}, Latest version: {latest_version}"
|
121
|
+
if not quiet:
|
122
|
+
logger.info(message)
|
123
|
+
logger.info("Consider upgrading with: pip install --upgrade TonieToolbox")
|
124
|
+
|
125
|
+
return is_latest, latest_version, message
|
@@ -16,6 +16,7 @@ TonieToolbox/tonie_analysis.py
|
|
16
16
|
TonieToolbox/tonie_file.py
|
17
17
|
TonieToolbox/tonie_header.proto
|
18
18
|
TonieToolbox/tonie_header_pb2.py
|
19
|
+
TonieToolbox/version_handler.py
|
19
20
|
TonieToolbox.egg-info/PKG-INFO
|
20
21
|
TonieToolbox.egg-info/SOURCES.txt
|
21
22
|
TonieToolbox.egg-info/dependency_links.txt
|
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
|