def main():
    db.create_projects()  # This will make sure the database has projects in it
    while True:
        try:
            events = GerritEventStream()
        except paramiko.SSHException as ex:
            logger.exception("Error connecting to Gerrit: %s", ex)
            time.sleep(60)
        for event in events:
            event = parse_json_event(event)
            if event is not None:
                _store_event(event)
def parse_json_event(event):
    try:
        event = json.loads(event)
    except Exception as ex:
        logger.error("Failed json.loads on event: %s", event)
        logger.exception(ex)
        return None
    if _is_valid(event):
        _process_event(event)
        logger.info("Parsed valid event: %s", event)
        return event
    return None
Exemple #3
0
def get_data(datafile, projects):
    data = []
    with open(datafile) as file_:
        for line in file_:
            try:
                event = json.loads(line)
            except Exception as ex:
                logger.error('Failed json.loads on event: %s', event)
                logger.exception(ex)
                continue
            parsed_event = parse_event(event, projects)
            if parsed_event is not None:
                data.append(parsed_event)
    return data