mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-10 23:35:45 +08:00
d23ed71ede
* Added last commit dates to lists of untested flight plans and airframes * Improved paparazzi_health to include a list of all modules and their usage * improved paparazzi_health to include a list of board makefiles not used by any airframe * improved paparazzi_health to generate list of unused airframes, flightplans and boards sorted by most recently changed * airframe details now stores modules as tuple of name and type: [(name, type), ...] * added seeing includes in paparazzi_health * Removed unneccesary print statements * Added widget to start.py to generate html table of the module usage of the airframes for the selected conf * improved html table readability and sorted airframe names alphabetically * fixed alphabetical ordering of airframe name being case sensitive and added comments * Added module class, more info about modules now gets printed. Commit dates should still be fixed * Did speed improvement, but still slow * split up more info and lists of untested files * Added checkboxes to start.py to give user option to show airframe detail, or untested files, or both * Cleaned up some code * Added separator to make link between checkboxes and MoreInfo button clearer * Fixed code style * Added description to the module listing * one should now be able to select which aspects to show in the maintenance tools * Initial version of maintenance tools window * Now also checks if modules are mentioned in the settings modules in an userconf * Improved layout of maintenance tool window * Improved variable names and tooltip information * Small QoL changes to prepare for pull request * Fixed a bug with the untested boards not showing correctly if airframes was not also selected and fixed some Codacy issues
157 lines
5.2 KiB
Python
Executable File
157 lines
5.2 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from __future__ import print_function
|
|
|
|
import glob
|
|
|
|
from collections import namedtuple
|
|
from os import path, getenv, walk
|
|
from fnmatch import fnmatch
|
|
#from subprocess import call
|
|
import commands
|
|
|
|
import lxml.etree as ET
|
|
|
|
# if PAPARAZZI_HOME not set, then assume the tree containing this
|
|
# file is a reasonable substitute
|
|
PAPARAZZI_SRC = getenv("PAPARAZZI_HOME", path.normpath(path.join(path.dirname(path.abspath(__file__)), '../../../')))
|
|
PAPARAZZI_HOME = getenv("PAPARAZZI_HOME", PAPARAZZI_SRC)
|
|
|
|
# Directories
|
|
conf_dir = path.join(PAPARAZZI_HOME, "conf/")
|
|
|
|
firmwares_dir = path.join(conf_dir, "firmwares/")
|
|
modules_dir = path.join(conf_dir, "modules/")
|
|
airframes_dir = path.join(conf_dir, "airframes/")
|
|
boards_dir = path.join(conf_dir, "boards/")
|
|
|
|
flight_plan_dir = path.join(conf_dir, "flight_plans/")
|
|
|
|
# Structures
|
|
PprzModule = namedtuple("PprzModule", "description defines configures")
|
|
|
|
# List Of Stuff
|
|
|
|
def get_list_of_conf_files(exclude_backups = 1):
|
|
conf_files = []
|
|
pattern = "*conf[._-]*xml"
|
|
backup_pattern = "*conf[._-]*xml.20[0-9][0-9]-[01][0-9]-[0-3][0-9]_*"
|
|
excludes = ["%gconf.xml"]
|
|
|
|
for cpath, subdirs, files in walk(conf_dir):
|
|
for name in files:
|
|
if exclude_backups and fnmatch(name, backup_pattern):
|
|
continue
|
|
if fnmatch(name, pattern):
|
|
filepath = path.join(cpath, name)
|
|
entry = path.relpath(filepath, conf_dir)
|
|
if not path.islink(filepath) and entry not in excludes:
|
|
conf_files.append(entry)
|
|
|
|
conf_files.sort()
|
|
return conf_files
|
|
|
|
def get_list_of_controlpanel_files(exclude_backups = 1):
|
|
controlpanel_files = []
|
|
pattern = "*control_panel[._-]*xml"
|
|
backup_pattern = "*control_panel[._-]*xml.20[0-9][0-9]-[01][0-9]-[0-3][0-9]_*"
|
|
excludes = []
|
|
|
|
for cpath, subdirs, files in walk(conf_dir):
|
|
for name in files:
|
|
if exclude_backups and fnmatch(name, backup_pattern):
|
|
continue
|
|
if fnmatch(name, pattern):
|
|
filepath = path.join(cpath, name)
|
|
entry = path.relpath(filepath, conf_dir)
|
|
if not path.islink(filepath) and entry not in excludes:
|
|
controlpanel_files.append(entry)
|
|
controlpanel_files.sort()
|
|
return controlpanel_files
|
|
|
|
|
|
|
|
def get_list_of_files(directory, extension):
|
|
mylist = glob.glob(path.join(directory, "*" + extension))
|
|
mylist.sort()
|
|
ret = []
|
|
for it in mylist:
|
|
ret.append( it.replace(directory, "").replace(extension, ""))
|
|
return ret
|
|
|
|
def get_list_of_modules():
|
|
return get_list_of_files( modules_dir, ".xml")
|
|
|
|
def get_list_of_firmwares():
|
|
return get_list_of_files( firmwares_dir, ".makefile")
|
|
|
|
def get_list_of_boards():
|
|
return get_list_of_files( boards_dir, ".makefile")
|
|
|
|
def get_list_of_subsystems(firmware):
|
|
subsys_dir = path.join( firmwares_dir, "subsystems/" + firmware + "/")
|
|
# \todo how about shared
|
|
#subsys_dir = path.join( firmwares_dir, "subsystems/shared/" )
|
|
return get_list_of_files(subsys_dir, ".makefile")
|
|
|
|
def get_list_of_flight_plan_files():
|
|
mylist = glob.glob(path.join(flight_plan_dir, "*.xml"))
|
|
mylist.sort()
|
|
return mylist
|
|
|
|
def get_list_of_servo_drivers():
|
|
# \todo where do we know this?
|
|
return ["Ppm", "Asctec", "Scilab"]
|
|
|
|
def get_module_information(module_name):
|
|
str_desc = ""
|
|
lst_def = []
|
|
lst_conf = []
|
|
try:
|
|
xml = ET.parse(path.join(modules_dir, module_name + ".xml"))
|
|
root = xml.getroot().find("doc")
|
|
str_desc = root.find("description").text
|
|
for block in root.iter("define"):
|
|
lst_def.append([block.get("name"), block.get("value"), block.get("unit"), block.get("description")])
|
|
for block in root.iter("configure"):
|
|
lst_conf.append([block.get("name"), block.get("value"), block.get("unit"), block.get("description")])
|
|
except (IOError, ET.XMLSyntaxError) as e:
|
|
print(e.__str__())
|
|
|
|
return PprzModule(description=str_desc, defines=lst_def, configures=lst_conf)
|
|
|
|
|
|
def search(string):
|
|
#return call(["grep", "-r", string , PAPARAZZI_HOME + "/sw/airborne/"])
|
|
#return system("grep -r " + string + " " + PAPARAZZI_HOME + "/sw/airborne/")
|
|
cmd = "grep -r " + string + " " + PAPARAZZI_HOME + "/sw/airborne/"
|
|
status, output = commands.getstatusoutput(cmd)
|
|
return output.replace(PAPARAZZI_HOME + "/sw/airborne/", "")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print("\nPAPARAZZI\n=========\n\nContent listing of current branch\n")
|
|
print("\nBOARDS\n------\n")
|
|
boards = get_list_of_boards()
|
|
for b in boards:
|
|
print(" - ```" + b + "```" )
|
|
print("\nFIRMWARES - SUBSYSTEMS\n---------\n")
|
|
firmwares = get_list_of_firmwares()
|
|
firmwares.append("shared")
|
|
for f in firmwares:
|
|
print(" - " + f)
|
|
subsystems = get_list_of_subsystems(f)
|
|
for s in subsystems:
|
|
print(" - ```", s, "```")
|
|
print("\nMODULES\n-------\n")
|
|
modules = get_list_of_modules()
|
|
for m in modules:
|
|
info = get_module_information(m)
|
|
d = info.description
|
|
if ((d is None) or (len(d) == 0)):
|
|
d = " "
|
|
print(" - ```" + m + "``` " + d.split('\n', 1)[0])
|
|
# for mod in get_list_of_modules():
|
|
# print(mod, " ---> ", get_module_information(mod))
|
|
|