<commit_before>#!/usr/bin/env python3

import argparse

NODE_LIBS = ["RF24Mesh", "SipHash"]
MASTER_LIBS = ["RF24Mesh"]


def install(args):
    pass


def init(args):
    pass


def libs(args):
    pass


def build(args):
    pass


def upload(args):
    pass


parser = argparse.ArgumentParser(description="handle firmware")
subparsers = parser.add_subparsers(help="Available commands")

install_parser = subparsers.add_parser("install", help="Install PlatformIO")
install_parser.set_default(install)

init_parser = subparsers.add_parser("init", help="Initialize Projects")
init_parser.set_default(init)

libs_parser = subparsers.add_parser("libs", help="Handle embedded librraies")
libs_parser.set_default(libs)

build_parser = subparsers.add_parser("build", help="Build firmware")
build_parser.set_default(build)

upload_parser = subparsers.add_parser("upload", help="Upload firmware to controller")
upload_parser.set_default(upload)


if __name__ == "__main__":
    args = parser.parse_args()
    args.func(args)
<commit_msg>Make firmware script a bit more useful<commit_after>#!/usr/bin/env python

import os
import sys
import argparse
import subprocess


PROJECTS = {"master_firmware": ["RF24Mesh"],
            "node_firmware": ["RF24Mesh", "SipHash"]}


def install(args):
    subprocess.call(["pip", "install", "--upgrade", "platformio"])


def init(args):
    pass


def libs(args):
    for proj in PROJECTS:
        print("\nProject: {}".format(proj))
        if args.action == "install":
            for lib in PROJECTS[proj]:
                subprocess.call(["platformio", "lib", "install", lib],
                        cwd=os.path.join("firmware", proj))
        else:
            subprocess.call(["platformio", "lib", "list"],
                    cwd=os.path.join("firmware", proj))
        print("\n")


def build(args):
    for proj in PROJECTS:
        print("\nProject: {}".format(proj))
        subprocess.call(["platformio", "run"],
                cwd=os.path.join("firmware", proj))


def upload(args):
    pass


parser = argparse.ArgumentParser(description="handle firmware")
subparsers = parser.add_subparsers(help="Available commands")

install_parser = subparsers.add_parser("install", help="Install/Upgrad/Upgradee PlatformIO")
install_parser.set_defaults(func=install)

init_parser = subparsers.add_parser("init", help="Initialize Projects")
init_parser.set_defaults(func=init)

libs_parser = subparsers.add_parser("libs", help="Handle embedded librraies")
libs_parser.add_argument("action", help="What to do", choices=["list", "install"], default="list")
libs_parser.set_defaults(func=libs)

build_parser = subparsers.add_parser("build", help="Build firmware")
build_parser.set_defaults(func=build)

upload_parser = subparsers.add_parser("upload", help="Upload firmware to controller")
upload_parser.set_defaults(func=upload)


if __name__ == "__main__":
    args = parser.parse_args()
    args.func(args)

{'fraction_non_alphanumeric': 0.14023144996596323, 'fraction_numerical': 0.0030633083730428863, 'mean_word_length': 4.630268199233717, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4278470', 'n_tokens_mistral': 975, 'n_tokens_neox': 923, 'n_words': 185}