|
12 | 12 | import os |
13 | 13 | import re |
14 | 14 | import sys |
15 | | -import time |
16 | 15 | import traceback |
17 | 16 |
|
18 | 17 | import github as pygithub |
| 18 | +import requests |
19 | 19 |
|
20 | 20 | from adabot import github_requests as gh_reqs |
21 | 21 | from adabot import pypi_requests as pypi |
@@ -219,52 +219,20 @@ def run_library_checks(validators, kw_args, error_depth): |
219 | 219 | # - Release asset delivery is being moved to AWS CloudFront/S3 |
220 | 220 | # print_circuitpython_dl_stats() |
221 | 221 |
|
222 | | - # Get PyPI stats |
223 | | - have_secrets = False |
224 | | - while True: |
225 | | - try: |
226 | | - ada_bundle = GH_INTERFACE.get_repo("adafruit/Adafruit_CircuitPython_Bundle") |
227 | | - file_contents = ada_bundle.get_contents( |
228 | | - "circuitpython_library_pypi_stats.md" |
229 | | - ) |
230 | | - stats_contents = file_contents.decoded_content.decode("utf-8").split("\n") |
231 | | - lib_stats = {} |
232 | | - total_library_pypi_stats = 0 |
233 | | - blinka_pypi_downloads = 0 |
234 | | - in_lib_stats = False |
235 | | - for line in stats_contents: |
236 | | - line = line.strip() |
237 | | - if not line: |
238 | | - continue |
239 | | - if line.startswith("| Adafruit Blinka (adafruit-blinka) |"): |
240 | | - blinka_pypi_downloads = int(line[38:-2]) |
241 | | - continue |
242 | | - if line.startswith( |
243 | | - "**Total PyPI library downloads in the last 7 days:" |
244 | | - ): |
245 | | - total_library_pypi_stats = int(line[51:-2]) |
246 | | - continue |
247 | | - if line.startswith("|"): |
248 | | - parts = [part.strip() for part in line.split("|") if part.strip()] |
249 | | - if parts[0] in ("Library (PyPI Package)", "---"): |
250 | | - in_lib_stats = True |
251 | | - continue |
252 | | - if in_lib_stats: |
253 | | - lib_stats[parts[0]] = int(parts[1][:-10]) |
254 | | - else: |
255 | | - in_lib_stats = False |
256 | | - have_secrets = True |
257 | | - break |
258 | | - except pygithub.RateLimitExceededException: |
259 | | - core_rate_limit_reset = GH_INTERFACE.get_rate_limit().core.reset |
260 | | - sleep_time = core_rate_limit_reset - datetime.datetime.utcnow() |
261 | | - logging.warning("Rate Limit will reset at: %s", core_rate_limit_reset) |
262 | | - time.sleep(sleep_time.seconds) |
263 | | - continue |
264 | | - except pygithub.GithubException: |
265 | | - break |
266 | | - |
267 | 222 | logger.info("### Libraries") |
| 223 | + # Bundle library counts |
| 224 | + resp = requests.get( |
| 225 | + "https://raw.githubusercontent.com/adafruit/" |
| 226 | + "CircuitPython_Community_Bundle/main/.gitmodules", |
| 227 | + timeout=30, |
| 228 | + ) |
| 229 | + community_bundle_submodules = resp.text |
| 230 | + community_library_count = community_bundle_submodules.count("submodule") |
| 231 | + logger.info( |
| 232 | + "* Adafruit Libraries: %s Community Libraries: %s", |
| 233 | + len(bundle_submodules), |
| 234 | + community_library_count, |
| 235 | + ) |
268 | 236 | print_pr_overview(lib_insights) |
269 | 237 | logger.info(" * Merged pull requests:") |
270 | 238 | sorted_prs = sorted( |
@@ -296,29 +264,6 @@ def run_library_checks(validators, kw_args, error_depth): |
296 | 264 | logger.info("* https://circuitpython.org/contributing") |
297 | 265 |
|
298 | 266 | logger.info("") |
299 | | - logger.info("#### Library PyPI Weekly Download Stats") |
300 | | - # if pypi_stats: |
301 | | - if have_secrets: |
302 | | - logger.info("* **Total Library Stats**") |
303 | | - logger.info( |
304 | | - " * %d PyPI downloads over %d libraries", |
305 | | - total_library_pypi_stats, |
306 | | - len(lib_stats), |
307 | | - ) |
308 | | - logger.info("* **Top 10 Libraries by PyPI Downloads**") |
309 | | - for index, (lib_stat_name, lib_stat_dl) in enumerate(lib_stats.items()): |
310 | | - if index == 10: |
311 | | - break |
312 | | - logger.info( |
313 | | - " * %s: %d", |
314 | | - lib_stat_name, |
315 | | - lib_stat_dl, |
316 | | - ) |
317 | | - else: |
318 | | - logger.info( |
319 | | - "Secrets unavailable, cannot report PyPI download stats for libraries" |
320 | | - ) |
321 | | - logger.info("*This is normal for CI runs from PRs*") |
322 | 267 |
|
323 | 268 | new_libs, updated_libs = bundle_announcer.get_adafruit_bundle_updates() |
324 | 269 | ( |
@@ -381,14 +326,7 @@ def run_library_checks(validators, kw_args, error_depth): |
381 | 326 | .get("adafruit-blinka", {}) |
382 | 327 | .get("month", "N/A") |
383 | 328 | ) |
384 | | - if have_secrets: |
385 | | - logger.info( |
386 | | - "* PyPI downloads in the last week: %d", |
387 | | - blinka_pypi_downloads, |
388 | | - ) |
389 | | - else: |
390 | | - logger.info("Secrets unavailable, cannot report PyPI download stats for Blinka") |
391 | | - logger.info("*This is normal for CI runs from PRs*") |
| 329 | + |
392 | 330 | logger.info("* Piwheels Downloads in the last month: %s", blinka_dl) |
393 | 331 | logger.info("Number of supported boards: %s", blinka_funcs.board_count()) |
394 | 332 |
|
|
0 commit comments