-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
61 lines (49 loc) · 1.59 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
55
56
57
58
59
60
61
import json
import os
import subprocess
import sys
import webbrowser
import rumps
from jira import JIRA
config = json.load(open(os.path.expanduser("~") + '/todo-app.json'))
class JiraTodoApp(object):
def __init__(self):
self.config = {
"app_name": "My Todos",
}
self.app = rumps.App(self.config["app_name"])
self.set_up_menu()
self.refresh = rumps.MenuItem(title="Refresh", callback=self.get_issues)
self.app.menu = [self.refresh]
def set_up_menu(self):
self.app.title = "💻"
self.get_issues()
def open_url(self, item):
id = item.title.split(':')[0]
url = '{}/browse/{}'.format(server, id)
if sys.platform == 'darwin':
subprocess.Popen(['open', url])
else:
webbrowser.open_new_tab(url)
def get_issues(self):
options = {
'server': server
}
jira = JIRA(options, basic_auth=(user, apikey))
issues = jira.search_issues(
'assignee = currentUser() AND status="TO DO"')
for issue in issues:
fields = jira.issue(issue.key).fields
issue_string = '{}:{} - {}'.format(issue.key,
fields.summary, fields.reporter)
button = rumps.MenuItem(
title=issue_string, callback=self.open_url)
self.app.menu.update(button)
def run(self):
self.app.run()
if __name__ == '__main__':
user = config['user']
server = config['server']
apikey = config['apikey']
app = JiraTodoApp()
app.run()