Total Complexity | 3 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | #!/usr/bin/env python3 |
||
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | """KanbanView (app) for Things 3.""" |
||
5 | |||
6 | from __future__ import print_function |
||
7 | |||
8 | # pylint: disable=duplicate-code |
||
9 | __author__ = "Luc Beaulieu and Alexander Willner" |
||
10 | __copyright__ = "Copyright 2018 Luc Beaulieu / 2020 Alexander Willner" |
||
11 | __credits__ = ["Luc Beaulieu", "Alexander Willner"] |
||
12 | __license__ = "Apache License 2.0" |
||
13 | __version__ = "2.0.1" |
||
14 | __maintainer__ = "Alexander Willner" |
||
15 | __email__ = "[email protected]" |
||
16 | __status__ = "Development" |
||
17 | |||
18 | import sys |
||
19 | from os import system |
||
20 | from threading import Thread |
||
21 | import webview # type: ignore |
||
|
|||
22 | import objc # type: ignore # pylint: disable=unused-import # noqa F401 |
||
23 | import pkg_resources.py2_warn # type: ignore # pylint: disable=unused-import # noqa F401 |
||
24 | import things3.things3_api as things3_api |
||
25 | |||
26 | |||
27 | def open_api(): |
||
28 | """Delay opening the browser.""" |
||
29 | things3_api.APP.run(port=things3_api.PORT) |
||
30 | |||
31 | |||
32 | FILE = "kanban.html" |
||
33 | THREAD = Thread(target=open_api) |
||
34 | |||
35 | |||
36 | def main(): |
||
37 | """Run the app.""" |
||
38 | # kill possible zombie processes; can't use psutil in py2app context |
||
39 | system('lsof -nti:' + str(things3_api.PORT) + |
||
40 | ' | xargs kill -9') |
||
41 | |||
42 | webview.create_window( |
||
43 | title='KanbanView for Things 3', |
||
44 | url=f'http://localhost:{things3_api.PORT}/{FILE}', |
||
45 | width=1024, |
||
46 | min_size=(1024, 600), |
||
47 | frameless=True) |
||
48 | |||
49 | try: |
||
50 | THREAD.start() |
||
51 | webview.start() |
||
52 | except KeyboardInterrupt: |
||
53 | print("Shutting down...") |
||
54 | THREAD.join() |
||
55 | sys.exit(0) |
||
56 | |||
57 | |||
58 | if __name__ == "__main__": |
||
59 | main() |
||
60 |