-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
54 lines (48 loc) · 1.73 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys
import os
from requests.exceptions import ConnectionError, ReadTimeout
from tendo import singleton
from PyQt5.QtWidgets import QApplication, QMessageBox
from jira import JIRAError
from jiraclient import JiraClient
from controllers.main_controller import MainController
from controllers.login_controller import LoginController
from config import CREDENTIALS_PATH
if __name__ == '__main__':
app = QApplication(sys.argv)
path = os.path.dirname(os.path.realpath(__file__))
if os.path.exists(CREDENTIALS_PATH):
with open(CREDENTIALS_PATH, 'r', encoding='utf-8') as file:
content = file.read()
try:
email, token = content.split(';')
jira_client = JiraClient(email, token)
jira_client.client.search_issues(
'assignee = currentUser()',
maxResults=1
)
controller = MainController(jira_client)
app.setQuitOnLastWindowClosed(False)
except (ValueError, JIRAError):
controller = LoginController(app)
except (ConnectionError, ReadTimeout):
QMessageBox.warning(
None,
'Connection error',
'Check your internet connection and try again'
)
sys.exit()
else:
controller = LoginController(app)
# possibility to open only one application at time
try:
me = singleton.SingleInstance()
except singleton.SingleInstanceException:
QMessageBox.warning(
None,
'Warning',
'Another instance of JQR is running'
)
sys.exit()
controller.show()
sys.exit(app.exec_())