[geany/infrastructure] 830916: Handle missing response headers from GitHub API

Enrico Tröger git-noreply at xxxxx
Fri May 15 09:31:10 UTC 2020


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Fri, 15 May 2020 09:31:10 UTC
Commit:      8309162add61e4a68abfd2e11b5ecf6eed49ef55
             https://github.com/geany/infrastructure/commit/8309162add61e4a68abfd2e11b5ecf6eed49ef55

Log Message:
-----------
Handle missing response headers from GitHub API

The GitHub sometimes don't set the 'Content-Length' header in responses.
As we do not strictly need the header contents, make it optional.


Modified Paths:
--------------
    scripts/git_hooks/github_commit_mail.py

Modified: scripts/git_hooks/github_commit_mail.py
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -123,9 +123,9 @@ def _query_commit_info(self, commit):
     #----------------------------------------------------------------------
     def _log_rate_limit(self, urllib_handle):
         headers = urllib_handle.info()
-        rate_limit_remaining = headers['X-RateLimit-Remaining']
-        rate_limit = headers['X-RateLimit-Limit']
-        length = headers['Content-Length']
+        rate_limit_remaining = headers.get('X-RateLimit-Remaining', '<unknown>')
+        rate_limit = headers.get('X-RateLimit-Limit', '<unknown>')
+        length = headers.get('Content-Length', '<unknown>')
         self._logger.debug(u'Github rate limits: %s/%s (%s bytes received)' %
             (rate_limit_remaining, rate_limit, length))
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list