示例#1
0
 def get_options(self):
     return [
         Option('--email', '-e', dest='email',
                type=str),
         Option('--password', '-p', dest='password',
                 type=str),
         Option('--fn', '-f', dest='fn',
                 type=str),
         Option('--ln', '-l', dest='ln',
                 type=str),
         Option('--username', '-u', dest='identifier', type=str),
         Option('--roles', dest="roles", type=str)
     ]
示例#2
0
文件: manage.py 项目: rsuste/copr
class DisplayChrootsCommand(Command):

    "Displays current mock chroots"

    def run(self, active_only):
        for ch in coprs_logic.MockChrootsLogic.get_multiple(
                active_only=active_only).all():

            print(ch.name)

    option_list = (
        Option("--active-only",
               "-a",
               dest="active_only",
               help="Display only active chroots",
               required=False,
               action="store_true",
               default=False),
    )
示例#3
0
class Search(Command):

    option_list = (Option(
        "tokens",
        metavar="TOKEN",
        nargs="*",
        help="Any number of tokens to search for",
    ), )

    def run(self, tokens):
        for u in self.search_query(tokens).limit(20):
            model = globals()[u.model]
            instance = model.get(u.id)

            print(u.weight, instance, u.details)

    def search_query(self, tokens):
        tokens = escape_tokens(tokens)
        return combined_search_query(MODELS, tokens)
示例#4
0
class SearchSample(Command):
    """Search sample in database."""

    option_list = (
        Option('sample_name'),
    )

    def run(self, sample_name):
        samples = Sample.query.filter_by(name=sample_name).all()

        print "Sample ID\tSample Name\tProject\tSequencing Runs\tCustom Panels"
        for sample in samples:
            print "{id}\t{name}\t{project}\t{runs}\t{custom_panels}".format(
                id=sample.id,
                name=sample.name,
                project=sample.project,
                runs=sample.sequencing_runs,
                custom_panels=sample.custom_panels,
            )
示例#5
0
class Report(Command):
    """
    Send report
    Usage:
        python cobra.py report --time=time_time(w/m/q)
    """
    option_list = (
        Option('--time', '-t', dest='t', help='Time e.g. w(weekly)/m(monthly)/q(quarterly)'),
    )

    def run(self, t='w'):
        from scheduler import report
        if t not in ['w', 'm', 'q']:
            print('Error: time type exception')
            return
        if report.Report(t).run():
            print('Report Success')
        else:
            print('Report Failed')
示例#6
0
文件: index.py 项目: wobsta/moin
class IndexDump(Command):
    description = 'Dump the indexes in readable form to stdout.'

    option_list = [
        Option('--tmp',
               action="store_true",
               required=False,
               dest='tmp',
               default=False,
               help='use the temporary location.'),
    ]

    def run(self, tmp):
        for idx_name in [LATEST_REVS, ALL_REVS]:
            print " {0} {1} {2}".format("-" * 10, idx_name, "-" * 60)
            for kvs in app.storage.dump(tmp=tmp, idx_name=idx_name):
                for k, v in kvs:
                    print k, repr(v)[:70]
                print
示例#7
0
class InfoCommand(RQCommand):
    "RQ command-line monitor."

    option_list = [
        Option('--path', '-P', default='.', help='Specify the import path.'),
        Option('--interval',
               '-i',
               type=float,
               help='Updates stats every N seconds (default: don\'t poll)'),
        Option('--raw',
               '-r',
               action='store_true',
               help='Print only the raw numbers, no bar charts'),
        Option('--only-queues',
               '-Q',
               action='store_true',
               help='Show only queue info'),
        Option('--only-workers',
               '-W',
               action='store_true',
               help='Show only worker info'),
        Option('--by-queue',
               '-R',
               action='store_true',
               help='Shows workers by queue'),
        Option('queues',
               nargs='*',
               metavar='QUEUE',
               help='Queues to work with, defaults to the ones specified '
               'in the Flask app config'),
    ]

    def run(self, path, interval, raw, only_queues, only_workers, by_queue,
            queues):
        cli.info.callback(
            url=self.rq.url,
            config=None,
            path=path,
            interval=interval,
            raw=raw,
            only_queues=only_queues,
            only_workers=only_workers,
            by_queue=by_queue,
            queues=queues or self.rq.queues,
        )
