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/gen_stable.py
Views: 1798
#!/usr/bin/env python1'''2create stable-x.y.z directories so we keep all past stable releases for users to download3'''45import os6import shutil78VEHICLES = ['AntennaTracker', 'Copter', 'Plane', 'Rover', 'Sub']910# beta directories that may contain stable builds11BETA_DIRS = ['beta-4.3']1213def make_stable(basedir, vehicle):14'''make stable version for a vehicle'''15stable_dir = os.path.join(basedir, vehicle, 'stable')16if not os.path.exists(stable_dir):17print("Missing %s" % stable_dir)18return19for b in sorted(os.listdir(stable_dir)):20if not os.path.isdir(os.path.join(stable_dir, b)):21continue22vfile = os.path.join(stable_dir, b, "firmware-version.txt")23if not os.path.exists(vfile):24print("Missing %s" % vfile)25continue26vstr = open(vfile).read()27version = vstr.split('-')[0]28new_dir_parent = os.path.join(basedir, vehicle, 'stable-%s' % version)29new_dir = os.path.join(new_dir_parent, b)30if os.path.exists(new_dir):31continue32if not os.path.exists(new_dir_parent):33os.mkdir(new_dir_parent)34print('Creating %s' % new_dir)35old_dir = os.path.join(stable_dir, b)36shutil.copytree(old_dir, new_dir)3738def make_stable_from_beta(basedir, vehicle, beta_dir):39'''make stable version from a beta with OFFICAL tag'''40beta_dir = os.path.join(basedir, vehicle, beta_dir)41if not os.path.exists(beta_dir):42return43for b in sorted(os.listdir(beta_dir)):44if not os.path.isdir(os.path.join(beta_dir, b)):45continue46vfile = os.path.join(beta_dir, b, "firmware-version.txt")47if not os.path.exists(vfile):48print("Missing %s" % vfile)49continue50vstr = open(vfile).read().strip()51a = vstr.split('-')52if len(a) != 2:53continue54version = a[0]55vtype = a[1]56#print(vfile, b, version, vtype)57if vtype != 'FIRMWARE_VERSION_TYPE_OFFICIAL':58# not a new stable59continue60new_dir_parent = os.path.join(basedir, vehicle, 'stable-%s' % version)61new_dir = os.path.join(new_dir_parent, b)62if os.path.exists(new_dir):63continue64if not os.path.exists(new_dir_parent):65os.mkdir(new_dir_parent)66print('Creating %s' % new_dir)67old_dir = os.path.join(beta_dir, b)68shutil.copytree(old_dir, new_dir)697071def make_all_stable(basedir):72'''make stable directory for all vehicles'''73for v in VEHICLES:74make_stable(basedir, v)75for b in BETA_DIRS:76make_stable_from_beta(basedir, v, b)777879if __name__ == "__main__":80import argparse81parser = argparse.ArgumentParser(description='gen_stable.py')82parser.add_argument('basedir', type=str, default="-", help='base binaries directory')83args = parser.parse_args()8485make_all_stable(args.basedir)868788