Skip to content

Commit 616b35d

Browse files
committed
app build script
1 parent fe3ef88 commit 616b35d

File tree

2 files changed

+104
-13
lines changed

2 files changed

+104
-13
lines changed

app/Tuttle.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,25 @@ def on_click_generate_invoices(self, event):
248248
)
249249
logger.info("Generate invoices clicked")
250250
if not self.calendar_file_path:
251+
self.app.snackbar_message(f"Please select a calendar file")
251252
logger.error("No calendar file selected!")
252253
return
253-
self.app.con.billing(
254-
project_tags=[self.project_select.value],
255-
period_start=str(self.date_from_select.get_date()),
256-
period_end=str(self.date_to_select.get_date()),
257-
timetracking_method="file_calendar",
258-
calendar_file_path=self.calendar_file_path,
259-
)
260-
self.app.snackbar_message(
261-
f"created invoice and timesheet for {self.project_select.value} - open the invoice folder to see the result"
262-
)
254+
try:
255+
self.app.con.billing(
256+
project_tags=[self.project_select.value],
257+
period_start=str(self.date_from_select.get_date()),
258+
period_end=str(self.date_to_select.get_date()),
259+
timetracking_method="file_calendar",
260+
calendar_file_path=self.calendar_file_path,
261+
)
262+
self.app.snackbar_message(
263+
f"created invoice and timesheet for {self.project_select.value} - open the invoice folder to see the result"
264+
)
265+
except Exception as ex:
266+
self.app.snackbar_message(
267+
f"failed to create invoice and timesheet for {self.project_select.value}: {ex}"
268+
)
269+
raise ex
263270

264271
def on_pick_calendar_file(self, event: FilePickerResultEvent):
265272
"""Handle the result of the calendar file picker."""

scripts/build_app.py

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,89 @@
11
import os
2+
import sys
3+
import subprocess
24

3-
os.system(
4-
"pyinstaller app/Tuttle.py --noconsole --noconfirm --add-data 'tuttle_tests/data/TuttleDemo-TimeTracking.ics:.'"
5-
)
5+
from loguru import logger
6+
7+
added_files = [
8+
("tuttle_tests/data", "demo_data"),
9+
("templates", "templates"),
10+
]
11+
12+
added_data_options = [f"--add-data={src}:{dst}" for src, dst in added_files]
13+
14+
15+
def build_macos():
16+
pyinstaller_options = [
17+
"--noconfirm",
18+
"--windowed",
19+
"--clean",
20+
"--onefile",
21+
# "--onedir",
22+
]
23+
24+
options = pyinstaller_options + added_data_options
25+
26+
logger.info(f"calling pyinstaller with options: {' '.join(options)}")
27+
subprocess.call(
28+
["pyinstaller", "app/Tuttle.py"] + options,
29+
shell=False,
30+
)
31+
32+
33+
def build_linux():
34+
pyinstaller_options = [
35+
"--noconfirm",
36+
"--windowed",
37+
"--clean",
38+
"--onefile",
39+
# "--onedir",
40+
]
41+
42+
options = pyinstaller_options + added_data_options
43+
44+
logger.info(f"calling pyinstaller with options: {' '.join(options)}")
45+
subprocess.call(
46+
["pyinstaller", "app/Tuttle.py"] + options,
47+
shell=False,
48+
)
49+
50+
51+
def build_windows():
52+
pyinstaller_options = [
53+
"--noconfirm",
54+
"--windowed",
55+
"--clean",
56+
"--onefile",
57+
# "--onedir",
58+
]
59+
60+
options = pyinstaller_options + added_data_options
61+
62+
logger.info(f"calling pyinstaller with options: {' '.join(options)}")
63+
subprocess.call(
64+
["pyinstaller", "app/Tuttle.py"] + options,
65+
shell=False,
66+
)
67+
68+
69+
def main():
70+
# which operating system?
71+
if sys.platform.startswith("linux"):
72+
logger.info("building for Linux")
73+
build_linux()
74+
elif sys.platform.startswith("darwin"):
75+
logger.info("building for macOS")
76+
build_macos()
77+
elif sys.platform.startswith("win"):
78+
logger.info("building for Windows")
79+
build_windows()
80+
else:
81+
raise RuntimeError("Unsupported operating system")
82+
83+
84+
if __name__ == "__main__":
85+
main()
86+
87+
# os.system(
88+
# "pyinstaller app/Tuttle.py --onefile --noconsole --noconfirm --add-data 'tuttle_tests/data/TuttleDemo-TimeTracking.ics:.'"
89+
# )

0 commit comments

Comments
 (0)