示例#8
0
class PurgeTimeline(Command):
    """Delete timeline permanently from Timesketch and Elasticsearch."""
    option_list = (Option('--index', '-i', dest='index_name', required=True), )

    # pylint: disable=arguments-differ, method-hidden
    def run(self, index_name):
        """Delete timeline in both Timesketch and Elasticsearch.

        Args:
            index_name: The name of the index in Elasticsearch
        """
        if not isinstance(index_name, six.text_type):
            index_name = codecs.decode(index_name, 'utf-8')

        searchindex = SearchIndex.query.filter_by(
            index_name=index_name).first()

        if not searchindex:
            sys.stdout.write('No such index\n')
            sys.exit()

        es = ElasticsearchDataStore(host=current_app.config['ELASTIC_HOST'],
                                    port=current_app.config['ELASTIC_PORT'])

        timelines = Timeline.query.filter_by(searchindex=searchindex).all()
        sketches = [
            t.sketch for t in timelines
            if t.sketch and t.sketch.get_status.status != 'deleted'
        ]
        if sketches:
            sys.stdout.write('WARNING: This timeline is in use by:\n')
            for sketch in sketches:
                sys.stdout.write(' * {0:s}\n'.format(sketch.name))
                sys.stdout.flush()
        really_delete = prompt_bool(
            'Are you sure you want to delete this timeline?')
        if really_delete:
            for timeline in timelines:
                db_session.delete(timeline)
            db_session.delete(searchindex)
            db_session.commit()
            es.client.indices.delete(index=index_name)
示例#9
0
class DMStIndex(Command):
    """ Add or update dmst handicaps in SkyLines """

    option_list = (Option("path", help="DMSt index list file"), )

    def run(self, path):
        for line in open(path):
            m = r.match(line)
            if m:
                names, index = m.group(1), int(m.group(2))
                for name in names.split(";"):
                    name = name.strip().decode("utf-8")
                    model = AircraftModel.by_name(name)
                    if model is None:
                        model = AircraftModel(name=name)
                        model.kind = 1
                        db.session.add(model)
                    model.dmst_index = index

        db.session.commit()
示例#10
0
文件: manage.py 项目: nos1609/copr
class AddDebugUserCommand(Command):
    """
    Adds user for debug/testing purpose.
    You shouldn't use this on production instance
    """
    def run(self, name, mail, **kwargs):
        user = User(username=name, mail=mail)

        if kwargs["admin"]:
            user.admin = True
        if kwargs["no_admin"]:
            user.admin = False
        if kwargs["proven"]:
            user.proven = True
        if kwargs["no_proven"]:
            user.proven = False
        #
        # if kwargs["api_token"]:
        #     user.api_token = kwargs["api_token"]
        #     user.api_token_expiration = datetime.date(2030, 1, 1)
        # if kwargs["api_login"]:
        #     user.api_token = kwargs["api_login"]
        #

        db.session.add(create_user_wrapper(user, mail))
        db.session.commit()

    option_list = (
        Option("name"),
        Option("mail"),
        Option("--api_token", default=None, required=False),
        Option("--api_login", default=None, required=False),
        Group(Option("--admin", action="store_true"),
              Option("--no-admin", action="store_true"),
              exclusive=True),
        Group(Option("--proven", action="store_true"),
              Option("--no-proven", action="store_true"),
              exclusive=True),
    )
示例#11
0
class BlueprintCommand(Command):
    """蓝图生成命令"""
    name = "blue"
    option_list = [
        Option('--name', '-n', dest='name'),
    ]

    def run(self, name):
        # 生成蓝图名称对象的目录
        os.mkdir(name)
        open("%s/__init__.py" % name, "w")
        open("%s/views.py" % name, "w")
        open("%s/models.py" % name, "w")
        with open("%s/urls.py" % name, "w") as f:
            content = """from . import views
        from application.utils import path
        urlpatterns = [

        ]"""
            f.write(content)
        print("蓝图%s已经创建完成...." % name)
