Add TactilityFreeRtos to TactilitySDK (#441)
- TactlitySDK updates fro TactilityFreeRtos - Enable auto-uploading of SDKs to the CDN when merging code
This commit is contained in:
committed by
GitHub
parent
7283920def
commit
524b197105
@@ -45,14 +45,9 @@ class DeviceIndex:
|
||||
gitCommit: str
|
||||
devices: list
|
||||
|
||||
if sys.platform == "win32":
|
||||
shell_color_red = ""
|
||||
shell_color_orange = ""
|
||||
shell_color_reset = ""
|
||||
else:
|
||||
shell_color_red = "\033[91m"
|
||||
shell_color_orange = "\033[93m"
|
||||
shell_color_reset = "\033[m"
|
||||
shell_color_red = "\033[91m"
|
||||
shell_color_orange = "\033[93m"
|
||||
shell_color_reset = "\033[m"
|
||||
|
||||
def print_warning(message):
|
||||
print(f"{shell_color_orange}WARNING: {message}{shell_color_reset}")
|
||||
@@ -61,7 +56,7 @@ def print_error(message):
|
||||
print(f"{shell_color_red}ERROR: {message}{shell_color_reset}")
|
||||
|
||||
def print_help():
|
||||
print("Usage: python generate-files.py [inPath] [outPath] [version]")
|
||||
print("Usage: python generate-firmware-files.py [inPath] [outPath] [version]")
|
||||
print(" inPath path with the extracted release files")
|
||||
print(" outPath path where the CDN files will become available")
|
||||
print(" version technical version name (e.g. 1.2.0)")
|
||||
@@ -228,7 +223,7 @@ if __name__ == "__main__":
|
||||
# Argument validation
|
||||
if len(sys.argv) < 4:
|
||||
print_help()
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
if "--verbose" in sys.argv:
|
||||
VERBOSE = True
|
||||
sys.argv.remove("--verbose")
|
||||
@@ -0,0 +1,86 @@
|
||||
import subprocess
|
||||
from datetime import datetime, UTC
|
||||
import os
|
||||
import sys
|
||||
from dataclasses import dataclass, asdict
|
||||
import json
|
||||
import shutil
|
||||
|
||||
VERBOSE = False
|
||||
|
||||
@dataclass
|
||||
class SdkIndex:
|
||||
version: str
|
||||
created: str
|
||||
gitCommit: str
|
||||
platforms: dict
|
||||
|
||||
shell_color_red = "\033[91m"
|
||||
shell_color_orange = "\033[93m"
|
||||
shell_color_reset = "\033[m"
|
||||
|
||||
def print_warning(message):
|
||||
print(f"{shell_color_orange}WARNING: {message}{shell_color_reset}")
|
||||
|
||||
def print_error(message):
|
||||
print(f"{shell_color_red}ERROR: {message}{shell_color_reset}")
|
||||
|
||||
def exit_with_error(message):
|
||||
print_error(message)
|
||||
sys.exit(1)
|
||||
|
||||
def print_help():
|
||||
print("Usage: python generate-sdk-files.py [inPath] [outPath] [version]")
|
||||
print(" inPath path with the extracted release files")
|
||||
print(" outPath path where the CDN files will become available")
|
||||
print(" version technical version name (e.g. 1.2.0)")
|
||||
print("Options:")
|
||||
print(" --verbose Show extra console output")
|
||||
|
||||
def get_git_commit_hash():
|
||||
return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
|
||||
|
||||
def main(in_path: str, out_path: str, version: str):
|
||||
if not os.path.exists(in_path):
|
||||
exit_with_error(f"Input path not found: {in_path}")
|
||||
if os.path.exists(out_path):
|
||||
shutil.rmtree(out_path)
|
||||
os.mkdir(out_path)
|
||||
artifact_directories = os.listdir(in_path)
|
||||
sdk_index = SdkIndex(
|
||||
version=version,
|
||||
created=datetime.now(UTC).strftime('%Y-%m-%dT%H:%M:%S'),
|
||||
gitCommit=get_git_commit_hash(),
|
||||
platforms={}
|
||||
)
|
||||
for artifact_directory in artifact_directories:
|
||||
if VERBOSE:
|
||||
print(f"Processing {in_path}/{artifact_directory}")
|
||||
if not artifact_directory.startswith("TactilitySDK-"):
|
||||
continue
|
||||
sdk_platform = artifact_directory.removeprefix("TactilitySDK-")
|
||||
if not sdk_platform:
|
||||
exit_with_error(f"Cannot derive platform from directory name: {artifact_directory}")
|
||||
sdk_index.platforms[sdk_platform] = f"{artifact_directory}.zip"
|
||||
if VERBOSE:
|
||||
print(f"Archiving {in_path}/{artifact_directory} to {out_path}/{artifact_directory}.zip")
|
||||
shutil.make_archive(os.path.join(out_path, artifact_directory), 'zip', os.path.join(in_path, artifact_directory))
|
||||
index_file_path = os.path.join(out_path, "index.json")
|
||||
if VERBOSE:
|
||||
print(f"Generating {index_file_path}")
|
||||
with open(index_file_path, "w") as index_file:
|
||||
json.dump(asdict(sdk_index), index_file, indent=2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Tactility CDN SDK File Generator")
|
||||
if "--help" in sys.argv:
|
||||
print_help()
|
||||
sys.exit()
|
||||
# Argument validation
|
||||
if len(sys.argv) < 4:
|
||||
print_help()
|
||||
sys.exit(1)
|
||||
if "--verbose" in sys.argv:
|
||||
VERBOSE = True
|
||||
sys.argv.remove("--verbose")
|
||||
main(in_path=sys.argv[1], out_path=sys.argv[2], version=sys.argv[3])
|
||||
@@ -2,14 +2,9 @@ import os
|
||||
import sys
|
||||
import boto3
|
||||
|
||||
if sys.platform == "win32":
|
||||
SHELL_COLOR_RED = ""
|
||||
SHELL_COLOR_ORANGE = ""
|
||||
SHELL_COLOR_RESET = ""
|
||||
else:
|
||||
SHELL_COLOR_RED = "\033[91m"
|
||||
SHELL_COLOR_ORANGE = "\033[93m"
|
||||
SHELL_COLOR_RESET = "\033[m"
|
||||
SHELL_COLOR_RED = "\033[91m"
|
||||
SHELL_COLOR_ORANGE = "\033[93m"
|
||||
SHELL_COLOR_RESET = "\033[m"
|
||||
|
||||
def print_warning(message):
|
||||
print(f"{SHELL_COLOR_ORANGE}WARNING: {message}{SHELL_COLOR_RESET}")
|
||||
@@ -18,7 +13,7 @@ def print_error(message):
|
||||
print(f"{SHELL_COLOR_RED}ERROR: {message}{SHELL_COLOR_RESET}")
|
||||
|
||||
def print_help():
|
||||
print("Usage: python upload-files.py [path] [version] [cloudflareAccountId] [cloudflareTokenName] [cloudflareTokenValue]")
|
||||
print("Usage: python upload-firmware-files.py [path] [version] [cloudflareAccountId] [cloudflareTokenName] [cloudflareTokenValue]")
|
||||
print("")
|
||||
print("Options:")
|
||||
print(" --index-only Upload only index.json")
|
||||
@@ -52,14 +47,14 @@ def main(path: str, version: str, cloudflare_account_id, cloudflare_token_name:
|
||||
counter += 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Tactility CDN Uploader")
|
||||
print("Tactility CDN Firmware Uploader")
|
||||
if "--help" in sys.argv:
|
||||
print_help()
|
||||
sys.exit()
|
||||
# Argument validation
|
||||
if len(sys.argv) < 6:
|
||||
print_help()
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
main(
|
||||
path=sys.argv[1],
|
||||
version=sys.argv[2],
|
||||
@@ -0,0 +1,65 @@
|
||||
import os
|
||||
import sys
|
||||
import boto3
|
||||
|
||||
SHELL_COLOR_RED = "\033[91m"
|
||||
SHELL_COLOR_ORANGE = "\033[93m"
|
||||
SHELL_COLOR_RESET = "\033[m"
|
||||
|
||||
def print_warning(message):
|
||||
print(f"{SHELL_COLOR_ORANGE}WARNING: {message}{SHELL_COLOR_RESET}")
|
||||
|
||||
def print_error(message):
|
||||
print(f"{SHELL_COLOR_RED}ERROR: {message}{SHELL_COLOR_RESET}")
|
||||
|
||||
def print_help():
|
||||
print("Usage: python upload-sdk-files.py [path] [version] [cloudflareAccountId] [cloudflareTokenName] [cloudflareTokenValue]")
|
||||
print("")
|
||||
print("Options:")
|
||||
print(" --index-only Upload only index.json")
|
||||
|
||||
def exit_with_error(message):
|
||||
print_error(message)
|
||||
sys.exit(1)
|
||||
|
||||
def main(path: str, version: str, cloudflare_account_id, cloudflare_token_name: str, cloudflare_token_value: str, index_only: bool):
|
||||
if not os.path.exists(path):
|
||||
exit_with_error(f"Path not found: {path}")
|
||||
s3 = boto3.client(
|
||||
service_name="s3",
|
||||
endpoint_url=f"https://{cloudflare_account_id}.r2.cloudflarestorage.com",
|
||||
aws_access_key_id=cloudflare_token_name,
|
||||
aws_secret_access_key=cloudflare_token_value,
|
||||
region_name="auto"
|
||||
)
|
||||
files_to_upload = os.listdir(path)
|
||||
counter = 1
|
||||
total = len(files_to_upload)
|
||||
for file_name in files_to_upload:
|
||||
if not index_only or file_name == 'index.json':
|
||||
object_path = f"sdk/{version}/{file_name}"
|
||||
print(f"[{counter}/{total}] Uploading {file_name} to {object_path}")
|
||||
file_path = os.path.join(path, file_name)
|
||||
try:
|
||||
s3.upload_file(file_path, "tactility", object_path)
|
||||
except Exception as e:
|
||||
exit_with_error(f"Failed to upload {file_name}: {str(e)}")
|
||||
counter += 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Tactility CDN SDK Uploader")
|
||||
if "--help" in sys.argv:
|
||||
print_help()
|
||||
sys.exit()
|
||||
# Argument validation
|
||||
if len(sys.argv) < 6:
|
||||
print_help()
|
||||
sys.exit(1)
|
||||
main(
|
||||
path=sys.argv[1],
|
||||
version=sys.argv[2],
|
||||
cloudflare_account_id=sys.argv[3],
|
||||
cloudflare_token_name=sys.argv[4],
|
||||
cloudflare_token_value=sys.argv[5],
|
||||
index_only="--index-only" in sys.argv
|
||||
)
|
||||
Reference in New Issue
Block a user