Пример #1
0
class AnonymousUsageTests(unittest.TestCase):

    def __init__(self, *args):
        super(AnonymousUsageTests, self).__init__(*args)

    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        trackerfile = os.path.join(self.tmpdir, 'au_unittests.db')
        self.tracker = AnonymousUsageTracker('UnitTests', trackerfile)
        self.tracker.track_statistic('Statistic')
        self.tracker.track_state('State', True)
        self.tracker.track_time('Timer')
        self.tracker.track_sequence('Sequence', ['A', 'B', 'C', 'D'])

    def tearDown(self):
        shutil.rmtree(self.tmpdir)
Пример #2
0
class AnonymousUsageTests(unittest.TestCase):

    def __init__(self, *args):
        super(AnonymousUsageTests, self).__init__(*args)

    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        trackerfile = os.path.join(self.tmpdir, 'au_unittests.db')
        self.tracker = AnonymousUsageTracker('UnitTests', trackerfile)
        self.tracker.track_statistic('Cheese')
        self.tracker.track_state('Fresh', True)

    def tearDown(self):
        shutil.rmtree(self.tmpdir)

    def test_statistic(self):
        cheese = self.tracker['Cheese']
        cheese += 1
        nrows = cheese.get_number_of_rows()
        self.assertEquals(1, nrows)
Пример #3
0
import uuid
import datetime
import logging
logging.getLogger().setLevel(logging.DEBUG)
from anonymoususage import AnonymousUsageTracker, NO_STATE

unique_identifier = uuid.uuid4().hex
database_path = './test.db'
submit_interval = datetime.timedelta(hours=1)

tracker = AnonymousUsageTracker(uuid=unique_identifier,
                                filepath=database_path,
                                check_interval_s=30,
                                submit_interval_s=60*60)
tracker.setup_hq(host='http://127.0.0.1:5010', api_key='1fd5451sdr83523ks234')
tracker.track_statistic('quests_complete')
tracker['quests_complete'].increment(1)
tracker['quests_complete'].decrement(1)
tracker.track_statistic('monsters_killed')
tracker.track_sequence('round_trip', checkpoints=('The Shire', 'Mordor', 'Gondor'))
tracker.track_state('server', initial_state=NO_STATE)
tracker.track_time('play_time')


def login(server_name, username, password):
    # Login code goes here

    # Start the play_time timer.
    tracker['play_time'].start_timer()
    tracker['server'] = server_name
Пример #4
0
import datetime
import logging
logging.getLogger().setLevel(logging.DEBUG)
from anonymoususage import AnonymousUsageTracker, NO_STATE

unique_identifier = uuid.uuid4().hex
database_path = 'data/usage.db'
submit_interval = datetime.timedelta(hours=1)

tracker = AnonymousUsageTracker(uuid=unique_identifier,
                                tracker_file=database_path,
                                config='./anonymoususage.cfg',
                                check_interval=datetime.timedelta(seconds=30),
                                submit_interval=submit_interval)

tracker.track_statistic('quests_complete')
tracker.track_statistic('monsters_killed')
tracker.track_sequence('round_trip', checkpoints=('The Shire', 'Mordor', 'Gondor'))
tracker.track_state('server', initial_state=NO_STATE)
tracker.track_time('play_time')


def login(server_name, username, password):
    # Login code goes here

    # Start the play_time timer.
    tracker['play_time'].start_timer()
    tracker['server'] = server_name


def logoff():
Пример #5
0
__author__ = 'calvin'

import os
import time
import datetime
from anonymoususage import AnonymousUsageTracker


usage_tracker = AnonymousUsageTracker(config='./anonymoususage.cfg',
                                           uuid="ASDFGH",
                                           tracker_file='./test.db',
                                           submit_interval=datetime.timedelta(seconds=10),
                                           check_interval=datetime.timedelta(minutes=2))
usage_tracker.track_statistic('grids')
usage_tracker.track_statistic('lines')

while 1:
    usage_tracker['grids'] += 1
    time.sleep(2)