Skip to content

Commit 74d778b

Browse files
committed
chore: match project structure to best pratices implement in other repositories
1 parent c66c501 commit 74d778b

File tree

11 files changed

+62
-43
lines changed

11 files changed

+62
-43
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8+
commit-message:
9+
prefix: "chore"
10+
include: "scope"
811
- package-ecosystem: "github-actions"
912
directory: "/"
1013
schedule:
1114
interval: "daily"
15+
commit-message:
16+
prefix: "chore"
17+
include: "scope"

.github/workflows/convention.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212

1313
jobs:
1414
title:
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616
permissions:
1717
pull-requests: read
1818
steps:

.github/workflows/deploy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defaults:
1414

1515
jobs:
1616
prepare:
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-24.04
1818
outputs:
1919
nuitka: ${{ steps.extract.outputs.nuitka }}
2020
version: ${{ steps.extract.outputs.version }}
@@ -45,7 +45,7 @@ jobs:
4545
4646
macos:
4747
needs: [prepare]
48-
runs-on: macos-latest
48+
runs-on: macos-15
4949

5050
steps:
5151
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2
@@ -91,7 +91,7 @@ jobs:
9191

9292
linux:
9393
needs: [prepare]
94-
runs-on: ubuntu-latest
94+
runs-on: ubuntu-24.04
9595

9696
steps:
9797
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2
@@ -136,7 +136,7 @@ jobs:
136136

137137
windows:
138138
needs: [prepare]
139-
runs-on: windows-latest
139+
runs-on: windows-2025
140140

141141
steps:
142142
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111

1212
jobs:
1313
check:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515
steps:
1616
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2
1717
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ permissions:
1818

1919
jobs:
2020
metadata:
21-
runs-on: ubuntu-latest
21+
runs-on: ubuntu-24.04
2222
outputs:
2323
desktop: ${{ steps.metadata.outputs.release_created }}
2424
steps:

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
e2e:
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest, macos-latest]
16+
os: [ubuntu-24.04, windows-2025, macos-15]
1717
fail-fast: false
1818
env:
1919
DISPLAY: ":99.0"
@@ -25,7 +25,7 @@ jobs:
2525
python-version-file: "pyproject.toml"
2626
cache: "pip"
2727
- uses: tlambert03/setup-qt-libs@19e4ef2d781d81f5f067182e228b54ec90d23b76 # v1.8.0
28-
- if: ${{ matrix.os == 'ubuntu-latest' }}
28+
- if: ${{ matrix.os == 'ubuntu-24.04' }}
2929
run: sudo apt-get install pulseaudio -y
3030
- name: Install dependencies
3131
run: pip install .[test]

src/pages/guide.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def __init__(self):
2323
2424
<p>
2525
Running the app will display the first input in the logs box and the second after 3 seconds, if it was entered.
26-
An example error will also be shown halfway through the process. If the app is minimized when the process ends a
27-
notification will be sent and the app will blink/jump in the taskbar depending on the operating system.
26+
An example error will also be shown halfway through the process. If the app is minimized when the process ends it
27+
will blink/jump in the taskbar depending on the operating system.
2828
</p>
2929
3030
<p>
@@ -45,8 +45,8 @@ def __init__(self):
4545
<h3>Certification</h3>
4646
4747
<ul>
48-
<li>Sign the app during the build process using a trusted certificate authority.</li>
49-
<li>These are usually paid services but having the app signed will remove the insecuriy warning from some operating systems.</li>
48+
<li>Sign the app after the build process using a trusted certificate authority.</li>
49+
<li>These are usually paid services but having the app signed will remove the insecurity warning from some operating systems.</li>
5050
</ul>
5151
5252
<h3>Localization</h3>

src/pages/home.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from services.example import ExampleThread
1818
from utils.data_saver import config
1919
from utils import file_loader
20+
from utils.logger import LogLevel
2021

2122

2223
class HomePage(QWidget):
@@ -148,23 +149,22 @@ def runExample(self):
148149
self.secondInputField.text(),
149150
)
150151

