Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/scripts/check_firmware_version.py
Views: 1798
#!/usr/bin/env python1'''2check firmware-version.txt in binaries directory3'''45import os67VEHICLES = ['AntennaTracker', 'Copter', 'Plane', 'Rover', 'Sub']89def parse_git_version(gfile):10'''parse git-version.txt, producing a firmware-version.txt'''11gv = open(gfile).readlines()12vline = gv[-1]13if not vline.startswith("APMVERSION:"):14print("Bad version %s in %s" % (vline, gfile))15return None16vline = vline[11:]17a = vline.split('V')18if len(a) != 2:19return None20vers = a[1].strip()21if vers[-1].isdigit():22return vers+"-FIRMWARE_VERSION_TYPE_OFFICIAL"23print("Bad vers %s in %s" % (vers, gfile))24return None2526def check_fw_version(version):27try:28(version_numbers, release_type) = version.split("-")29(_, _, _) = version_numbers.split(".")30except Exception:31return False32return True3334def check_version(vehicle):35'''check firmware-version.txt version for a vehicle'''36for d in os.listdir(vehicle):37if not d.startswith("stable"):38continue39stable_dir = '%s/%s' % (vehicle, d)40for b in sorted(os.listdir(stable_dir)):41if not os.path.isdir(os.path.join(stable_dir, b)):42continue43vfile = os.path.join(stable_dir, b, "firmware-version.txt")44if os.path.exists(vfile):45v = open(vfile).read()46if check_fw_version(v):47continue48gfile = os.path.join(stable_dir, b, "git-version.txt")49if not os.path.exists(gfile):50print("Missing %s" % gfile)51continue52v = parse_git_version(gfile)53if v is not None:54open(vfile, "w").write(v)55print("Added %s" % vfile)56continue57print("Failed for %s" % gfile)5859if __name__ == "__main__":60import argparse61parser = argparse.ArgumentParser(description='check_firmware_version.py')6263args = parser.parse_args()6465for v in VEHICLES:66check_version(v)676869