Skip to content

Commit

Permalink
fix checking version
Browse files Browse the repository at this point in the history
- [Change] checking version now uses the version function from packaging
- [Change] use logger.error for StreamStderrToLogger
  • Loading branch information
Dadangdut33 committed Jan 7, 2024
1 parent efa3435 commit eab18b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions speech_translate/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class StreamStderrToLogger(object):
"""
For stderr and tqdm progress bar
"""
def __init__(self, level):
self.level = level
def __init__(self):
# tqdm use stderr to print, so we can consider it as info
self.considered_info = [
"Downloading", "Fetching", "run_threaded", "Estimating duration from bitrate", "Translating", "Refine", "Align",
Expand All @@ -60,7 +59,7 @@ def write(self, buf):
if len(recent_stderr) > 10:
recent_stderr.pop(0)
else:
logger.log(self.level, line)
logger.error(line)

def flush(self):
pass
Expand All @@ -73,7 +72,7 @@ def init_logging(level):
dir_log + "/" + current_log, level=level, encoding="utf-8", backtrace=False, diagnose=True, format=LOG_FORMAT
)

sys.stderr = StreamStderrToLogger("ERROR")
sys.stderr = StreamStderrToLogger()
# tqdm use stderr so we also need to redirect it


Expand Down
3 changes: 2 additions & 1 deletion speech_translate/ui/window/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tkinter import Canvas, Tk, Toplevel, ttk

from loguru import logger
from packaging import version
from PIL import Image, ImageTk
from requests import get

Expand Down Expand Up @@ -155,7 +156,7 @@ def req_update_check(self, notify_up_to_date=False):
if req is not None and req.status_code == 200:
data = req.json()
latest_version = str(data["tag_name"])
if __version__ < latest_version:
if version.parse(__version__) < version.parse(latest_version):
logger.info(f"New version found: {latest_version}")
self.update_text = "New version available"
self.update_fg = "blue"
Expand Down

0 comments on commit eab18b0

Please sign in to comment.