Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kkajakas patch 2 #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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"

# 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)

# 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)

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 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(zip_path)

# Remove the temporary directory
shutil.rmtree(temp_dir)

print("Installation completed.")
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@file https://dl.djicdn.com/downloads/dji_thermal_sdk/20221108/dji_thermal_sdk_v1.4_20220929.zip