GameSentenceMiner 2.0.1.post2__py3-none-any.whl → 2.1.0__py3-none-any.whl

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.
@@ -3,6 +3,7 @@ from tkinter import filedialog, messagebox, simpledialog
3
3
 
4
4
  import ttkbootstrap as ttk
5
5
 
6
+ from .package_updater import check_for_updates, get_latest_version, update, get_current_version
6
7
  from . import configuration
7
8
  from . import obs
8
9
  from .configuration import *
@@ -89,6 +90,25 @@ class ConfigApp:
89
90
  if self.window is not None:
90
91
  self.window.withdraw()
91
92
 
93
+ def update_now(self):
94
+ update_available, version = check_for_updates()
95
+ if update_available:
96
+ success = update()
97
+ if success:
98
+ messagebox.showinfo("Update Successful", "Update successful, please restart the application.")
99
+ else:
100
+ messagebox.showinfo("No Update Found", "No update found.")
101
+
102
+ def check_update(self, show_no_update=False):
103
+ update_available, version = check_for_updates()
104
+ if update_available:
105
+ self.latest_version.config(text=version)
106
+ should_update = messagebox.askyesno("Update Found", "Update Found, would you like to update now?")
107
+ if should_update:
108
+ self.update_now()
109
+ elif show_no_update:
110
+ messagebox.showinfo("No Update Found", "No update found.")
111
+
92
112
  def add_save_hook(self, func):
93
113
  on_save.append(func)
94
114
 
@@ -100,7 +120,8 @@ class ConfigApp:
100
120
  general=General(
101
121
  use_websocket=self.websocket_enabled.get(),
102
122
  websocket_uri=self.websocket_uri.get(),
103
- open_config_on_startup=self.open_config_on_startup.get()
123
+ open_config_on_startup=self.open_config_on_startup.get(),
124
+ check_for_update_on_startup=self.check_for_update_on_startup.get()
104
125
  ),
