Skip to content

Commit

Permalink
[SHA] Store the SHA of a successful airframe test
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter committed Oct 19, 2017
1 parent 2bc7e0d commit 6ae0b63
Show file tree
Hide file tree
Showing 5 changed files with 463 additions and 6 deletions.
15 changes: 13 additions & 2 deletions conf/airframes/TUDELFT/tudelft_conf.xml
Expand Up @@ -152,6 +152,7 @@
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/gps_ubx_ucenter.xml modules/logger_sd_spi_direct.xml modules/temp_adc.xml modules/air_data.xml modules/geo_mag.xml modules/opa_controller.xml modules/ahrs_int_cmpl_quat.xml modules/stabilization_rate.xml modules/stabilization_int_quat.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps.xml modules/imu_common.xml"
gui_color="#ffffdffac31f"
release="dc8a90d35290784bcc817edff08d8da2df64bcef"
/>
<aircraft
name="Disco"
Expand All @@ -163,6 +164,7 @@
settings="settings/fixedwing_basic.xml"
settings_modules="modules/nav_basic_fw.xml modules/guidance_full_pid_fw.xml modules/stabilization_adaptive_fw.xml modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/gps_ubx_ucenter.xml modules/gps.xml modules/ahrs_float_dcm.xml modules/imu_common.xml"
gui_color="blue"
release="dfba3220f5b3500611231d02fca8799f9f045cb8"
/>
<aircraft
name="Flappy"
Expand All @@ -174,6 +176,7 @@
settings=""
settings_modules="modules/air_data.xml modules/ahrs_int_cmpl_quat.xml modules/stabilization_int_quat.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps.xml modules/imu_common.xml"
gui_color="white"
release="65aa9a711dc4a66ed2d7cf73c0f5872bbeeb821d"
/>
<aircraft
name="GeniusDD"
Expand Down Expand Up @@ -229,6 +232,7 @@
settings="settings/rotorcraft_basic.xml"
settings_modules="[modules/air_data.xml] modules/geo_mag.xml modules/ins_extended.xml modules/ahrs_int_cmpl_quat.xml modules/stabilization_indi_simple.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps_ubx_ucenter.xml modules/gps.xml modules/imu_common.xml"
gui_color="#ffffcccaccca"
release="433c2150022275f26fb4619e536903676d7e2c9e"
/>
<aircraft
name="LadybirdMXS"
Expand All @@ -251,6 +255,7 @@
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/geo_mag.xml modules/ahrs_int_cmpl_quat.xml modules/stabilization_int_quat.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps_ubx_ucenter.xml modules/gps.xml modules/imu_common.xml"
gui_color="#ffffdffac31f"
release="0fba1ce80a46d8dce23c570e6547595c89988fad"
/>
<aircraft
name="MAVTec1_Kirk"
Expand All @@ -262,6 +267,7 @@
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/geo_mag.xml modules/ahrs_int_cmpl_quat.xml modules/stabilization_indi_simple.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps.xml modules/imu_common.xml"
gui_color="#ffff00000000"
release="e688107d8a1f9c933cb0931eebb0e7b009ccc445"
/>
<aircraft
name="MAVTec3_Chris"
Expand All @@ -271,8 +277,9 @@
telemetry="telemetry/default_rotorcraft.xml"
flight_plan="flight_plans/TUDELFT/tudelft_rotorcraft_survey_imav2015_competition.xml"
settings="settings/rotorcraft_basic.xml settings/modules/config_asctec_v2.xml"
settings_modules="[modules/geo_mag.xml] [modules/nav_survey_poly_rotorcraft.xml] [modules/nav_survey_rectangle_rotorcraft.xml] modules/gps_ubx_ucenter.xml modules/switch_servo.xml modules/ahrs_float_mlkf.xml modules/stabilization_int_quat.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps.xml modules/imu_common.xml"
gui_color="#ffffd5c5aead"
settings_modules="modules/geo_mag.xml modules/nav_survey_poly_rotorcraft.xml modules/nav_survey_rectangle_rotorcraft.xml modules/gps_ubx_ucenter.xml modules/switch_servo.xml modules/ahrs_float_mlkf.xml modules/stabilization_int_quat.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps.xml modules/imu_common.xml"
gui_color="blue"
release="2a6ad556f183875fa9fb8072d774beec7ba55701"
/>
<aircraft
name="MAVTec4_Bart"
Expand Down Expand Up @@ -317,6 +324,7 @@
settings="settings/fixedwing_basic.xml settings/estimation/ac_char.xml"
settings_modules="modules/digital_cam.xml modules/light.xml modules/gps_ubx_ucenter.xml modules/geo_mag.xml modules/air_data.xml modules/gps.xml modules/nav_basic_fw.xml modules/guidance_energy.xml modules/stabilization_attitude_fw.xml modules/ahrs_int_cmpl_quat.xml modules/imu_common.xml"
gui_color="white"
release="997fa535902c4d8f73bc34c02c862652cd47cae5"
/>
<aircraft
name="Quad_Navstik"
Expand Down Expand Up @@ -350,6 +358,7 @@
settings="settings/rotorcraft_basic.xml ../conf/modules/px4_flash.xml ../conf/modules/glide_wing_lock.xml"
settings_modules="[modules/air_data.xml] modules/geo_mag.xml modules/ins_extended.xml modules/ahrs_int_cmpl_quat.xml modules/stabilization_indi_simple.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/gps_ubx_ucenter.xml modules/gps.xml modules/imu_common.xml"
gui_color="#ffffcccaccca"
release=""
/>
<aircraft
name="SkyWalker"
Expand All @@ -361,6 +370,7 @@
settings="settings/fixedwing_basic.xml settings/estimation/ins_neutrals.xml settings/control/tune_agr_climb.xml"
settings_modules="modules/digital_cam.xml modules/light.xml modules/gps.xml modules/nav_basic_fw.xml modules/guidance_basic_fw.xml modules/stabilization_attitude_fw.xml"
gui_color="#b748fe64fe64"
release="7cf84458f9e2c7273215dfab122792d5e5813304"
/>
<aircraft
name="Splash"
Expand Down Expand Up @@ -537,5 +547,6 @@
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/gps.xml modules/ahrs_float_cmpl_quat.xml modules/stabilization_indi_simple.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/air_data.xml modules/gps_ubx_ucenter.xml modules/guidance_hybrid.xml"
gui_color="#ffffcccaccca"
release="2a6ad556f183875fa9fb8072d774beec7ba55701"
/>
</conf>
246 changes: 246 additions & 0 deletions report.py
@@ -0,0 +1,246 @@
#!/usr/bin/env python

