mirror of
https://github.com/basicswap/basicswap.git
synced 2026-05-07 06:52:12 +02:00
Merge pull request #461 from tecnovert/ltc
fix: workaround for osx ltc release not on github
This commit is contained in:
+32
-14
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2019-2024 tecnovert
|
# Copyright (c) 2019-2024 tecnovert
|
||||||
# Copyright (c) 2024-2025 The Basicswap developers
|
# Copyright (c) 2024-2026 The Basicswap developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ import urllib.parse
|
|||||||
import zipfile
|
import zipfile
|
||||||
import zmq
|
import zmq
|
||||||
|
|
||||||
|
from typing import List
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
import basicswap.config as cfg
|
import basicswap.config as cfg
|
||||||
@@ -58,7 +59,7 @@ PARTICL_LINUX_EXTRA = os.getenv("PARTICL_LINUX_EXTRA", "nousb")
|
|||||||
BITCOIN_VERSION = os.getenv("BITCOIN_VERSION", "29.3")
|
BITCOIN_VERSION = os.getenv("BITCOIN_VERSION", "29.3")
|
||||||
BITCOIN_VERSION_TAG = os.getenv("BITCOIN_VERSION_TAG", "")
|
BITCOIN_VERSION_TAG = os.getenv("BITCOIN_VERSION_TAG", "")
|
||||||
|
|
||||||
LITECOIN_VERSION = os.getenv("LITECOIN_VERSION", "0.21.5.4")
|
LITECOIN_VERSION = os.getenv("LITECOIN_VERSION", "0.21.5.5")
|
||||||
LITECOIN_VERSION_TAG = os.getenv("LITECOIN_VERSION_TAG", "")
|
LITECOIN_VERSION_TAG = os.getenv("LITECOIN_VERSION_TAG", "")
|
||||||
|
|
||||||
DCR_VERSION = os.getenv("DCR_VERSION", "2.1.3")
|
DCR_VERSION = os.getenv("DCR_VERSION", "2.1.3")
|
||||||
@@ -185,11 +186,13 @@ else:
|
|||||||
BIN_ARCH = os.getenv("BIN_ARCH", BIN_ARCH)
|
BIN_ARCH = os.getenv("BIN_ARCH", BIN_ARCH)
|
||||||
FILE_EXT = os.getenv("FILE_EXT", FILE_EXT)
|
FILE_EXT = os.getenv("FILE_EXT", FILE_EXT)
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger("prepare")
|
||||||
LOG_LEVEL = logging.DEBUG
|
LOG_LEVEL = logging.DEBUG
|
||||||
|
logger.propagate = False
|
||||||
logger.level = LOG_LEVEL
|
logger.level = LOG_LEVEL
|
||||||
if not len(logger.handlers):
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
logger.addHandler(logging.StreamHandler(sys.stdout))
|
handler.setFormatter(logging.Formatter("%(levelname)s : %(message)s"))
|
||||||
|
logger.addHandler(handler)
|
||||||
logging.getLogger("gnupg").setLevel(logging.INFO)
|
logging.getLogger("gnupg").setLevel(logging.INFO)
|
||||||
|
|
||||||
BSX_DOCKER_MODE = toBool(os.getenv("BSX_DOCKER_MODE", False))
|
BSX_DOCKER_MODE = toBool(os.getenv("BSX_DOCKER_MODE", False))
|
||||||
@@ -458,12 +461,23 @@ def getRemoteFileLength(url: str) -> (int, bool):
|
|||||||
popConnectionParameters()
|
popConnectionParameters()
|
||||||
|
|
||||||
|
|
||||||
def downloadRelease(url: str, path: str, extra_opts, timeout: int = 10) -> None:
|
def downloadRelease(
|
||||||
"""If file exists at path compare it's size to the content length at the url
|
url_in: str | List[str], path: str, extra_opts, timeout: int = 10
|
||||||
and attempt to resume download if file size is below expected.
|
) -> None:
|
||||||
"""
|
# If file exists at path compare it's size to the content length at the url
|
||||||
resume_from: int = 0
|
# and attempt to resume download if file size is below expected.
|
||||||
|
|
||||||
|
release_filename: str = os.path.basename(path)
|
||||||
|
urls = (
|
||||||
|
url_in
|
||||||
|
if isinstance(url_in, list)
|
||||||
|
else [
|
||||||
|
url_in,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for url in urls:
|
||||||
|
try:
|
||||||
|
resume_from: int = 0
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
if extra_opts.get("redownload_releases", False):
|
if extra_opts.get("redownload_releases", False):
|
||||||
logging.warning(f"Overwriting: {path}")
|
logging.warning(f"Overwriting: {path}")
|
||||||
@@ -483,8 +497,11 @@ def downloadRelease(url: str, path: str, extra_opts, timeout: int = 10) -> None:
|
|||||||
else:
|
else:
|
||||||
# File exists and size check is disabled
|
# File exists and size check is disabled
|
||||||
return
|
return
|
||||||
|
|
||||||
return downloadFile(url, path, timeout, resume_from)
|
return downloadFile(url, path, timeout, resume_from)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to download {release_filename} from {url}")
|
||||||
|
logger.debug(f"Download error {e}")
|
||||||
|
raise RuntimeError(f"Failed to download {release_filename}.")
|
||||||
|
|
||||||
|
|
||||||
def downloadFile(url: str, path: str, timeout: int = 5, resume_from: int = 0) -> None:
|
def downloadFile(url: str, path: str, timeout: int = 5, resume_from: int = 0) -> None:
|
||||||
@@ -925,9 +942,10 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}):
|
|||||||
assert_filename,
|
assert_filename,
|
||||||
)
|
)
|
||||||
elif coin == "litecoin":
|
elif coin == "litecoin":
|
||||||
release_url = "https://github.com/litecoin-project/litecoin/releases/download/v{}/{}".format(
|
release_url = [
|
||||||
version + version_tag, release_filename
|
f"https://github.com/litecoin-project/litecoin/releases/download/v{version}{version_tag}/{release_filename}",
|
||||||
)
|
f"https://download.litecoin.org/litecoin-{version}{version_tag}/{os_name}/{release_filename}",
|
||||||
|
]
|
||||||
assert_filename = "{}-core-{}-{}-build.assert".format(
|
assert_filename = "{}-core-{}-{}-build.assert".format(
|
||||||
coin, os_name, ".".join(version.split(".")[:2])
|
coin, os_name, ".".join(version.split(".")[:2])
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user