"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/www/avatar.py" between
buildbot-3.0.2.tar.gz and buildbot-3.1.0.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

avatar.py  (buildbot-3.0.2):avatar.py  (buildbot-3.1.0)
skipping to change at line 16 skipping to change at line 16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details. # details.
# #
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 # this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Copyright Buildbot Team Members # Copyright Buildbot Team Members
import base64
import hashlib import hashlib
from urllib.parse import urlencode from urllib.parse import urlencode
from urllib.parse import urljoin from urllib.parse import urljoin
from urllib.parse import urlparse from urllib.parse import urlparse
from urllib.parse import urlunparse from urllib.parse import urlunparse
from twisted.internet import defer from twisted.internet import defer
from twisted.python import log from twisted.python import log
from buildbot.util import config from buildbot import config
from buildbot.util import httpclientservice from buildbot.util import httpclientservice
from buildbot.util import unicode2bytes from buildbot.util import unicode2bytes
from buildbot.util.config import ConfiguredMixin
from buildbot.www import resource from buildbot.www import resource
class AvatarBase(config.ConfiguredMixin): class AvatarBase(ConfiguredMixin):
name = "noavatar" name = "noavatar"
def getUserAvatar(self, email, username, size, defaultAvatarUrl): def getUserAvatar(self, email, username, size, defaultAvatarUrl):
raise NotImplementedError() raise NotImplementedError()
class AvatarGitHub(AvatarBase): class AvatarGitHub(AvatarBase):
name = "github" name = "github"
DEFAULT_GITHUB_API_URL = 'https://api.github.com' DEFAULT_GITHUB_API_URL = 'https://api.github.com'
def __init__(self, def __init__(self,
github_api_endpoint=None, github_api_endpoint=None,
token=None, token=None,
client_id=None,
client_secret=None,
debug=False, debug=False,
verify=False): verify=False):
httpclientservice.HTTPClientService.checkAvailable(self.__class__.__name __) httpclientservice.HTTPClientService.checkAvailable(self.__class__.__name __)
self.github_api_endpoint = github_api_endpoint self.github_api_endpoint = github_api_endpoint
if github_api_endpoint is None: if github_api_endpoint is None:
self.github_api_endpoint = self.DEFAULT_GITHUB_API_URL self.github_api_endpoint = self.DEFAULT_GITHUB_API_URL
self.token = token self.token = token
self.client_creds = None
if bool(client_id) != bool(client_secret):
config.error('client_id and client_secret must be both provided or n
one')
if client_id:
if token:
config.error('client_id and client_secret must not be provided w
hen token is')
self.client_creds = base64.b64encode(b':'.join(
cred.encode('utf-8') for cred in (client_id, client_secret)
)).decode('ascii')
self.debug = debug self.debug = debug
self.verify = verify self.verify = verify
self.master = None self.master = None
self.client = None self.client = None
@defer.inlineCallbacks @defer.inlineCallbacks
def _get_http_client(self): def _get_http_client(self):
if self.client is not None: if self.client is not None:
return self.client return self.client
headers = { headers = {
'User-Agent': 'Buildbot', 'User-Agent': 'Buildbot',
} }
if self.token: if self.token:
headers['Authorization'] = 'token ' + self.token headers['Authorization'] = 'token ' + self.token
elif self.client_creds:
headers['Authorization'] = 'basic ' + self.client_creds
self.client = yield httpclientservice.HTTPClientService.getService(self. master, self.client = yield httpclientservice.HTTPClientService.getService(self. master,
self.github_api_endpoint, headers=headers, self.github_api_endpoint, headers=headers,
debug=self.debug, verify=self.verify) debug=self.debug, verify=self.verify)
return self.client return self.client
@defer.inlineCallbacks @defer.inlineCallbacks
def _get_avatar_by_username(self, username): def _get_avatar_by_username(self, username):
headers = { headers = {
 End of changes. 7 change blocks. 
2 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)