Beispiel #1
0
def main():
    qubesstats.setup_logging()
    args = parser.parse_args()
    if args.force_descriptor_type:
        qubesstats.EXIT_DESCRIPTOR_TYPE = args.force_descriptor_type
    counter = qubesstats.QubesCounter(args.month.year, args.month.month)
    counter.bake_exit_cache(args.exit_list)
Beispiel #2
0
def main():
    qubesstats.setup_logging()
    args = parser.parse_args()

    if args.force_descriptor_type:
        qubesstats.EXIT_DESCRIPTOR_TYPE = args.force_descriptor_type

    if args.current_month:
        month = datetime.date.today()
    elif args.last_month:
        month = datetime.date.today().replace(day=1)-datetime.timedelta(days=1)
    else:
        month = args.month

    counter = qubesstats.QubesCounter(month.year, month.month)

    if args.force_fetch or args.current_month:
        counter.fetch_exit_cache()
    else:
        counter.load_or_fetch_exit_cache()

    for filename in args.logfiles:
        logging.log(25, 'parsing logfile %r', filename)
        counter.process(open(filename))

    logging.log(25, 'writing stats for period %r to datafile %r',
        counter.timestamp, args.datafile)

    try:
        fh = open(args.datafile, 'r+')
        data = json.load(fh)
    except IOError:
        fh = open(args.datafile, 'w')
        data = {}

    data[counter.timestamp] = counter
    data['meta'] = {
        'title': 'Estimated Qubes OS userbase',
        'last-updated':
            datetime.datetime.utcnow().strftime(qubesstats.TIMESTAMP_FORMAT),
        'comment':
            'Current month is not reliable. '
            'The methodology of counting Tor users changed on April 2018.',
        'source': 'https://github.com/woju/qubes-stats',
    }
    fh.seek(0)
    qubesstats.QubesJSONEncoder(sort_keys=True, indent=2).dump(data, fh)
    fh.truncate()
    fh.close()
Beispiel #3
0
def main():
    qubesstats.setup_logging()
    args = parser.parse_args()
    if args.current_month:
        month = datetime.date.today()
    elif args.last_month:
        month = datetime.date.today().replace(day=1)-datetime.timedelta(days=1)
    else:
        month = args.month

    counter = qubesstats.QubesCounter(month.year, month.month)

    if args.force_fetch or args.current_month:
        counter.fetch_exit_cache()
    else:
        counter.load_or_fetch_exit_cache()

    for filename in args.logfiles:
        logging.log(25, 'parsing logfile %r', filename)
        counter.process(open(filename))

    logging.log(25, 'writing stats for period %r to datafile %r',
        counter.timestamp, args.datafile)

    try:
        fh = open(args.datafile, 'r+')
        data = json.load(fh)
    except IOError:
        fh = open(args.datafile, 'w')
        data = {}

    data[counter.timestamp] = counter
    data['meta'] = {
        'title': 'Estimated Qubes OS userbase',
        'last-updated': datetime.datetime.now().strftime('%d.%m.%Y %H:%M'),
        'comment': 'Stats are based on counting the number of unique IPs'
            ' connecting to the Qubes update server each month.',
        'source': 'https://github.com/woju/qubes-stats',
    }
    fh.seek(0)
    qubesstats.QubesJSONEncoder(sort_keys=True, indent=2).dump(data, fh)
    fh.truncate()
    fh.close()
Beispiel #4
0
def main():
    qubesstats.setup_logging()
    args = parser.parse_args()
    stats = LoadedStats(args.datafile)
    graph = Graph(stats)
    graph.save(args.output)
Beispiel #5
0
def main():
    qubesstats.setup_logging()
    args = parser.parse_args()
    stats = LoadedStats(args.datafile)
    graph = Graph(stats)
    graph.save(args.output)