mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 03:43:34 +08:00
Moved deployment logic to python scripts.
This commit is contained in:
committed by
Lorenz Meier
parent
50159cabbe
commit
a0fff97fd2
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import zipfile
|
||||
import os
|
||||
|
||||
FIRMWARE_FILE = 'Firmware.zip'
|
||||
|
||||
|
||||
def extract_file_only(filename, dest):
|
||||
"""
|
||||
Extract a file without keeping directories.
|
||||
"""
|
||||
# extract firmware files without paths
|
||||
f_src = archive.open(filename, 'r')
|
||||
data = f_src.read()
|
||||
dst_name = os.path.join(dest, os.path.basename(filename))
|
||||
with open(dst_name, 'w') as f_dst:
|
||||
f_dst.write(data)
|
||||
f_src.close()
|
||||
|
||||
# open destination archive
|
||||
with zipfile.ZipFile(FIRMWARE_FILE, 'w') as dest_archive:
|
||||
|
||||
# get all zip files in Packages directory
|
||||
for zip_filename in glob.glob("Packages/*.zip"):
|
||||
|
||||
# open zipfile
|
||||
with zipfile.ZipFile(zip_filename, 'r') as archive:
|
||||
|
||||
# look for interesting names
|
||||
for src_filename in archive.namelist():
|
||||
|
||||
# extract firmware files
|
||||
if os.path.splitext(src_filename)[1] == '.px4':
|
||||
base_name = os.path.basename(src_filename)
|
||||
dest_archive.writestr(base_name, archive.read(src_filename))
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import zipfile
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
S3_DIR = 's3deploy-branch'
|
||||
S3_ARCHIVE_DIR = 's3deploy-branch'
|
||||
|
||||
if not os.path.isdir(S3_DIR):
|
||||
os.mkdir(S3_DIR)
|
||||
|
||||
if not os.path.isdir(S3_ARCHIVE_DIR):
|
||||
os.mkdir(S3_ARCHIVE_DIR)
|
||||
|
||||
shutil.copyfile(Firmware.zip, S3_ARCHIVE_DIR)
|
||||
|
||||
def extract_file_only(filename, dest):
|
||||
# extract firmware files without paths
|
||||
f_src = archive.open(filename, 'r')
|
||||
data = f_src.read()
|
||||
with open(os.path.join(dest,
|
||||
os.path.basename(filename)), 'w') as f_dst:
|
||||
f_dst.write(data)
|
||||
f_src.close()
|
||||
|
||||
# get all zip files in Packages directory
|
||||
for zip_filename in glob.glob("Packages/*.zip"):
|
||||
|
||||
# open zipfile
|
||||
with zipfile.ZipFile(zip_filename, 'r') as archive:
|
||||
|
||||
# look for interesting names
|
||||
for filename in archive.namelist():
|
||||
|
||||
# extract firmware files
|
||||
if os.path.splitext(filename)[1] == '.px4':
|
||||
extract_file_only(filename, S3_DIR)
|
||||
|
||||
# copy px4fmu-v4_default xml files for qgroundcontrol
|
||||
if re.match(filename, r'.*px4fmu-v4_default.*\.xml') is not None:
|
||||
extract_file_only(filename, S3_DIR)
|
||||
Reference in New Issue
Block a user