From c55fb901a5d2203e0b50e0afd4213ebd6b066436 Mon Sep 17 00:00:00 2001 From: kkajakas <137375839+kkajakas@users.noreply.github.com> Date: Fri, 23 Jun 2023 08:39:09 +0300 Subject: [PATCH 1/4] Create requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ + From 90c2352f93e0b23b401382c7da4e6d0d4fae58d2 Mon Sep 17 00:00:00 2001 From: kkajakas <137375839+kkajakas@users.noreply.github.com> Date: Fri, 23 Jun 2023 08:43:27 +0300 Subject: [PATCH 2/4] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8b13789..40547de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ - +@file https://dl.djicdn.com/downloads/dji_thermal_sdk/20221108/dji_thermal_sdk_v1.4_20220929.zip From 4bba9519163db54ed65d1cb71b8197f724f6d385 Mon Sep 17 00:00:00 2001 From: kkajakas <137375839+kkajakas@users.noreply.github.com> Date: Fri, 23 Jun 2023 09:01:55 +0300 Subject: [PATCH 3/4] Create install.py --- install.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 install.py diff --git a/install.py b/install.py new file mode 100644 index 0000000..12a3a37 --- /dev/null +++ b/install.py @@ -0,0 +1,45 @@ +import os +import requests +import zipfile +from tqdm import tqdm + +# Define the URL of the zip file +zip_url = "https://dl.djicdn.com/downloads/dji_thermal_sdk/20221108/dji_thermal_sdk_v1.4_20220929.zip" + +# Define the target directory for extraction +target_dir = "resources/dji" + +# Create the target directory if it doesn't exist +os.makedirs(target_dir, exist_ok=True) + +# Download the zip file +response = requests.get(zip_url, stream=True) +total_size = int(response.headers.get("content-length", 0)) +block_size = 1024 # 1KB +progress_bar = tqdm(total=total_size, unit="iB", unit_scale=True) + +with open("dji_thermal_sdk.zip", "wb") as zip_file: + for data in response.iter_content(block_size): + progress_bar.update(len(data)) + zip_file.write(data) + +progress_bar.close() + +# Extract the contents of the zip file +with zipfile.ZipFile("dji_thermal_sdk.zip", "r") as zip_ref: + files_to_extract = [ + file for file in zip_ref.namelist() + if file.startswith("utility/bin/linux/release_x64") or file.startswith("utility/bin/windows/release_x64") + ] + progress_bar = tqdm(total=len(files_to_extract)) + + for file in files_to_extract: + zip_ref.extract(file, target_dir) + progress_bar.update(1) + +progress_bar.close() + +# Remove the zip file +os.remove("dji_thermal_sdk.zip") + +print("Installation completed.") From c57a37e97a912a6fa1204b57aaa570853f2c9fd3 Mon Sep 17 00:00:00 2001 From: kkajakas <137375839+kkajakas@users.noreply.github.com> Date: Fri, 23 Jun 2023 20:40:10 +0300 Subject: [PATCH 4/4] Update install.py --- install.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/install.py b/install.py index 12a3a37..ac2d2ad 100644 --- a/install.py +++ b/install.py @@ -1,7 +1,9 @@ import os import requests import zipfile +import tempfile from tqdm import tqdm +import shutil # Define the URL of the zip file zip_url = "https://dl.djicdn.com/downloads/dji_thermal_sdk/20221108/dji_thermal_sdk_v1.4_20220929.zip" @@ -12,34 +14,39 @@ # Create the target directory if it doesn't exist os.makedirs(target_dir, exist_ok=True) +# Create a temporary directory for extraction +temp_dir = tempfile.mkdtemp() + # Download the zip file response = requests.get(zip_url, stream=True) total_size = int(response.headers.get("content-length", 0)) block_size = 1024 # 1KB progress_bar = tqdm(total=total_size, unit="iB", unit_scale=True) -with open("dji_thermal_sdk.zip", "wb") as zip_file: +zip_path = os.path.join(temp_dir, "dji_thermal_sdk.zip") + +with open(zip_path, "wb") as zip_file: for data in response.iter_content(block_size): progress_bar.update(len(data)) zip_file.write(data) progress_bar.close() -# Extract the contents of the zip file -with zipfile.ZipFile("dji_thermal_sdk.zip", "r") as zip_ref: - files_to_extract = [ - file for file in zip_ref.namelist() - if file.startswith("utility/bin/linux/release_x64") or file.startswith("utility/bin/windows/release_x64") - ] - progress_bar = tqdm(total=len(files_to_extract)) - - for file in files_to_extract: - zip_ref.extract(file, target_dir) - progress_bar.update(1) - -progress_bar.close() +# Extract the contents of the zip file to the temporary directory +with zipfile.ZipFile(zip_path, "r") as zip_ref: + for file in zip_ref.namelist(): + if file.startswith("utility/bin/linux/release_x64/") or file.startswith("utility/bin/windows/release_x64/"): + source_path = zip_ref.extract(file, path=temp_dir) + target_path = os.path.join(target_dir, os.path.basename(file)) + if os.path.isdir(source_path): # Check if the extracted item is a directory + shutil.copytree(source_path, target_path, dirs_exist_ok=True) + else: + shutil.copy(source_path, target_path) # Remove the zip file -os.remove("dji_thermal_sdk.zip") +os.remove(zip_path) + +# Remove the temporary directory +shutil.rmtree(temp_dir) print("Installation completed.")