|
12 | 12 | import sys |
13 | 13 | import zipfile |
14 | 14 |
|
15 | | -BASE_PATH = "https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.6.1/" |
| 15 | +from string import Template |
| 16 | + |
| 17 | +BASE_PATH = Template("https://github.com/eclipse-esmf/esmf-sdk/releases/download/v$version_number/$file_name") |
| 18 | +LINUX_FILE_NAME = Template("samm-cli-$version_number-linux-x86_64.tar.gz") |
| 19 | +SAMM_CLI_VERSION = "2.6.1" |
| 20 | +WIN_FILE_NAME = Template("samm-cli-$version_number-windows-x86_64.zip") |
16 | 21 |
|
17 | 22 |
|
18 | 23 | def get_samm_cli_file_name(): |
19 | 24 | """Get a SAMM CLI file name for the current platform.""" |
20 | 25 |
|
21 | 26 | if platform.system() == "Windows": |
22 | | - file_name = "samm-cli-2.6.1-windows-x86_64.zip" |
| 27 | + file_name = WIN_FILE_NAME.substitute(version_number=SAMM_CLI_VERSION) |
23 | 28 | elif platform.system() == "Linux": |
24 | | - file_name = "samm-cli-2.6.1-linux-x86_64.tar.gz" |
| 29 | + file_name = LINUX_FILE_NAME.substitute(version_number=SAMM_CLI_VERSION) |
25 | 30 | else: |
26 | | - raise NotImplementedError(f"Please download a SAMM CLI manually for your operation system from '{BASE_PATH}'") |
| 31 | + raise NotImplementedError( |
| 32 | + f"Please download a SAMM CLI manually for your operation system from '{BASE_PATH}'" |
| 33 | + ) |
27 | 34 |
|
28 | 35 | return file_name |
29 | 36 |
|
@@ -60,17 +67,17 @@ def download_samm_cli(): |
60 | 67 | print(error) |
61 | 68 | else: |
62 | 69 | print(f"Start downloading SAMM CLI {samm_cli_file_name}") |
63 | | - url = BASE_PATH + samm_cli_file_name |
64 | | - dir_path = Path(__file__).resolve().parent |
65 | | - archive_file = os.path.join(dir_path, f".\\{samm_cli_file_name}") |
| 70 | + url = BASE_PATH.substitute(version_number=SAMM_CLI_VERSION, file_name=samm_cli_file_name) |
| 71 | + dir_path = Path(__file__).resolve().parents[1] |
| 72 | + archive_file = os.path.join(dir_path, samm_cli_file_name) |
66 | 73 |
|
67 | 74 | download_archive_file(url, archive_file) |
68 | | - print("SAMM CLI archive file downloaded") |
| 75 | + print("\nSAMM CLI archive file downloaded") |
69 | 76 |
|
70 | 77 | print("Start extracting files") |
71 | 78 | archive = zipfile.ZipFile(archive_file) |
72 | 79 | for file in archive.namelist(): |
73 | | - archive.extract(file, ".\\samm-cli") |
| 80 | + archive.extract(file, "samm-cli") |
74 | 81 | archive.close() |
75 | 82 | print("Done extracting files.") |
76 | 83 |
|
|
0 commit comments