[modules/github] Use GITHUB_TOKEN environment variable if present

This commit is contained in:
Frederic Junod 2017-07-12 16:06:17 +02:00
parent 8941f60572
commit 89c830789d

View file

@ -7,9 +7,11 @@ Requires the following library:
Parameters: Parameters:
* github.token: GitHub user access token, the token needs to have the 'notifications' scope. * github.token: GitHub user access token, the token needs to have the 'notifications' scope.
The value of the token can also be set using a 'GITHUB_TOKEN' environment variable.
* github.interval: Interval in minutes * github.interval: Interval in minutes
""" """
import os
import time import time
import functools import functools
import bumblebee.input import bumblebee.input
@ -41,7 +43,7 @@ class Module(bumblebee.engine.Module):
def update(self, _, immediate=False): def update(self, _, immediate=False):
if immediate or self._nextcheck < int(time.time()): if immediate or self._nextcheck < int(time.time()):
self._nextcheck = int(time.time()) + self._interval * 60 self._nextcheck = int(time.time()) + self._interval * 60
token = self.parameter("token", "") token = self.parameter("token", os.environ.get("GITHUB_TOKEN"))
if not token: if not token:
self._count = "n/a" self._count = "n/a"