Beispiel #1
0
def main():
    setup_logzero(logging.getLogger('spinboard'), level=logging.DEBUG)

    p = argparse.ArgumentParser()
    setup_parser(p)
    args = p.parse_args()
    run(args)
Beispiel #2
0
def add2org(
    items: Union[List[Tuple[Key, I]], Dict[Key, I]],
    output: PathIsh,
    state: PathIsh,
    logger: LoggerIsh,
    org_formatter=None,
):
    if isinstance(items, dict):
        items = list(items.items())
    assert len(set(i[0] for i in items)) == len(items), 'Duplicate keys!!'

    output = Path(output)
    json_state = JsonState(Path(state))

    if isinstance(logger, str):
        logger = logging.getLogger(logger)
        setup_logzero(logger, level=logging.DEBUG)

    for k, i in items:
        if k in json_state:
            logger.debug('already handled: %s %s', k, i)
        else:
            logger.info('adding: %s %s', k, i)
            print(
                f'adding new item {k} {i}'
            )  # print since it's easier to track changes via kron emailing. maybe It's not the best way, dunno..
            atomic_append(
                output,
                i,
            )
            json_state[k] = repr(i)
Beispiel #3
0
def main():
    logger = get_logger()
    setup_logzero(logger, level=logging.DEBUG)

    if len(sys.argv) > 1:
        cmd = sys.argv[1]
        # TODO ok, update cache makes sense just to refresh in case of code changes...
        # TODO don't even need it anymore? cachew handles this..
        if cmd == "update_cache":
            from .takeout import update_cache, get_locations
            update_cache()
        else:
            raise RuntimeError(f"Unknown command {cmd}")
    else:
        for p in get_groups():
            print(p)
Beispiel #4
0
def main():
    setup_logzero(logger, level=logging.INFO)
    pa = argparse.ArgumentParser()
    pa.add_argument('--kml', type=Path)
    pa.add_argument('--map', type=Path)
    args = pa.parse_args()

    if args.kml is not None:
        args.kml.write_text(get_kml())
        logger.info('file to upload: %s', args.kml)
    elif args.map is not None:
        fmap = get_map()
        fmap.save(str(args.map))
        logger.info('saved map: %s', args.map)
    else:
        raise RuntimeError(args)
Beispiel #5
0
def main():
    # TODO eh. vendorize klogging already?
    from kython.klogging import setup_logzero
    setup_logzero(get_logger())
    test_tz()