($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
* [PATCH yocto-autobuilder-helper 1/3] scripts/abint: sort and organise imports
@ 2024-03-07 16:42 ross.burton
  2024-03-07 16:42 ` [PATCH yocto-autobuilder-helper 2/3] scripts/abint: add argument parser ross.burton
  2024-03-07 16:42 ` [PATCH yocto-autobuilder-helper 3/3] scripts/abint: fix sorting on initial display ross.burton
  0 siblings, 2 replies; 3+ messages in thread
From: ross.burton @ 2024-03-07 16:42 UTC (permalink / raw
  To: yocto

From: Ross Burton <ross.burton@arm.com>

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/abint/abint.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/scripts/abint/abint.py b/scripts/abint/abint.py
index f4cb8b29..d4fbed7e 100755
--- a/scripts/abint/abint.py
+++ b/scripts/abint/abint.py
@@ -1,14 +1,15 @@
 #! /usr/bin/env python3
 
-import re
 import collections
-from pprint import pprint
-import bugzilla
-import pickle
-import requests
 import dataclasses
-import arrow
 import logging
+import pickle
+import pprint
+import re
+
+import arrow
+import bugzilla
+import requests
 
 MOCK = False
 # logging.basicConfig(level=logging.DEBUG)
@@ -83,7 +84,7 @@ def get_data():
         for bug in bugs
     ]
 
-    pprint(bugs)
+    pprint.pprint(bugs)
     print(f"Found {len(bugs)} AB-INT bugs")
 
     comments_data = bz.get_comments([bug.id for bug in bugs])["bugs"]
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH yocto-autobuilder-helper 2/3] scripts/abint: add argument parser
  2024-03-07 16:42 [PATCH yocto-autobuilder-helper 1/3] scripts/abint: sort and organise imports ross.burton
@ 2024-03-07 16:42 ` ross.burton
  2024-03-07 16:42 ` [PATCH yocto-autobuilder-helper 3/3] scripts/abint: fix sorting on initial display ross.burton
  1 sibling, 0 replies; 3+ messages in thread
From: ross.burton @ 2024-03-07 16:42 UTC (permalink / raw
  To: yocto

From: Ross Burton <ross.burton@arm.com>

Add an argument parser so that the use of the cache or verbose logging
can be enabled/disabled without having to edit the source code.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/abint/abint.py | 45 ++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/scripts/abint/abint.py b/scripts/abint/abint.py
index d4fbed7e..1d358836 100755
--- a/scripts/abint/abint.py
+++ b/scripts/abint/abint.py
@@ -1,5 +1,6 @@
 #! /usr/bin/env python3
 
+import argparse
 import collections
 import dataclasses
 import logging
@@ -11,19 +12,6 @@ import arrow
 import bugzilla
 import requests
 
-MOCK = False
-# logging.basicConfig(level=logging.DEBUG)
-
-
-def save_pickle(name, data):
-    with open(name, "wb") as f:
-        pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
-
-
-def load_pickle(name):
-    with open(name, "rb") as f:
-        return pickle.load(f)
-
 
 http = requests.Session()
 
@@ -104,15 +92,9 @@ def get_data():
                 except requests.exceptions.HTTPError as e:
                     logging.debug(f"Couldn't find build for {builder=} {build=}")
 
-    save_pickle("bugs.data", bugs)
     return bugs
 
 
-if MOCK:
-
-    def get_data():
-        return load_pickle("bugs.data")
-
 
 def last_seen_report(data):
     import jinja2
@@ -129,5 +111,26 @@ def last_seen_report(data):
         f.write(template.render(bugs=data, start=start, now=arrow.now()))
 
 
-data = get_data()
-last_seen_report(data)
+CACHE_NAME = "bugs.data"
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--verbose", action="store_true", help="Enable verbose logging")
+    parser.add_argument("--cached", action="store_true", help="Use the local cached data instead of fetching")
+    args = parser.parse_args()
+
+    if args.verbose:
+        logging.basicConfig(level=logging.DEBUG)
+
+    if args.cached:
+        logging.debug(f"Loading cached data from {CACHE_NAME}")
+        with open(CACHE_NAME, "rb") as f:
+            data = pickle.load(f)
+    else:
+        data = get_data()
+        # Always save a cache because it's quick
+        logging.debug(f"Saving data to cache {CACHE_NAME}")
+        with open(CACHE_NAME, "wb") as f:
+            pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
+
+    last_seen_report(data)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH yocto-autobuilder-helper 3/3] scripts/abint: fix sorting on initial display
  2024-03-07 16:42 [PATCH yocto-autobuilder-helper 1/3] scripts/abint: sort and organise imports ross.burton
  2024-03-07 16:42 ` [PATCH yocto-autobuilder-helper 2/3] scripts/abint: add argument parser ross.burton
@ 2024-03-07 16:42 ` ross.burton
  1 sibling, 0 replies; 3+ messages in thread
From: ross.burton @ 2024-03-07 16:42 UTC (permalink / raw
  To: yocto

From: Ross Burton <ross.burton@arm.com>

The default sorting was based on the list of seen times, but it should
be based on the latest seen time.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/abint/abint.html.j2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/abint/abint.html.j2 b/scripts/abint/abint.html.j2
index f531649d..580a4a35 100644
--- a/scripts/abint/abint.html.j2
+++ b/scripts/abint/abint.html.j2
@@ -56,7 +56,7 @@
         </tr>
       </thead>
       <tbody>
-        {% for bug in bugs|sort(attribute="seen", reverse=True) %}
+        {% for bug in bugs|sort(attribute="latest", reverse=True) %}
         <tr>
           <th scope="row"><a href="http://bugzilla.yoctoproject.org/{{bug.id}}">{{bug.id}}</a></th>
           <td>
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-07 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-07 16:42 [PATCH yocto-autobuilder-helper 1/3] scripts/abint: sort and organise imports ross.burton
2024-03-07 16:42 ` [PATCH yocto-autobuilder-helper 2/3] scripts/abint: add argument parser ross.burton
2024-03-07 16:42 ` [PATCH yocto-autobuilder-helper 3/3] scripts/abint: fix sorting on initial display ross.burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).