from __future__ import print_function

import webbrowser
import os
import shutil
import datetime
from fnmatch import fnmatch
import subprocess
PIPE = subprocess.PIPE



import xml.etree.ElementTree

class Airframe:
name = ""
id = ""
xml = ""
flight_plan = ""
release = ""
def __init__(self):
name = ""
ac_id = ""
xml = ""
flight_plan = ""
release = ""

class AirframeFile:
name = ""
firmware = []
boards = []
xml = ""
includes = []
def __init__(self):
name = ""
firmware = []
boards = []
xml = ""
includes = []

class PaparazziOverview(object):

def RepresentsInt(self, s):
try:
v=int(s)
return v
except ValueError:
return -1

def git_behind(self, sha):
process = subprocess.Popen(['git', 'rev-list', sha+"..HEAD", '--count'], stdout=PIPE, stderr=PIPE)
stdoutput, stderroutput = process.communicate()
return self.RepresentsInt(stdoutput)

def git_ahead(self, sha):
process = subprocess.Popen(['git', 'rev-list', "HEAD.."+sha, '--count'], stdout=PIPE, stderr=PIPE)
stdoutput, stderroutput = process.communicate()
return self.RepresentsInt(stdoutput)

def gif_last_commit(self, file):
process = subprocess.Popen(['git', 'log', '-n', 1, '--pretty=format:%H', '--', sha+"..HEAD"], stdout=PIPE, stderr=PIPE)
stdoutput, stderroutput = process.communicate()
return stdoutput

def find_conf_files(self):
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 path, subdirs, files in os.walk(self.conf_dir):
for name in files:
if self.exclude_backups and fnmatch(name, backup_pattern):
continue
if fnmatch(name, pattern):
filepath = os.path.join(path, name)
entry = os.path.relpath(filepath, self.conf_dir)
if not os.path.islink(filepath) and entry not in excludes:
conf_files.append(entry)
conf_files.sort()
return conf_files

def find_xml_files(self, folder):
airframe_files = []
pattern = "*.xml"
confn = "*conf[._-]*xml"
controlpanel = "*control_panel[._-]*xml"

for path, subdirs, files in os.walk(os.path.join(self.conf_dir,folder)):
for name in files:
if fnmatch(name, confn):
continue
if fnmatch(name, controlpanel):
continue
if fnmatch(name, pattern):
filepath = os.path.join(path, name)
entry = os.path.relpath(filepath, self.conf_dir)
airframe_files.append(entry)
airframe_files.sort()
return airframe_files

def find_airframe_files(self):
return self.find_xml_files('airframes/')

def find_flightplan_files(self):
return self.find_xml_files('flight_plans/')

def list_airframes_in_conf(self, conf):
if conf is None:
return []
list_of_airframes = []

afile = os.path.join(self.conf_dir, conf)
if os.path.exists(afile):
e = xml.etree.ElementTree.parse(afile).getroot()
for atype in e.findall('aircraft'):
release = ""
if (not atype.get('release') is None) & (not atype.get('release') == ""):
release = atype.get('release')
af = Airframe()
af.name = atype.get('name')
af.ac_id = atype.get('ac_id')
af.xml = atype.get('airframe')
af.flight_plan = atype.get('flight_plan')
af.release = release
list_of_airframes.append(af)
return list_of_airframes

