mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 07:28:29 -04:00
Tools: flake8 fixes for generate_manifest.py
This commit is contained in:
parent
9da18cd6bc
commit
0abec1e0f3
@ -9,7 +9,7 @@ import re
|
|||||||
import fnmatch
|
import fnmatch
|
||||||
|
|
||||||
FIRMWARE_TYPES = ["AntennaTracker", "Copter", "Plane", "Rover", "Sub"]
|
FIRMWARE_TYPES = ["AntennaTracker", "Copter", "Plane", "Rover", "Sub"]
|
||||||
RELEASE_TYPES = ["beta", "latest", "stable", "stable-*" ]
|
RELEASE_TYPES = ["beta", "latest", "stable", "stable-*"]
|
||||||
|
|
||||||
|
|
||||||
class Firmware():
|
class Firmware():
|
||||||
@ -92,7 +92,6 @@ class ManifestGenerator():
|
|||||||
"filepath (%s) does not contain a git sha" % (filepath,))
|
"filepath (%s) does not contain a git sha" % (filepath,))
|
||||||
return m.group("sha")
|
return m.group("sha")
|
||||||
|
|
||||||
|
|
||||||
def add_USB_IDs_PX4(self, firmware):
|
def add_USB_IDs_PX4(self, firmware):
|
||||||
'''add USB IDs to a .px4 firmware'''
|
'''add USB IDs to a .px4 firmware'''
|
||||||
url = firmware['url']
|
url = firmware['url']
|
||||||
@ -121,11 +120,11 @@ class ManifestGenerator():
|
|||||||
if not os.path.exists(apj_path):
|
if not os.path.exists(apj_path):
|
||||||
print("bad apj path %s" % apj_path, file=sys.stderr)
|
print("bad apj path %s" % apj_path, file=sys.stderr)
|
||||||
return
|
return
|
||||||
apj_json = json.load(open(apj_path,'r'))
|
apj_json = json.load(open(apj_path, 'r'))
|
||||||
if not 'board_id' in apj_json:
|
if 'board_id' not in apj_json:
|
||||||
print("no board_id in %s" % apj_path, file=sys.stderr)
|
print("no board_id in %s" % apj_path, file=sys.stderr)
|
||||||
return
|
return
|
||||||
if not 'platform' in firmware:
|
if 'platform' not in firmware:
|
||||||
print("no platform for %s" % apj_path, file=sys.stderr)
|
print("no platform for %s" % apj_path, file=sys.stderr)
|
||||||
return
|
return
|
||||||
board_id = apj_json['board_id']
|
board_id = apj_json['board_id']
|
||||||
@ -138,18 +137,18 @@ class ManifestGenerator():
|
|||||||
|
|
||||||
# map of vendor specific USB IDs
|
# map of vendor specific USB IDs
|
||||||
USBID_MAP = {
|
USBID_MAP = {
|
||||||
'CubeBlack' : ['0x2DAE/0x1011'],
|
'CubeBlack': ['0x2DAE/0x1011'],
|
||||||
'CubeOrange': ['0x2DAE/0x1016'],
|
'CubeOrange': ['0x2DAE/0x1016'],
|
||||||
'CubePurple': ['0x2DAE/0x1005'],
|
'CubePurple': ['0x2DAE/0x1005'],
|
||||||
'CubeYellow': ['0x2DAE/0x1002'],
|
'CubeYellow': ['0x2DAE/0x1002'],
|
||||||
'Pixhawk4' : ['0x3162/0x0047'],
|
'Pixhawk4': ['0x3162/0x0047'],
|
||||||
'PH4-mini' : ['0x3162/0x0049'],
|
'PH4-mini': ['0x3162/0x0049'],
|
||||||
'Pixhawk6' : ['0x3162/0x004B'],
|
'Pixhawk6': ['0x3162/0x004B'],
|
||||||
'VRBrain-v51':['0x27AC/0x1151'],
|
'VRBrain-v51': ['0x27AC/0x1151'],
|
||||||
'VRBrain-v52':['0x27AC/0x1152'],
|
'VRBrain-v52': ['0x27AC/0x1152'],
|
||||||
'VRBrain-v54':['0x27AC/0x1154'],
|
'VRBrain-v54': ['0x27AC/0x1154'],
|
||||||
'VRCore-v10': ['0x27AC/0x1910'],
|
'VRCore-v10': ['0x27AC/0x1910'],
|
||||||
'VRUBrain-v51':['0x27AC/0x1351']
|
'VRUBrain-v51': ['0x27AC/0x1351']
|
||||||
}
|
}
|
||||||
if platform in USBID_MAP:
|
if platform in USBID_MAP:
|
||||||
firmware['USBID'] = USBID_MAP[platform]
|
firmware['USBID'] = USBID_MAP[platform]
|
||||||
@ -182,8 +181,6 @@ class ManifestGenerator():
|
|||||||
firmware['bootloader_str'].append('MindPX BL FMU v2.x')
|
firmware['bootloader_str'].append('MindPX BL FMU v2.x')
|
||||||
firmware['USBID'].append('0x26AC/0x0030')
|
firmware['USBID'].append('0x26AC/0x0030')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_USB_IDs(self, firmware):
|
def add_USB_IDs(self, firmware):
|
||||||
'''add USB IDs to a firmware'''
|
'''add USB IDs to a firmware'''
|
||||||
fmt = firmware['format']
|
fmt = firmware['format']
|
||||||
@ -194,8 +191,6 @@ class ManifestGenerator():
|
|||||||
self.add_USB_IDs_ChibiOS(firmware)
|
self.add_USB_IDs_ChibiOS(firmware)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_firmware_data_from_dir(self,
|
def add_firmware_data_from_dir(self,
|
||||||
dir,
|
dir,
|
||||||
firmware_data,
|
firmware_data,
|
||||||
@ -217,7 +212,7 @@ class ManifestGenerator():
|
|||||||
try:
|
try:
|
||||||
git_sha = self.git_sha_from_git_version(
|
git_sha = self.git_sha_from_git_version(
|
||||||
os.path.join(some_dir, "git-version.txt"))
|
os.path.join(some_dir, "git-version.txt"))
|
||||||
except Exception as e:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
firmware_version_file = os.path.join(some_dir,
|
firmware_version_file = os.path.join(some_dir,
|
||||||
"firmware-version.txt")
|
"firmware-version.txt")
|
||||||
@ -225,11 +220,11 @@ class ManifestGenerator():
|
|||||||
firmware_version = open(firmware_version_file).read()
|
firmware_version = open(firmware_version_file).read()
|
||||||
firmware_version = firmware_version.strip()
|
firmware_version = firmware_version.strip()
|
||||||
(version_numbers, release_type) = firmware_version.split("-")
|
(version_numbers, release_type) = firmware_version.split("-")
|
||||||
except ValueError as e:
|
except ValueError:
|
||||||
# print("malformed firmware-version.txt at (%s)" %
|
# print("malformed firmware-version.txt at (%s)" %
|
||||||
# (firmware_version_file,), file=sys.stderr)
|
# (firmware_version_file,), file=sys.stderr)
|
||||||
firmware_version = None
|
firmware_version = None
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# this exception is swallowed.... the current archive
|
# this exception is swallowed.... the current archive
|
||||||
# is incomplete.
|
# is incomplete.
|
||||||
firmware_version = None
|
firmware_version = None
|
||||||
@ -324,7 +319,7 @@ class ManifestGenerator():
|
|||||||
else:
|
else:
|
||||||
return [xfirmwares]
|
return [xfirmwares]
|
||||||
|
|
||||||
def check_release_type(self, tag):
|
def valid_release_type(self, tag):
|
||||||
'''check for valid release type'''
|
'''check for valid release type'''
|
||||||
for r in RELEASE_TYPES:
|
for r in RELEASE_TYPES:
|
||||||
if fnmatch.fnmatch(tag, r):
|
if fnmatch.fnmatch(tag, r):
|
||||||
@ -370,7 +365,6 @@ class ManifestGenerator():
|
|||||||
if fulldate in ["files.html", ".makehtml"]:
|
if fulldate in ["files.html", ".makehtml"]:
|
||||||
# generated file which should be ignored
|
# generated file which should be ignored
|
||||||
continue
|
continue
|
||||||
print(fulldate, file=sys.stderr)
|
|
||||||
self.add_firmware_data_from_dir(
|
self.add_firmware_data_from_dir(
|
||||||
os.path.join(year_month_path, fulldate),
|
os.path.join(year_month_path, fulldate),
|
||||||
xfirmwares,
|
xfirmwares,
|
||||||
@ -380,7 +374,7 @@ class ManifestGenerator():
|
|||||||
# "beta", or the "latest" directory (treated as a
|
# "beta", or the "latest" directory (treated as a
|
||||||
# release and handled specially later)
|
# release and handled specially later)
|
||||||
tag = firstlevel
|
tag = firstlevel
|
||||||
if not self.check_release_type(tag):
|
if not self.valid_release_type(tag):
|
||||||
print("Unknown tag (%s) in directory (%s)" %
|
print("Unknown tag (%s) in directory (%s)" %
|
||||||
(tag, os.path.join(vdir)), file=sys.stderr)
|
(tag, os.path.join(vdir)), file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
@ -463,6 +457,6 @@ if __name__ == "__main__":
|
|||||||
if args.outfile is None:
|
if args.outfile is None:
|
||||||
print(generator.json())
|
print(generator.json())
|
||||||
else:
|
else:
|
||||||
f = open(args.outfile,"w")
|
f = open(args.outfile, "w")
|
||||||
f.write(generator.json())
|
f.write(generator.json())
|
||||||
f.close()
|
f.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user