151-
def output(text, level):
152-
if level == "ERROR":
152+
def output(text: str, level: LogLevel):
153+
if level == LogLevel.ERROR.value:
153154
self.runLogsBox.append(f'<font color="red">{text}</font>')
154-
else:
155+
elif level == LogLevel.WARNING.value:
156+
self.runLogsBox.append(f'<font color="olive">{text}</font>')
157+
elif level == LogLevel.SUCCESS.value:
155158
self.runLogsBox.append(f'<font color="green">{text}</font>')
159+
else:
160+
self.runLogsBox.append(f'<font color="gray">{text}</font>')
156161
self.runLogsClearButton.setDisabled(False)
157162

158163
self.worker.outputSignal.connect(output)
159164

160165
def finished():
161166
self.runButton.setDisabled(False)
162167
App.alert(self, 0)
163-
# if (
164-
# App.applicationState()
165-
# == Qt.ApplicationState.ApplicationInactive
166-
# ):
167-
# SystemTray().send("Example finished!", "Go back to the app.")
168168
self.finishSound.play()
169169

170170
self.worker.finished.connect(finished)

src/services/example.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from PySide6.QtCore import QThread, Signal
22

3-
from utils.logger import logger
3+
from utils.logger import LogLevel, logger
44

55

66
class ExampleThread(QThread):
@@ -13,15 +13,17 @@ def __init__(self, firstInput: str, secondInput: str | None = None):
1313
self.firstInput = firstInput
1414
self.secondInput = secondInput
1515

16-
def output(self, text: str, level="INFO"):
17-
logger.log(level, text)
18-
self.outputSignal.emit(text, level)
16+
def output(self, text: str, level: LogLevel = LogLevel.INFO):
17+
logger.log(level.value, text)
18+
self.outputSignal.emit(text, level.value)
1919

2020
def run(self):
21-
inputs = self.__dict__.copy()
22-
logger.info(f"Starting example thread with input parameters: {inputs}")
23-
self.output("...")
24-
with logger.catch():
21+
try:
22+
inputs = self.__dict__.copy()
23+
logger.info(
24+
f"Starting example thread with input parameters: {inputs}"
25+
)
26+
self.output("...")
2527
self.output("Your first input was: " + self.firstInput)
2628
self.output(
2729
"If you entered text in the second input it will be shown here after 3 seconds"
@@ -30,7 +32,12 @@ def run(self):
3032
try:
3133
raise Exception("This is an example error after 1.5 seconds")
3234
except Exception as e:
33-
self.output(str(e), "ERROR")
35+
self.output(str(e), LogLevel.ERROR)
3436
self.msleep(1500)
3537
if self.secondInput:
3638
self.output("Your second input was: " + self.secondInput)
39+
except Exception as error:
40+
self.output(
41+
f"An unexpected error occurred: {f'{error}'.split(';')[0][9:]}",
42+
LogLevel.ERROR,
43+
)

src/utils/logger.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
from enum import Enum
23
import os
34
import sys
45

@@ -9,18 +10,33 @@
910

1011
LOGS_PATH = os.path.join(DATA_PATH, "logs")
1112

13+
14+
class LogLevel(Enum):
15+
TRACE = "TRACE"
16+
DEBUG = "DEBUG"
17+
INFO = "INFO"
18+
SUCCESS = "SUCCESS"
19+
WARNING = "WARNING"
20+
ERROR = "ERROR"
21+
CRITICAL = "CRITICAL"
22+
23+
1224
formatter = (
1325
"[{time:YYYY-MM-DDTHH:mm:ss.SSS[Z]!UTC}] [<level>{level}</level>] {message}"
1426
)
1527

1628
dev = "__compiled__" not in globals()
1729

1830
logger.remove()
19-
logger.level("INFO", color="<green>")
31+
logger.level(LogLevel.INFO.value, color="<green>")
2032

2133
if dev:
2234
logger.add(
23-
sys.stdout, colorize=True, format=formatter, level="DEBUG", enqueue=True
35+
sys.stdout,
36+
colorize=True,
37+
format=formatter,
38+
level=LogLevel.DEBUG.value,
39+
enqueue=True,
2440
)
2541

2642
logger.add(
@@ -29,7 +45,7 @@
2945
rotation=datetime.time(0, 0, 0, tzinfo=datetime.timezone.utc),
3046
retention="30 days",
3147
enqueue=True,
32-
level="DEBUG" if dev else "INFO",
48+
level=LogLevel.DEBUG.value if dev else LogLevel.INFO.value,
3349
)
3450

3551

0 commit comments

Comments
 (0)