def airframe_details(self, xmlname):
airframe = AirframeFile()
airframe.xml = xmlname
airframe.firmware = []
airframe.includes = []
airframe.board = []
if xml is None:
return airframe
afile = os.path.join(self.conf_dir, xmlname)
if os.path.exists(afile):
e = xml.etree.ElementTree.parse(afile).getroot()
for atype in e.findall('firmware'):
if (not atype.get('name') is None) & (not atype.get('name') == "") & (not atype.get('name') in airframe.firmware):
airframe.firmware.append(atype.get('name'))
for btype in atype.findall('target'):
if (not btype.get('board') is None) & (not btype.get('board') == "") & (not btype.get('board') in airframe.board):
airframe.board.append( btype.get('board') )
for atype in e.findall('include'):
if (not atype.get('href') is None) & (not atype.get('href') == ""):
airframe.includes.append( atype.get('href') )
return airframe

def flightplan_includes(self, xmlname):
includes = []
print(xmlname)
if xml is None:
return includes
afile = os.path.join(self.conf_dir, xmlname)
if os.path.exists(afile):
e = xml.etree.ElementTree.parse(afile).getroot()
for atype in e.findall('include'):
if (not atype.get('procedure') is None) & (not atype.get('procedure') == ""):
includes.append( atype.get('procedure') )
return includes


# Constructor Functions
def __init__(self, verbose):
# if PAPARAZZI_HOME not set, then assume the tree containing this
# file is a reasonable substitute
self.paparazzi_home = os.getenv("PAPARAZZI_HOME", os.path.dirname(os.path.abspath(__file__)))
self.conf_dir = os.path.join(self.paparazzi_home, "conf")
self.exclude_backups = 1
self.verbose = verbose

def run(self):
# find all airframe XML's
afs = self.find_airframe_files()
fps = self.find_flightplan_files()
#brds = self.find_boards()
# write all confs
with open('paparazzi.html','w') as f:
f.write('<!DOCTYPE html>\n<html lang="en">\n<head>\n<title>Paparazzi</title>\n<meta charset="utf-8"/>\n<meta http-equiv="Cache-Control" content="no-cache" />\n')
f.write('<style>\n.conf {\n\tfloat: left;\n\tmargin: 10px;\n\tpadding: 5px;\n}\n\n.uav {\n\tfloat: left;\n\tmargin: 10px;\n\tpadding: 5px;\n\twidth: 250px;\n\tborder: 1px solid black;\n\tbackground-color:#fef9e7;\n}\n</style>\n\n</head>\n')
f.write('<body>\n')
conf_files = self.find_conf_files()
for conf in conf_files:
airframes = self.list_airframes_in_conf(conf)
f.write('<div class="conf"><h2>' + conf + '</h2>')
for ac in airframes:
f.write('<div class="uav" title="'+ ac.name + ': ' + ac.xml +'"><h4>' + ac.name + ' (' + ac.ac_id + ')</h4 >')
sha = ac.release
xml = ac.xml
name = ac.name
# remove airframe xml from list
if xml in afs:
afs.remove(xml)
if ac.flight_plan in fps:
fps.remove(ac.flight_plan)
if (not sha is None) and (not sha == ""):
f.write('<p>Last flown with <a href="https://github.com/paparazzi/paparazzi/commit/' + sha + '">' + sha[:6] + '...</a></p>')
behind = self.git_behind(sha)
color = 'orange'
if behind < 200:
color = 'green'
if behind > 2000:
color = 'red'
f.write( '<p><font color="' + color + '">Is <b>' + str(behind) + '</b> commits behind</font></p>')
outside = self.git_ahead(sha)
if outside > 0:
f.write( '<p><font color="red">Using <b>' + str(outside) + '</b> commits not in master</font></p>')
af = self.airframe_details(xml)
f.write('<p>' + ", ".join(af.firmware) + ' on ' + ", ".join(af.board) + '</p>')
if self.verbose:
f.write('<p><a href="https://github.com/paparazzi/paparazzi/blob/master/conf/' + ac.xml + '"/>' + ac.xml + '</a></p>')
if self.verbose:
f.write('<p><a href="https://github.com/paparazzi/paparazzi/blob/master/conf/' + ac.flight_plan + '"/>' + ac.flight_plan + '</a></p>')
#fp_inc = self.flightplan_includes(ac.flight_plan)
if len(af.includes) > 0:
for i in af.includes:
inc_name = i[5:].replace('$AC_ID',ac.ac_id)
if inc_name in afs:
afs.remove(inc_name)
if self.verbose:
f.write('<p>Includes: ' + ", ".join(af.includes) + '</p>')
f.write('</div>\n\n')
f.write('</div>\n')
f.write('<hr><div class="conf"><h1>Airframe xml that are not tested by any conf:</h1>')
for af in afs:
f.write('<li>' + af)
f.write('</div><div class="conf"><h1>Flight_plan xml that are not tested by any conf:</h1>')
for af in fps:
f.write('<li>' + af)

f.write('</div></body>\n</html>\n')

if __name__ == "__main__":
import sys
brief = 0
if len(sys.argv) > 1:
brief = 1

obj = PaparazziOverview(brief)
obj.run()
webbrowser.open('file://' + os.path.realpath('./paparazzi.html'))

0 comments on commit 6ae0b63

Please sign in to comment.