示例#12
0
class Sitemap(Command):
    """Generate static sitemap."""

    option_list = (
        Option('--output-directory', '-o', dest='directory', default='.'),
    )

    def run(self, directory):
        """Generate static sitemap to given directory."""
        sitemap = current_app.extensions['sitemap']

        @sitemap_page_needed.connect
        def generate_page(app, page=1, urlset=None):
            filename = url_for('flask_sitemap_domain.page', page=page).split('/')[-1]
            with codecs.open(os.path.join(directory, filename), 'w',
                             'utf-8') as f:
                f.write(sitemap.render_page(urlset=urlset))

        filename = url_for('flask_sitemap_domain.sitemap').split('/')[-1]
        with codecs.open(os.path.join(directory, filename), 'w', 'utf-8') as f:
            f.write(sitemap.sitemap())
示例#13
0
文件: manage.py 项目: nos1609/copr
class CreateDBCommand(Command):
    """
    Create the DB schema
    """
    def run(self, alembic_ini=None):
        CreateSqliteFileCommand().run()
        db.create_all()

        # load the Alembic configuration and generate the
        # version table, "stamping" it with the most recent rev:
        from alembic.config import Config
        from alembic import command
        alembic_cfg = Config(alembic_ini)
        command.stamp(alembic_cfg, "head")

    option_list = (Option(
        "--alembic",
        "-f",
        dest="alembic_ini",
        help="Path to the alembic configuration file (alembic.ini)",
        required=True), )
示例#14
0
class FixturesCommand(Command):

    option_list = (Option('--url',
                          '-url',
                          dest='url',
                          default='http://localhost:2015/images/exercises/'), )

    def run(self, url):

        with app.app_context():

            for user in users:
                db.session.add(user)
            db.session.commit()

            for token in tokens:
                db.session.add(token)
                db.session.commit()

            for program in programs:
                db.session.add(program)
            db.session.commit()

            for user_program in user_programs:
                db.session.add(user_program)
            db.session.commit()

            for exercise in exercises:
                if len(exercise.image) > 0:
                    exercise.image = url + exercise.image
                db.session.add(exercise)
            db.session.commit()

            for user_exercise in user_exercises:
                db.session.add(user_exercise)
            db.session.commit()

            for step in steps:
                db.session.add(step)
            db.session.commit()
class Geolocalization(Command):
    option_list = (Option('--antennas', '-a', dest='antennas'), )

    def run(self, antennas=1000):
        # parameters validation
        try:
            antennas = int(antennas)
        except:
            print("Antennas must be a number")
            return

        if antennas < 0:
            print("Antennas must be a positive number")
            return

        from app.data.antennas_geolocalization import update_antennas_localization

        geolocated_antennas = update_antennas_localization(
            max_number_of_queries=antennas)
        application.logger.info("New geolocated antennas: " +
                                str(geolocated_antennas))
        print("New geolocated antennas:" + str(geolocated_antennas))
示例#16
0
class Generate(Command):
    """ Generate fake live tracks for debugging """

    option_list = (
        Option('user_id', type=int, help='a user ID'),
    )

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

        i = randint(0, 100)
        _longitude = randint(6500, 7500) / 1000.
        _latitude = randint(50500, 51500) / 1000.
        _altitude = 500

        while True:
            longitude = sin(i / 73.) * 0.001 + _longitude
            latitude = sin(i / 50.) * 0.004 + _latitude
            altitude = sin(i / 20.) * 300 + _altitude

            fix = TrackingFix()
            fix.pilot = user
            fix.set_location(longitude, latitude)
            fix.altitude = altitude
            fix.time = datetime.now()
            fix.time_visible = fix.time + timedelta(minutes=user.tracking_delay)

            db.session.add(fix)
            db.session.commit()

            print('.', end='')
            sys.stdout.flush()

            sleep(1)

            i += 1
示例#17
0
class dbAdapter(Command):
    option_list = (Option('--type', '-T', dest='type', default=None), )

    def run(self, type):
        if type == 'schoolInfo' or type == 'S':
            schoolInfo = schoolDB()
            schoolInfo.run()
        elif type == 'cafeInfo' or type == 'C':
            cafe = cafeDB()
            cafe.run()
        elif type == 'initialCommunity' or type == 'I':
            community = communityDB()
            community.run()
        elif type == 'contest' or type == 'T':
            contest = contestDB()
            contest.run()
        elif type == 'univ' or type == 'U':
            univ = univDB()
            univ.run()
        elif type == "alarm" or type == "A":
            survey = surveyDB()
            survey.run()
