From 8f71d050988ba486b150f178766a304ad8ca19cc Mon Sep 17 00:00:00 2001 From: Reza Date: Mon, 16 Sep 2024 22:21:48 -0700 Subject: [PATCH] greedy_url in error --- pyalfe/interfaces/greedy.py | 8 +++- pyalfe/tools/__init__.py | 80 +++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/pyalfe/interfaces/greedy.py b/pyalfe/interfaces/greedy.py index 569f89f..a1c1040 100644 --- a/pyalfe/interfaces/greedy.py +++ b/pyalfe/interfaces/greedy.py @@ -1,18 +1,22 @@ import subprocess from shutil import which -from pyalfe.tools import GREEDY_PATH +from pyalfe.tools import GREEDY_PATH, greedy_url class Greedy: def __init__(self, greedy_path=GREEDY_PATH): self.cmd = [greedy_path] if which(greedy_path) is None: - raise RuntimeError( + msg = ( f'{greedy_path} executable was not found in your system. ' 'To download and install greedy, visit:\n ' 'https://greedy.readthedocs.io/en/latest/install.html#using-pre-compiled-binaries' ) + if greedy_url: + msg += f'\n or {greedy_url} \n' + + raise RuntimeError(msg) def dim(self, d): self.cmd += ['-d', str(d)] diff --git a/pyalfe/tools/__init__.py b/pyalfe/tools/__init__.py index 2d4bb4b..9b397e9 100644 --- a/pyalfe/tools/__init__.py +++ b/pyalfe/tools/__init__.py @@ -1,42 +1,62 @@ import os +from collections import defaultdict -greedy_url = { - 'Linux': { - 'x86_64': ( - 'https://sourceforge.net/projects/greedy-reg/files/Nightly/' - 'greedy-nightly-Linux-gcc64.tar.gz' - ) - }, - 'Darwin': { - 'x86_64': ( - 'https://sourceforge.net/projects/greedy-reg/files/Nightly/' - 'greedy-nightly-MacOS-x86_64.dmg' +greedy_url = defaultdict( + lambda: defaultdict(str), + { + 'Linux': defaultdict( + str, + { + 'x86_64': ( + 'https://sourceforge.net/projects/greedy-reg/files/Nightly/' + 'greedy-nightly-Linux-gcc64.tar.gz' + ) + }, ), - 'arm64': ( - 'https://sourceforge.net/projects/greedy-reg/files/Nightly/' - 'greedy-nightly-MacOS-arm64.dmg' + 'Darwin': defaultdict( + str, + { + 'x86_64': ( + 'https://sourceforge.net/projects/greedy-reg/files/Nightly/' + 'greedy-nightly-MacOS-x86_64.dmg' + ), + 'arm64': ( + 'https://sourceforge.net/projects/greedy-reg/files/Nightly/' + 'greedy-nightly-MacOS-arm64.dmg' + ), + }, ), }, -}[os.uname()[0]][os.uname()[-1]] +)[os.uname()[0]][os.uname()[-1]] -c3d_url = { - 'Linux': { - 'x86_64': ( - 'https://sourceforge.net/projects/c3d/files/c3d/Nightly/' - 'c3d-nightly-Linux-gcc64.tar.gz' - ) - }, - 'Darwin': { - 'x86_64': ( - 'https://sourceforge.net/projects/c3d/files/c3d/Nightly/' - 'c3d-nightly-MacOS-x86_64.dmg' + +c3d_url = defaultdict( + lambda: defaultdict(str), + { + 'Linux': defaultdict( + str, + { + 'x86_64': ( + 'https://sourceforge.net/projects/c3d/files/c3d/Nightly/' + 'c3d-nightly-Linux-gcc64.tar.gz' + ) + }, ), - 'arm64': ( - 'https://sourceforge.net/projects/c3d/files/c3d/Nightly/' - 'c3d-nightly-MacOS-arm64.dmg' + 'Darwin': defaultdict( + str, + { + 'x86_64': ( + 'https://sourceforge.net/projects/c3d/files/c3d/Nightly/' + 'c3d-nightly-MacOS-x86_64.dmg' + ), + 'arm64': ( + 'https://sourceforge.net/projects/c3d/files/c3d/Nightly/' + 'c3d-nightly-MacOS-arm64.dmg' + ), + }, ), }, -}[os.uname()[0]][os.uname()[-1]] +)[os.uname()[0]][os.uname()[-1]] GREEDY_PATH = 'greedy' # importlib.resources.files('pyalfe.tools').joinpath('greedy') C3D_PATH = 'c3d' # importlib.resources.files('pyalfe.tools').joinpath('c3d')