Skip to content

Commit

Permalink
daily-status.py and dispatch-build: Set User-Agent header
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Nov 14, 2023
1 parent a7bbadf commit 7e28bc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/tools/daily-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import List
from xml.sax.saxutils import escape
from zipfile import Path as ZipPath
from ghreq import Client
from ghreq import Client, make_user_agent
from ghtoken import get_ghtoken
from pydantic import BaseModel, Field
import requests
Expand Down Expand Up @@ -289,13 +289,16 @@ class AppveyorHistory(BaseModel):
def main() -> None:
outfile = sys.argv[1]
token = get_ghtoken()
user_agent = make_user_agent(
"daily-status.py", url="https://github.com/datalad/git-annex"
)
cutoff = datetime.now(timezone.utc) - WINDOW

with CLIENT_INFO_FILE.open() as fp:
client_info = YAML(typ="safe").load(fp)
all_clients = set(client_info.keys())

with Client(token=token) as client:
with Client(token=token, user_agent=user_agent) as client:
github_statuses = []
wfrepo = client / "repos" / WORKFLOW_REPO
for wffilename in WORKFLOWS:
Expand Down Expand Up @@ -368,6 +371,7 @@ def main() -> None:

appveyor_builds = []
with requests.Session() as s:
s.headers["User-Agent"] = user_agent
for build in get_appveyor_builds(s):
if build.finished is None:
continue
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/tools/dispatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations
from collections.abc import Sequence
import click
from ghreq import Client
from ghreq import Client, make_user_agent
from ghtoken import get_ghtoken

__python_requires__ = ">= 3.8"
Expand Down Expand Up @@ -108,7 +108,10 @@ def main(
the `gh` or `hub` command, or by setting the `hub.oauthtoken` Git config
option in your `~/.gitconfig` file.
"""
with BuildDispatcher(token=get_ghtoken()) as client:
user_agent = make_user_agent(
"dispatch-build", url="https://github.com/datalad/git-annex"
)
with BuildDispatcher(token=get_ghtoken(), user_agent=user_agent) as client:
if pr:
if ref is None:
raise click.UsageError("--pr requires a PR number")
Expand Down

0 comments on commit 7e28bc4

Please sign in to comment.