示例#18
0
class Email(Command):
    """ Send email to all users """

    option_list = (Option(
        "path", help="path to a text file with the content of the email"), )

    def run(self, path):
        with io.open(path, mode="r", encoding="utf-8") as f:
            content = f.read()
            title, text = [str.strip() for str in content.split("---")]

        users_query = (db.session.query(User).filter(
            User.email_address != None).order_by(User.id))

        for user in users_query:
            print(u"Sending email to {} (ID: {})...".format(
                user.name, user.id).encode("utf-8"))

            try:
                custom_text = u"Hello {},\n\n{}".format(user.name, text)

                msg = MIMEText(custom_text.encode("utf-8"), "plain", "utf-8")
                msg["Subject"] = title.encode("utf-8")
                msg["From"] = current_app.config["EMAIL_FROM"]
                msg["To"] = user.email_address.encode("ascii")
                msg["Date"] = formatdate(localtime=1)

                smtp = smtplib.SMTP(current_app.config["SMTP_SERVER"])
                smtp.ehlo()
                smtp.sendmail(
                    current_app.config["EMAIL_FROM"].encode("ascii"),
                    user.email_address.encode("ascii"),
                    msg.as_string(),
                )
                smtp.quit()

            except BaseException as e:
                print("Sending email failed: {}", e)
示例#19
0
文件: manage.py 项目: nos1609/copr
class AlterChrootCommand(ChrootCommand):

    "Activates or deactivates a chroot"

    def run(self, chroot_names, action):
        activate = (action == "activate")
        for chroot_name in chroot_names:
            try:
                coprs_logic.MockChrootsLogic.edit_by_name(
                    chroot_name, activate)
                db.session.commit()
            except exceptions.MalformedArgumentException:
                self.print_invalid_format(chroot_name)
            except exceptions.NotFoundException:
                self.print_doesnt_exist(chroot_name)

    option_list = ChrootCommand.option_list + (Option(
        "--action",
        "-a",
        dest="action",
        help="Action to take - currently activate or deactivate",
        choices=["activate", "deactivate"],
        required=True), )
示例#20
0
class DeleteAccount(BaseCommand):
    """Deletes an AWS account and all objects that are related to the account"""
    name = 'DeleteAccount'
    option_list = (
        Option('account_name', help='Account Name', metavar='NAME'),
    )

    def run(self, **kwargs):
        try:
            acct = Account.query.filter_by(account_name=kwargs['account_name']).first()
            if acct:
                cfm = 'Are you absolutely sure you wish to delete the account named {}'.format(acct.account_name)
                if confirm(cfm):
                    acct.delete()
                    self.log.info('Account {0} has been deleted'.format(kwargs['account_name']))
                else:
                    self.log.info('Failed to verify account name, not deleting')
            else:
                self.log.warning('No such account found: {0}'.format(kwargs['account_name']))

        except Exception:
            self.log.exception('An error occured while trying to delete the account')
            db.session.rollback()
示例#21
0
文件: email.py 项目: vdrok/skylines
class Email(Command):
    """ Send email to all users """

    option_list = (Option(
        'path', help='path to a text file with the content of the email'), )

    def run(self, path):
        with io.open(path, mode='r', encoding='utf-8') as f:
            content = f.read()
            title, text = [str.strip() for str in content.split('---')]

        users_query = db.session.query(User) \
            .filter(User.email_address != None) \
            .order_by(User.id)

        for user in users_query:
            print(u'Sending email to {} (ID: {})...'.format(
                user.name, user.id).encode('utf-8'))

            try:
                custom_text = u'Hello {},\n\n{}'.format(user.name, text)

                msg = MIMEText(custom_text.encode('utf-8'), 'plain', 'utf-8')
                msg['Subject'] = title.encode('utf-8')
                msg['From'] = current_app.config['EMAIL_FROM']
                msg['To'] = user.email_address.encode('ascii')
                msg['Date'] = formatdate(localtime=1)

                smtp = smtplib.SMTP(current_app.config['SMTP_SERVER'])
                smtp.ehlo()
                smtp.sendmail(current_app.config['EMAIL_FROM'].encode('ascii'),
                              user.email_address.encode('ascii'),
                              msg.as_string())
                smtp.quit()

            except BaseException as e:
                print('Sending email failed: {}', e)
