Merge pull request #414 from nclsHart/github-access-token
Allow use of access_token in github module
This commit is contained in:
commit
8dee66059e
@ -7,9 +7,16 @@ from i3pystatus.core.util import user_open, internet, require
|
|||||||
|
|
||||||
class Github(IntervalModule):
|
class Github(IntervalModule):
|
||||||
"""
|
"""
|
||||||
Check Github for pending notifications.
|
Check GitHub for pending notifications.
|
||||||
Requires `requests`
|
Requires `requests`
|
||||||
|
|
||||||
|
Availables authentication methods:
|
||||||
|
|
||||||
|
* username + password
|
||||||
|
* access_token (manually generate a new token at https://github.com/settings/tokens)
|
||||||
|
|
||||||
|
See https://developer.github.com/v3/#authentication for more informations.
|
||||||
|
|
||||||
Formatters:
|
Formatters:
|
||||||
|
|
||||||
* `{unread}` — contains the value of unread_marker when there are pending notifications
|
* `{unread}` — contains the value of unread_marker when there are pending notifications
|
||||||
@ -22,6 +29,7 @@ class Github(IntervalModule):
|
|||||||
color = '#78EAF2'
|
color = '#78EAF2'
|
||||||
username = ''
|
username = ''
|
||||||
password = ''
|
password = ''
|
||||||
|
access_token = ''
|
||||||
format = '{unread}'
|
format = '{unread}'
|
||||||
interval = 600
|
interval = 600
|
||||||
keyring_backend = None
|
keyring_backend = None
|
||||||
@ -34,6 +42,7 @@ class Github(IntervalModule):
|
|||||||
('unread_marker', 'sets the string that the "unread" formatter shows when there are pending notifications'),
|
('unread_marker', 'sets the string that the "unread" formatter shows when there are pending notifications'),
|
||||||
("username", ""),
|
("username", ""),
|
||||||
("password", ""),
|
("password", ""),
|
||||||
|
("access_token", "see https://developer.github.com/v3/#authentication"),
|
||||||
("color", "")
|
("color", "")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,6 +53,9 @@ class Github(IntervalModule):
|
|||||||
def run(self):
|
def run(self):
|
||||||
format_values = dict(unread_count='', unread='')
|
format_values = dict(unread_count='', unread='')
|
||||||
|
|
||||||
|
if self.access_token:
|
||||||
|
response = requests.get('https://api.github.com/notifications?access_token=' + self.access_token)
|
||||||
|
else:
|
||||||
response = requests.get('https://api.github.com/notifications', auth=(self.username, self.password))
|
response = requests.get('https://api.github.com/notifications', auth=(self.username, self.password))
|
||||||
data = json.loads(response.text)
|
data = json.loads(response.text)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user