105
126
  paths=Paths(
106
127
  folder_to_watch=self.folder_to_watch.get(),
@@ -228,6 +249,9 @@ class ConfigApp:
228
249
  HoverInfoWidget(root, label, row=self.current_row, column=column)
229
250
  self.increment_row()
230
251
 
252
+ def add_label_without_row_increment(self, root, label, row=0, column=0):
253
+ HoverInfoWidget(root, label, row=self.current_row, column=column)
254
+
231
255
  @new_tab
232
256
  def create_general_tab(self):
233
257
  general_frame = ttk.Frame(self.notebook)
@@ -254,6 +278,32 @@ class ConfigApp:
254
278
  self.add_label_and_increment_row(general_frame, "Whether to open config when the script starts.",
255
279
  row=self.current_row, column=2)
256
280
 
281
+ ttk.Label(general_frame, text="Check for Updates On Startup:").grid(row=self.current_row, column=0, sticky='W')
282
+ self.check_for_update_on_startup = tk.BooleanVar(value=self.settings.general.check_for_update_on_startup)
283
+ ttk.Checkbutton(general_frame, variable=self.check_for_update_on_startup).grid(row=self.current_row, column=1,
284
+ sticky='W')
285
+ self.add_label_and_increment_row(general_frame, "Always check for Updates On Startup.",
286
+ row=self.current_row, column=2)
287
+
288
+ ttk.Label(general_frame, text="Current Version:").grid(row=self.current_row, column=0, sticky='W')
289
+ self.current_version = ttk.Label(general_frame, text=get_current_version())
290
+ self.current_version.grid(row=self.current_row, column=1)
291
+ self.add_label_and_increment_row(general_frame, "The current version of the application.", row=self.current_row,
292
+ column=2)
293
+
294
+ ttk.Label(general_frame, text="Latest Version:").grid(row=self.current_row, column=0, sticky='W')
295
+ self.latest_version = ttk.Label(general_frame, text=get_latest_version())
296
+ self.latest_version.grid(row=self.current_row, column=1)
297
+ self.add_label_and_increment_row(general_frame, "The latest available version of the application.",
298
+ row=self.current_row, column=2)
299
+
300
+ ttk.Button(general_frame, text="Check Update", command=lambda: self.check_update(True)).grid(row=self.current_row, column=0,
301
+ pady=5)
302
+ ttk.Button(general_frame, text="Update Now", command=self.update_now).grid(row=self.current_row, column=1,
303
+ pady=5)
304
+ self.add_label_and_increment_row(general_frame, "Check for updates or update to the latest version.",
305
+ row=self.current_row, column=2)
306
+
257
307
  # ttk.Label(general_frame, text="Per Scene Config:").grid(row=self.current_row, column=0, sticky='W')
258
308
  # self.per_scene_config = tk.BooleanVar(value=self.master_config.per_scene_config)
259
309
  # ttk.Checkbutton(general_frame, variable=self.per_scene_config).grid(row=self.current_row, column=1,
@@ -40,6 +40,7 @@ class General:
40
40
  use_websocket: bool = True
41
41
  websocket_uri: str = 'localhost:6677'
42
42
  open_config_on_startup: bool = False
43
+ check_for_update_on_startup: bool = False
43
44
 
44
45
 
45
46
  @dataclass_json
GameSentenceMiner/gsm.py CHANGED
@@ -358,6 +358,8 @@ def main(reloading=False, do_config_input=True):
358
358
 
359
359
  try:
360
360
  settings_window = config_gui.ConfigApp()
361
+ if get_config().general.check_for_update_on_startup:
362
+ settings_window.window.after(0, settings_window.check_update)
361
363
  settings_window.add_save_hook(update_icon)
362
364
  settings_window.window.mainloop()
363
365
  except KeyboardInterrupt:
@@ -0,0 +1,59 @@
1
+ import os
2
+ import subprocess
3
+ import sys
4
+ import requests
5
+
6
+ from .configuration import logger, get_app_directory
7
+
8
+ PACKAGE_NAME = "GameSentenceMiner"
9
+ VERSION_FILE_PATH = os.path.join(get_app_directory(), 'version.txt')
10
+
11
+ def get_current_version():
12
+ try:
13
+ with open(VERSION_FILE_PATH, 'r') as file:
14
+ version = file.read().strip()
15
+ return version
16
+ except FileNotFoundError:
17
+ latest_version = get_latest_version()
18
+ set_current_version(latest_version)
19
+ return latest_version
20
+
21
+ def set_current_version(version):
22
+ try:
23
+ with open(VERSION_FILE_PATH, 'w') as file:
24
+ file.write(version)
25
+ except Exception as e:
26
+ logger.error(f"Error writing to {VERSION_FILE_PATH}: {e}")
27
+
28
+ def get_latest_version():
29
+ try:
30
+ response = requests.get(f"https://pypi.org/pypi/{PACKAGE_NAME}/json")
31
+ latest_version = response.json()["info"]["version"]
32
+ return latest_version
33
+ except Exception as e:
34
+ logger.error(f"Error fetching latest version: {e}")
35
+ return None
36
+
37
+ def check_for_updates(force=False):
38
+ try:
39
+ installed_version = get_current_version()
40
+ latest_version = get_latest_version()
41
+
42
+ if installed_version != latest_version or force:
43
+ logger.info(f"Update available: {installed_version} -> {latest_version}")
44
+ return True, latest_version
45
+ else:
46
+ logger.info("You are already using the latest version.")
47
+ return False, latest_version
48
+ except Exception as e:
49
+ logger.error(f"Error checking for updates: {e}")
50
+
51
+ def update():
52
+ try:
53
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", PACKAGE_NAME])
54
+ logger.info(f"Updated {PACKAGE_NAME} to the latest version, restarting...")
55
+ set_current_version(get_latest_version())
56
+ return True
57
+ except subprocess.CalledProcessError as e:
58
+ logger.error(f"Error updating {PACKAGE_NAME}: {e}")
59
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: GameSentenceMiner
3
- Version: 2.0.1.post2
3
+ Version: 2.1.0
4
4
  Summary: A tool for mining sentences from games.
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -1,20 +1,21 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  GameSentenceMiner/anki.py,sha256=3UT6K5PxzJMDoiXyOULrkeCoJ0KMq7JvBw6XhcLCirE,9114
3
- GameSentenceMiner/config_gui.py,sha256=s03e8F2pEPj0iG31RxFqWGfm2GLb8JoGQR7QhCMFu3M,45581
4
- GameSentenceMiner/configuration.py,sha256=G3EGjCk2U4Ak9aRVU_nuLarCOy8fHyPfRp2hRVrwu9g,13983
3
+ GameSentenceMiner/config_gui.py,sha256=GFRM4bOW8EP4pS7XwUHasb5fGdUK1kZm50uyLui-EiA,48840
4
+ GameSentenceMiner/configuration.py,sha256=CSg67qIzEdj_w-dS-NEls9syyTeJD3rfPrwSZLomFcU,14029
5
5
  GameSentenceMiner/ffmpeg.py,sha256=hdKimzkpAKsE-17qEAQg4uHy4-TtdFywYx48Skn9cPs,10418
6
6
  GameSentenceMiner/gametext.py,sha256=GpR9P8h3GmmKH46Dw13kJPx66n3jGjFCiV8Fcrqn9E8,3999
7
- GameSentenceMiner/gsm.py,sha256=Lnj59KHV4l5eEgffkswBlRCONgYB_Id3L0pTajUzsvI,14937
7
+ GameSentenceMiner/gsm.py,sha256=GqMNcb8w117clJfFiNLhDbZ8eOFQTyVhejrjHvsBJXo,15072
8
8
  GameSentenceMiner/model.py,sha256=oh8VVT8T1UKekbmP6MGNgQ8jIuQ_7Rg4GPzDCn2kJo8,1999
9
9
  GameSentenceMiner/notification.py,sha256=sWgIIXhaB9WV1K_oQGf5-IR6q3dakae_QS-RuIvbcEs,1939
10
10
  GameSentenceMiner/obs.py,sha256=gutnRk30jIxuvrpEosR9jw2h_tll36wgtAZkUF-vWDY,5256
11
+ GameSentenceMiner/package_updater.py,sha256=5b5-QWbycv5Zp3184LyyjAlz7OYZqZb8hyis7NcoZOg,1983
11
12
  GameSentenceMiner/util.py,sha256=OYg0j_rT9F7v3aJRwWnHvdWMYyxGlimrvw7U2C9ifeY,4441
12
13
  GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
14
  GameSentenceMiner/vad/silero_trim.py,sha256=r7bZYEj-NUXGKgD2UIhLrbTPyq0rau97qGtrMZcRK4A,1517
14
15
  GameSentenceMiner/vad/vosk_helper.py,sha256=lWmlGMhmg_0QoWeCHrXwz9wDKPqY37BckHCekGVtJUI,5794
15
16
  GameSentenceMiner/vad/whisper_helper.py,sha256=9kmPeSs6jRcKSVxYY-vtyTcqVUDORR4q1nl8fqxHHn4,3379
16
- GameSentenceMiner-2.0.1.post2.dist-info/METADATA,sha256=Hs8Xypb_1o0HKl74PXczECS9uAUE0N3w6xsa5H2a2Ts,13541
17
- GameSentenceMiner-2.0.1.post2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
- GameSentenceMiner-2.0.1.post2.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
19
- GameSentenceMiner-2.0.1.post2.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
20
- GameSentenceMiner-2.0.1.post2.dist-info/RECORD,,
17
+ GameSentenceMiner-2.1.0.dist-info/METADATA,sha256=8bxVBmPyGQkS5FblJbOEyq23BvVhzLjR2GyLYZxwq8o,13535
18
+ GameSentenceMiner-2.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
19
+ GameSentenceMiner-2.1.0.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
20
+ GameSentenceMiner-2.1.0.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
21
+ GameSentenceMiner-2.1.0.dist-info/RECORD,,