Merge bitcoin/bitcoin#34260: contrib: Remove unused functions
facaf56214contrib: Remove unused functions (MarcoFalke) Pull request description: * `remove_files` is unused since5668c6473a* `download_lines_with_urllib` is unused since it was introduced in37c9fb7a59* `determine_wellknown_cmd` is unused since76c090145eACKs for top commit: fjahr: ACKfacaf56214bensig: ACKfacaf56214straightforward l0rinc: Reproduced it locally, ACKfacaf56214Tree-SHA512: c7d4880944b57108429e31541f1b97a98101cc06f1be716d6028f4193b6f087d9af06fa87e95ab224e027d574c6bd793cf06e540cdb8997805e1470e0c4e77a2
This commit is contained in:
2 files changed
-40
No files matched your search
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# Copyright (c) 2021-present The Bitcoin Core developers
|
|
||||||
# Distributed under the MIT software license, see the accompanying
|
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
'''
|
|
||||||
Common utility functions
|
|
||||||
'''
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def determine_wellknown_cmd(envvar, progname) -> list[str]:
|
|
||||||
maybe_env = os.getenv(envvar)
|
|
||||||
maybe_which = shutil.which(progname)
|
|
||||||
if maybe_env:
|
|
||||||
return maybe_env.split(' ') # Well-known vars are often meant to be word-split
|
|
||||||
elif maybe_which:
|
|
||||||
return [ maybe_which ]
|
|
||||||
else:
|
|
||||||
sys.exit(f"{progname} not found")
|
|
||||||
@@ -39,8 +39,6 @@ import sys
|
|||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
import urllib.request
|
|
||||||
import urllib.error
|
|
||||||
import enum
|
import enum
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from pathlib import PurePath, Path
|
from pathlib import PurePath, Path
|
||||||
@@ -116,18 +114,6 @@ def download_with_wget(remote_file, local_file):
|
|||||||
return result.returncode == 0, result.stdout.decode().rstrip()
|
return result.returncode == 0, result.stdout.decode().rstrip()
|
||||||
|
|
||||||
|
|
||||||
def download_lines_with_urllib(url) -> tuple[bool, list[str]]:
|
|
||||||
"""Get (success, text lines of a file) over HTTP."""
|
|
||||||
try:
|
|
||||||
return (True, [
|
|
||||||
line.strip().decode() for line in urllib.request.urlopen(url).readlines()])
|
|
||||||
except urllib.error.HTTPError as e:
|
|
||||||
log.warning(f"HTTP request to {url} failed (HTTPError): {e}")
|
|
||||||
except Exception as e:
|
|
||||||
log.warning(f"HTTP request to {url} failed ({e})")
|
|
||||||
return (False, [])
|
|
||||||
|
|
||||||
|
|
||||||
def verify_with_gpg(
|
def verify_with_gpg(
|
||||||
filename,
|
filename,
|
||||||
signature_filename,
|
signature_filename,
|
||||||
@@ -148,11 +134,6 @@ def verify_with_gpg(
|
|||||||
return result.returncode, gpg_data
|
return result.returncode, gpg_data
|
||||||
|
|
||||||
|
|
||||||
def remove_files(filenames):
|
|
||||||
for filename in filenames:
|
|
||||||
os.remove(filename)
|
|
||||||
|
|
||||||
|
|
||||||
class SigData:
|
class SigData:
|
||||||
"""GPG signature data as parsed from GPG stdout."""
|
"""GPG signature data as parsed from GPG stdout."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Reference in new issue
Block a user