MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / geckodriver

Function geckodriver

scripts/pinned_browsers.py:382–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

380
381
382def geckodriver():
383 content = ""
384
385 releases_url = "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
386 r = http.request("GET", releases_url, headers=API_HEADERS)
387 if r.status != 200:
388 body = r.data[:200].decode("utf-8", "replace")
389 raise ValueError(f"Fetch failed (HTTP {r.status}): {releases_url}: {body}")
390 for a in json.loads(r.data)["assets"]:
391 if a["name"].endswith("-linux64.tar.gz"):
392 url = a["browser_download_url"]
393 sha = calculate_hash(url)
394 content = (
395 content
396 + f""" http_archive(
397 name = "linux_geckodriver",
398 url = "{url}",
399 sha256 = "{sha}",
400 build_file_content = \"\"\"
401load("@aspect_rules_js//js:defs.bzl", "js_library")
402package(default_visibility = ["//visibility:public"])
403
404exports_files(["geckodriver"])
405
406js_library(
407 name = "geckodriver-js",
408 data = ["geckodriver"],
409)
410\"\"\",
411 )
412"""
413 )
414
415 if a["name"].endswith("-macos-aarch64.tar.gz"):
416 url = a["browser_download_url"]
417 sha = calculate_hash(url)
418 content = (
419 content
420 + f"""
421 http_archive(
422 name = "mac_geckodriver",
423 url = "{url}",
424 sha256 = "{sha}",
425 build_file_content = \"\"\"
426load("@aspect_rules_js//js:defs.bzl", "js_library")
427package(default_visibility = ["//visibility:public"])
428
429exports_files(["geckodriver"])
430
431js_library(
432 name = "geckodriver-js",
433 data = ["geckodriver"],
434)
435\"\"\",
436 )
437"""
438 )
439 return content

Callers 1

pinned_browsers.pyFile · 0.85

Calls 3

calculate_hashFunction · 0.85
decodeMethod · 0.65
requestMethod · 0.45

Tested by

no test coverage detected