Skip to content

Commit a6f97e9

Browse files
author
Michael Whapples
committed
Add possibility for some in app settings.
1 parent c921b19 commit a6f97e9

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/convert2ebrl/__main__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def check_release(exe_file_name: str) -> bool:
3232
logging.debug(f"Executable hash: {exe_hash}")
3333
hash_path = Path(os.path.join(app_dir, "release.hash"))
3434
return hash_path.exists() and Path(hash_path).read_text(encoding="UTF-8").strip() == exe_hash
35-
else:
36-
return False
35+
return False
3736

3837
def run_app(args: Sequence[str]):
3938
app = QApplication(args)
@@ -42,6 +41,8 @@ def run_app(args: Sequence[str]):
4241
app.setApplicationName("Convert2EBRL")
4342
app.setApplicationVersion(version(__package__))
4443
app.setQuitOnLastWindowClosed(False)
44+
app_settings = QSettings(os.path.join(os.path.dirname(sys.argv[0]), "settings.ini"), QSettings.Format.IniFormat)
45+
log_level = app_settings.value("log_level", defaultValue=logging.INFO, type=int)
4546
log_path = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppLocalDataLocation)
4647
os.makedirs(log_path, exist_ok=True)
4748
rfh = logging.handlers.RotatingFileHandler(
@@ -53,8 +54,9 @@ def run_app(args: Sequence[str]):
5354
delay=False
5455
)
5556
logging.basicConfig(
56-
level=logging.INFO, format="%(levelname)s:%(asctime)s:%(module)s:%(message)s", handlers=[rfh]
57+
level=log_level, format="%(levelname)s:%(asctime)s:%(module)s:%(message)s", handlers=[rfh]
5758
)
59+
logging.info("Using settings from %s", app_settings.fileName())
5860
release_build = check_release(sys.argv[0])
5961
logging.info(f"Release build: {release_build}")
6062
QSettings.setDefaultFormat(QSettings.Format.IniFormat)
@@ -63,7 +65,7 @@ def run_app(args: Sequence[str]):
6365
save_settings_profiles(DEFAULT_SETTINGS_PROFILES_LIST)
6466

6567
raw_meta, unparsed = parse_email(str(metadata(__package__)))
66-
download_site = raw_meta["project_urls"]["download-site"]
68+
download_site = str(app_settings.value("download_site", defaultValue=raw_meta["project_urls"]["download-site"]))
6769
w = MainWindow(download_site)
6870
w.show()
6971

src/convert2ebrl/update_checker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Convert2EBRL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
55
# Convert2EBRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
66
# You should have received a copy of the GNU General Public License along with Convert2EBRL. If not, see <https://www.gnu.org/licenses/>.
7+
import logging
78
import re
89

910
from PySide6.QtCore import QObject, QUrl, Slot, Signal, QCoreApplication
@@ -23,6 +24,7 @@ def __init__(self, parent: QObject|None = None):
2324
self.reply = None
2425
def check_for_update(self, update_url: QUrl):
2526
self.checkingForUpdates.emit()
27+
logging.info("Checking for update at %s", update_url.toDisplayString())
2628
self.reply = self.network_manager.get(QNetworkRequest(update_url))
2729
self.reply.readyRead.connect(self.on_ready_read)
2830
self.reply.finished.connect(self.on_finished)

0 commit comments

Comments
 (0)