示例#22
0
 def get_options(self):
     return [
         Option('-e',
                '--email',
                dest='email',
                help='Email address for this user',
                type=str),
         Option('-p',
                '--password',
                dest='password',
                help='Password for this user',
                type=str),
         Option('-f',
                '--fn',
                dest='fn',
                help='First name of this user',
                type=str,
                metavar='NAME'),
         Option('-l',
                '--ln',
                dest='ln',
                help='Last name of this user',
                type=str,
                metavar='NAME'),
         Option('-u',
                '--username',
                dest='identifier',
                help='Username for this user',
                type=str,
                required=True),
         Option('--add-roles',
                dest="add_roles",
                help='Comma-delimited list of roles to add',
                type=str),
         Option('--remove-roles',
                dest="remove_roles",
                help='Comma-delimited list of roles to remove',
                type=str)
     ]
示例#23
0
class CopyFlights(Command):
    """ Copy flight files by one or more properties """

    option_list = (Option("dest",
                          help="Destination directory"), ) + selector_options

    def run(self, dest, **kwargs):
        if not os.path.exists(dest):
            print("Creating destination directory: " + dest)
            os.makedirs(dest)

        query = (db.session.query(Flight).join(
            Flight.takeoff_airport).join(IGCFile).order_by(Flight.id))

        query = select(query, **kwargs)

        if not query:
            quit()

        for flight in query:
            print("Flight: " + str(flight.id) + " " + flight.igc_file.filename)
            src = os.path.join(current_app.config["SKYLINES_FILES_PATH"],
                               flight.igc_file.filename)
            shutil.copy(src, dest)
示例#24
0
class RunDevelopmentServer(Command):
    """Run a development api server. Don't use this in production.
    Specify the port with -p or --port otherwise defaults to 5000"""

    option_list = (Option('--port',
                          '-p',
                          dest='port',
                          type=IntRange(0, 2**16 - 1),
                          default=5000), )

    # pylint: disable=arguments-differ
    def run(self, port):
        if config.cfg.has_option('devel', 'debug'):
            debug = config.cfg.getboolean('devel', 'debug')
        else:
            debug = False
        # We need to import api here so that the functions within it get
        # registered (via `rest_call`), though we don't use it directly:
        # pylint: disable=unused-variable
        from hil import api
        server.init()
        migrations.check_db_schema()
        server.stop_orphan_consoles()
        rest.serve(port, debug=debug)
示例#25
0
class CreateInstance(Command):
    description = 'Create wikiconfig and wiki instance directories and copy required files.'

    option_list = [
        Option(
            '--path',
            '-p',
            required=False,
            dest='path',
            type=str,
            help="Path to new wikiconfig dir, defaults to CWD if not specified."
        ),
    ]

    def run(self, path):
        config_path = os.path.dirname(config.__file__)
        if not path:
            path = os.getcwd()
        if os.path.exists(path):
            print('Directory', os.path.abspath(path),
                  'already exists, using as wikiconfig dir.')
        else:
            os.makedirs(path)
            print('Directory', os.path.abspath(path), 'created.')

        if os.path.isfile(os.path.join(path, 'wikiconfig.py')):
            print('wikiconfig.py already exists, not copied.')
        else:
            shutil.copy(os.path.join(config_path, 'wikiconfig.py'), path)

        if os.path.isfile(os.path.join(path, 'intermap.txt')):
            print('intermap.txt already exists, not copied.')
        else:
            shutil.copy(os.path.join(config_path, 'intermap.txt'), path)
        if not os.path.isdir('wiki_local'):
            os.mkdir('wiki_local')
