<commit_before>from __future__ import print_function

from flask_script import Command, Option

import sys
import socket
import struct
from skylines.model import User
from skylines.tracking.server import (
    datetime,
    FLAG_LOCATION,
    FLAG_ALTITUDE,
    TrackingFix,
    MAGIC,
    TYPE_FIX,
    set_crc,
)
from math import sin
from random import randint
from time import sleep


class GenerateThroughDaemon(Command):
    """ Generate fake live tracks for debugging on daemon """

    option_list = (
        Option("--host", type=str, default="127.0.0.1"),
        Option("--port", type=int, default=5597),
        Option("user_id", type=int, help="a user ID"),
    )

    def run(self, user_id, **kwargs):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

        user = User.get(user_id)
        if not user:
            print('User with id "{}" not found.'.format(user_id))
            sys.exit(1)

        start_time = datetime.utcnow()

        i = randint(0, 100)
        _time = (
            start_time.hour * 60 * 60 * 1000
            + start_time.minute * 60 * 1000
            + start_time.second * 1000
        )
        _longitude = randint(6500, 7500) / 1000.0
        _latitude = randint(50500, 51500) / 1000.0
        _altitude = 500

        while True:
            longitude = sin(i / 73.0) * 0.001 + _longitude
            latitude = sin(i / 50.0) * 0.004 + _latitude
            altitude = sin(i / 20.0) * 300 + _altitude

            flags = FLAG_LOCATION | FLAG_ALTITUDE
            fix = TrackingFix()
            fix.pilot_id = user.id
            fix.set_location(longitude, latitude)
            fix.altitude = altitude

            data = struct.pack(
                "!IHHQIIiiIHHHhhH",
                MAGIC,
                0,
                TYPE_FIX,
                user.tracking_key,
                flags,
                _time,
                int(latitude * 1000000),
                int(longitude * 1000000),
                0,
                0,
                0,
                0,
                int(altitude),<commit_msg>commands.tracking.generate_through_daemon: Remove unused `TrackingFix` instance<commit_after>from __future__ import print_function

from flask_script import Command, Option

import sys
import socket
import struct
from skylines.model import User
from skylines.tracking.server import (
    datetime,
    FLAG_LOCATION,
    FLAG_ALTITUDE,
    MAGIC,
    TYPE_FIX,
    set_crc,
)
from math import sin
from random import randint
from time import sleep


class GenerateThroughDaemon(Command):
    """ Generate fake live tracks for debugging on daemon """

    option_list = (
        Option("--host", type=str, default="127.0.0.1"),
        Option("--port", type=int, default=5597),
        Option("user_id", type=int, help="a user ID"),
    )

    def run(self, user_id, **kwargs):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

        user = User.get(user_id)
        if not user:
            print('User with id "{}" not found.'.format(user_id))
            sys.exit(1)

        start_time = datetime.utcnow()

        i = randint(0, 100)
        _time = (
            start_time.hour * 60 * 60 * 1000
            + start_time.minute * 60 * 1000
            + start_time.second * 1000
        )
        _longitude = randint(6500, 7500) / 1000.0
        _latitude = randint(50500, 51500) / 1000.0
        _altitude = 500

        while True:
            longitude = sin(i / 73.0) * 0.001 + _longitude
            latitude = sin(i / 50.0) * 0.004 + _latitude
            altitude = sin(i / 20.0) * 300 + _altitude

            flags = FLAG_LOCATION | FLAG_ALTITUDE

            data = struct.pack(
                "!IHHQIIiiIHHHhhH",
                MAGIC,
                0,
                TYPE_FIX,
                user.tracking_key,
                flags,
                _time,
                int(latitude * 1000000),
                int(longitude * 1000000),
                0,
                0,
                0,
                0,
                int(altitude),
{'fraction_non_alphanumeric': 0.0971540726202159, 'fraction_numerical': 0.05053974484789009, 'mean_word_length': 1.6560260586319218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4622592', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1205, 'n_words': 298}