Skip to content

Commit c9f6441

Browse files
committed
mailbot: plumb thru the user agent to Maintainers()
We fetch the MAINTAINERS file form Linus, set the user agent otherwise kernel.org is unpleasant to us. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent faee581 commit c9f6441

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

core/maintainers.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ def __eq__(self, other):
3838

3939

4040
class Maintainers:
41-
def __init__(self, *, file=None, url=None):
41+
def __init__(self, *, file=None, url=None, config=None):
4242
self.entries = MaintainersList()
4343

44+
self.http_headers = None
45+
if config:
46+
ua = config.get('patchwork', 'user-agent', fallback='')
47+
if ua:
48+
self.http_headers = {"user-agent":ua}
49+
4450
if file:
4551
self._load_from_file(file)
4652
elif url:
@@ -72,7 +78,7 @@ def _load_from_file(self, file):
7278
self._load_from_lines(f.read().split('\n'))
7379

7480
def _load_from_url(self, url):
75-
r = requests.get(url)
81+
r = requests.get(url, headers=self.http_headers)
7682
data = r.content.decode('utf-8')
7783
self._load_from_lines(data.split('\n'))
7884

mailbot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def main():
752752

753753
if (req_time - doc_load_time).total_seconds() > 24 * 60 * 60:
754754
global maintainers
755-
maintainers = Maintainers(url='https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/MAINTAINERS')
755+
maintainers = Maintainers(url='https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/MAINTAINERS', config=config)
756756

757757
dr = DocRefs()
758758
dr.load_section('process/maintainer-netdev', 'net')

0 commit comments

Comments
 (0)