示例#26
0
class DBSetup(Command):
	option_list = (
		Option('--name', '-n', dest='name'),
		Option('--location', '-l', dest='base'),
		Option('--epoch-granularity', '-g', dest='granularity'),
		Option('--max-epoch', '-e', dest='max_epoch'),
		Option('--nodes-per-part', '-p', dest='nnp'),
		Option('--overwrite', '-o', dest='overwrite')
		)

	def run(self, name, base, granularity, max_epoch, nnp, overwrite):
		if not name:
			print("Graph instance name must be provided using flag: -n [name]")
			return

		if max_epoch:
			e = int(max_epoch)
		else:
			e = 100

		if granularity:
			g = int(granularity)
		else:
			g = 0

		if base:
			b = base
		else:
			b = "data/"

		if nnp:
			n = int(nnp)
		else:
			n = 50

		if overwrite:
			o = overwrite.lower()
		else:
			o = None

		db = Handler(name, b, max_epoch = e, granularity = g, nodes_per_part = n, overwrite = o)
 def get_options(self):
     options = (
         Option('-H',
                '--host',
                dest='host',
                type=str,
                default=self.options['host'],
                help="hostname to bind server to"),
         Option('-p',
                '--port',
                dest='port',
                type=int,
                default=self.options['port'],
                help="port to bind server to"),
         Option('-w',
                '--workers',
                dest='workers',
                type=int,
                default=self.options['workers'],
                help="set the number of workers"),
         Option('--access-logfile',
                dest='access_logfile',
                type=str,
                default=self.options['access_logfile'],
                help="set the access log output location"),
         Option('--max-requests',
                dest='max_requests',
                type=int,
                default=self.options['max_requests'],
                help="set the maximum number of requests " +
                "to serve before reloading"),
         Option('--no-debug',
                dest='debug',
                action='store_false',
                default=self.options['debug'],
                help="turn off debug mode"),
     )
     return options
class CreatePlatformCommand(Command):

    option_list = (
        Option(help="platform name", dest="platform"),
        Option(help="email", dest="email"),
        Option(help="password", dest="password"),
        Option(help="firstname", dest="firstname"),
        Option(help="lastname", dest="lastname"),
        Option(help="phonenumber", dest="phonenumber"),
    )

    def run(self, platform, email, password, firstname, lastname, phonenumber):
        params = {
            "email": email,
            "password": password,
            "firstname": firstname,
            "lastname": lastname,
            "phone_number": phonenumber
        }
        organization = {
            "name": password,
        }
        create_user(params, platform=organization)
示例#29
0
文件: manager.py 项目: lxj0276/fof
    def get_options(self):
        options = (
            Option('-h', '--host',
                   dest='host',
                   default=self.host),

            Option('-p', '--port',
                   dest='port',
                   type=int,
                   default=self.port),

            Option('-d', '--debug',
                   action='store_true',
                   dest='use_debugger',
                   help=('enable the Werkzeug debugger (DO NOT use in '
                         'production code)'),
                   default=self.use_debugger),
            Option('-D', '--no-debug',
                   action='store_false',
                   dest='use_debugger',
                   help='disable the Werkzeug debugger',
                   default=self.use_debugger),

            Option('-r', '--reload',
                   action='store_true',
                   dest='use_reloader',
                   help=('monitor Python files for changes (not 100%% safe '
                         'for production use)'),
                   default=self.use_reloader),
            Option('-R', '--no-reload',
                   action='store_false',
                   dest='use_reloader',
                   help='do not monitor Python files for changes',
                   default=self.use_reloader),
        )
        return options
示例#30
0
class GenerateThroughDaemon(Command):
    """ Generate fake live tracks for debugging on daemon """

    UDP_IP = '127.0.0.1'
    UDP_PORT = 5597
    ADDRESS = (UDP_IP, UDP_PORT)

    option_list = (Option('user_id', type=int, help='a user ID'), )

    def run(self, user_id):
        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.
        _latitude = randint(50500, 51500) / 1000.
        _altitude = 500

        while True:
            longitude = sin(i / 73.) * 0.001 + _longitude
            latitude = sin(i / 50.) * 0.004 + _latitude
            altitude = sin(i / 20.) * 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,
                altitude,
                0,
                0,
            )
            data = set_crc(data)
            sock.sendto(data, self.ADDRESS)

            print '.',
            sys.stdout.flush()

            sleep(1)

            i += 1
            _time += 1000