#!/usr/bin/env python3
'''
script to build a html file showing flash free for current builds
AP_FLAKE8_CLEAN
'''
import os
import argparse
import fnmatch
import json
from datetime import datetime
parser = argparse.ArgumentParser(description='create builds.html for list of builds')
parser.add_argument('basedir', default=None, help='base directory (binaries directory)')
parser.add_argument('--outfile', default="builds.html", help='output file')
build_dirs = ['latest', 'beta', 'stable']
builds = ['Plane', 'Copter', 'Rover', 'Sub', 'Blimp', 'AntennaTracker', 'AP_Periph']
args = parser.parse_args()
warning_flash_free = 5000
warning_build_days = 3
class APJInfo:
def __init__(self, vehicle, board, githash, mtime, flash_free):
self.vehicle = vehicle
self.board = board
self.githash = githash
self.mtime = mtime
self.flash_free = flash_free
self.warning = 0
def apj_list(basedir):
'''list of APJInfo for one directory'''
boards = []
for root, subdirs, files in os.walk(basedir):
for f in files:
if not fnmatch.fnmatch(f, "*.apj"):
continue
fname = os.path.join(root, f)
board = os.path.basename(root)
vehicle = fname.split('/')[-4]
fw_json = json.load(open(fname, "r"))
githash = fw_json['git_identity']
flash_free = fw_json.get('flash_free', -1)
mtime = os.stat(fname).st_mtime
apjinfo = APJInfo(vehicle, board, githash, mtime, flash_free)
boards.append(apjinfo)
return boards
def write_headers(h):
'''write html headers'''
h.write('''
Build List
Build List
This is an auto-generated list of current builds
allowing us to quickly see how close we are to running out of flash space.
This page was most recently regenerated on %s UTC.
Builds that are coloured red haven't built recently. Builds that are coloured yellow have low flash space remaining.
Click on any column header to sort by that column, or filter by entering a search term in the box above each table.