From: Heiko Schocher <hs@denx.de>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Heiko Schocher <hs@nabladev.com>, Heiko Schocher <hs@denx.de>,
Caleb Connolly <caleb.connolly@linaro.org>,
Greg Malysa <malysagreg@gmail.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Jerome Forissier <jerome.forissier@linaro.org>,
Mattijs Korpershoek <mkorpershoek@kernel.org>,
Nathan Barrett-Morrison <nathan.morrison@timesys.com>,
Oliver Gaskell <Oliver.Gaskell@analog.com>,
Robert Marko <robert.marko@sartura.hr>,
Sam Protsenko <semen.protsenko@linaro.org>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v1 8/8] scripts: add helper for getting infos from your patchwork ToDo list
Date: Sat, 5 Apr 2025 20:46:26 +0200 [thread overview]
Message-ID: <20250405184626.22377-9-hs@denx.de> (raw)
In-Reply-To: <20250405184626.22377-1-hs@denx.de>
From: Heiko Schocher <hs@nabladev.com>
The new script scripts/getpatchlist.py list for all patches in your
Patchworks ToDo list the PATCH ID and MESSAGE ID.
With that script you can eaysy do in your current U-Boot tree:
MIL=$(scripts/getpatchlist.py <your username> <your patchwork password> | cut -d " " -f 2)
for m in $MIL;do
rm -rf mbox
wget http://patchwork.ozlabs.org/project/uboot/patch/$m/mbox
scripts/checkpatch.pl mbox
git am -3 --whitespace=strip mbox
done
And you have all your patches from your ToDo list downloaded,
checked with the checkpatch.pl script and applied to your current
branch.
Signed-off-by: Heiko Schocher <hs@nabladev.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
---
MAINTAINERS | 1 +
scripts/getpatchlist.py | 126 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+)
create mode 100755 scripts/getpatchlist.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 90a54deedb..24238a8f5b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1678,6 +1678,7 @@ F: cmd/broadcom/chimp_handshake.c
TBOTTEST
M: Heiko Schocher <hs@nabladev.com>
S: Maintained
+F: scripts/getpatchlist.py
F: tbottesting/*
TDA19988 HDMI ENCODER
diff --git a/scripts/getpatchlist.py b/scripts/getpatchlist.py
new file mode 100755
index 0000000000..3df483b1da
--- /dev/null
+++ b/scripts/getpatchlist.py
@@ -0,0 +1,126 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0+
+
+import requests
+import argparse
+from bs4 import BeautifulSoup
+
+# URLs
+LOGIN_URL = "https://patchwork.ozlabs.org/user/login/"
+TODO_LIST_URL = "https://patchwork.ozlabs.org/user/todo/uboot/"
+
+def login_and_get_cookies(username, password):
+ # Start a session to maintain cookies
+ session = requests.Session()
+
+ # Get the CSRF token by sending a GET request to the login page
+ response = session.get(LOGIN_URL)
+
+ # Check if the response is successful
+ if response.status_code != 200:
+ print(f"Error fetching login page: {response.status_code}")
+ return None, None
+
+ # Extract CSRF token from cookies or HTML
+ csrf_token = response.cookies.get('csrftoken')
+ if not csrf_token:
+ # If not found in cookies, extract it from the HTML form
+ soup = BeautifulSoup(response.text, "html.parser")
+ csrf_token = soup.find("input", {"name": "csrfmiddlewaretoken"})["value"]
+
+ #print(f"CSRF Token: {csrf_token}")
+
+ # Prepare login data
+ login_data = {
+ 'username': username,
+ 'password': password,
+ 'csrfmiddlewaretoken': csrf_token,
+ }
+
+ # Send POST request to login
+ headers = {
+ 'User-Agent': 'Mozilla/5.0', # Common user-agent string
+ 'Referer': LOGIN_URL # Set Referer header to avoid potential issues
+ }
+
+ # Perform login
+ login_response = session.post(LOGIN_URL, data=login_data, headers=headers)
+
+ # If login is successful, extract session ID from cookies
+ if login_response.status_code == 200:
+ session_id = session.cookies.get('sessionid') # Get session ID from cookies
+ #print(f"Session ID: {session_id}")
+ return session, session_id
+ else:
+ print(f"Login failed: {login_response.status_code}")
+ return None, None
+
+def get_todo_patch_and_message_ids(session):
+ response = session.get(TODO_LIST_URL)
+
+ if response.status_code != 200:
+ print(f"Error fetching todo list: {response.status_code}")
+ return []
+
+ soup = BeautifulSoup(response.text, "html.parser")
+
+ patch_data = []
+ for row in soup.select("tr[id^='patch_row']"): # Identify all patch rows
+ # Extract the Patch ID from the 'id' attribute
+ patch_id = row.get("id").split(":")[1]
+
+ # Extract the Message ID from the patch URL
+ msg_id_tag = row.select_one('a[href^="/project/uboot/patch/"]') # Look for the patch URL
+ if msg_id_tag:
+ msg_id = msg_id_tag["href"].split("/")[4] # Extract the Message ID
+
+ patch_data.append((patch_id, msg_id))
+
+ return patch_data
+
+def main():
+ """
+ Get a list of your patches in your patchworks ToDo list. List for each patch the
+ PATCH ID and MESSAGE ID, so you can use them for example with the pwclient.py tool.
+
+ Or you can do in your current U-Boot tree:
+
+ MIL=$(scripts/getpatchlist.py <your username> <your patchwork password> | cut -d " " -f 2)
+ for m in $MIL;do
+ rm -rf mbox
+ wget http://patchwork.ozlabs.org/project/uboot/patch/$m/mbox
+ scripts/checkpatch.pl mbox
+ git am -3 --whitespace=strip mbox
+ done
+
+ And you have all your patches from your ToDo list downloaded, checked with the
+ checkpatch.pl script and applied to your current branch.
+ """
+ # Set up argument parser
+ parser = argparse.ArgumentParser(description="Login to Patchwork and get Todo list patches.")
+ parser.add_argument("username", help="Your Patchwork username")
+ parser.add_argument("password", help="Your Patchwork password")
+
+ # Parse arguments
+ args = parser.parse_args()
+
+ # Step 1: Login and get session
+ session, session_id = login_and_get_cookies(args.username, args.password)
+
+ if session:
+ # Step 2: Get patch IDs and message IDs
+ patches = get_todo_patch_and_message_ids(session)
+
+ if patches:
+ # print("Found Patch IDs and Message IDs:")
+ for patch_id, msg_id in patches:
+ print(f"{patch_id} {msg_id}")
+ else:
+ print("No patches found. Check the HTML structure!")
+ exit (1)
+ else:
+ print("Unable to login. Exiting.")
+ exit (2)
+
+if __name__ == "__main__":
+ main()
--
2.20.1
prev parent reply other threads:[~2025-04-05 18:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 18:46 [PATCH v1 0/8] This series introduces U-Boot tests with tbot on real hardware Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 1/8] test/py/requirements.txt: update coverage Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 2/8] tools/buildman/requirements.txt: " Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 3/8] test/py/requirements.txt: increase filelock version Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 4/8] test/py/requirements.txt: remove unittest2 and testtools Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 5/8] test: increase timeouts Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 6/8] [RFC] CI: add U-Boot testing on real HW with tbot Heiko Schocher
2025-04-05 18:46 ` [PATCH v1 7/8] .gitlab-ci.yml: add tbot-lab Heiko Schocher
2025-04-05 18:46 ` Heiko Schocher [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250405184626.22377-9-hs@denx.de \
--to=hs@denx.de \
--cc=Oliver.Gaskell@analog.com \
--cc=caleb.connolly@linaro.org \
--cc=hs@nabladev.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jerome.forissier@linaro.org \
--cc=malysagreg@gmail.com \
--cc=mkorpershoek@kernel.org \
--cc=nathan.morrison@timesys.com \
--cc=robert.marko@sartura.hr \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox