Пример #1
0
class EventGenerator(object):
    """
    Simple analytical event generator
    """
    def __init__(self):
        self.log = EventLogIO()
        self.etl = EventLogETL()

    def generate(self, count, projects, users, events):
        event = dict()

        for i in xrange(count):
            eventtype = random.choice(events)
            if eventtype not in EVENT_DESCRIPTIONS.keys():
                logging.warning('Event type "%s" is not known, skipping it' %
                                eventtype)
                continue

            event['project'] = random.choice(projects)
            event['event'] = eventtype
            event['username'] = random.choice(users)

            self.log.write_event(event)
            print '.',

        print ''

    def process(self):
        # Update tables
        self.etl.run()

        # Run summaries from last two full hours
        dt_now = datetime.utcnow()
        dt_end = dt_now - timedelta(minutes=dt_now.minute,
                                    seconds=dt_now.second,
                                    microseconds=dt_now.microsecond)
        dt_start = dt_end - timedelta(hours=2)

        stl = SummaryETL(dt_start, dt_end)
        stl.run()
Пример #2
0
class EventGenerator(object):
    """
    Simple analytical event generator
    """
    def __init__(self):
        self.log = EventLogIO()
        self.etl = EventLogETL()


    def generate(self, count, projects, users, events):
        event = dict()

        for i in xrange(count):
            eventtype = random.choice(events)
            if eventtype not in EVENT_DESCRIPTIONS.keys():
                logging.warning('Event type "%s" is not known, skipping it' % eventtype)
                continue

            event['project'] = random.choice(projects)
            event['event'] = eventtype
            event['username'] = random.choice(users)

            self.log.write_event(event)
            print '.',

        print ''


    def process(self):
        # Update tables
        self.etl.run()

        # Run summaries from last two full hours
        dt_now = datetime.utcnow()
        dt_end = dt_now - timedelta(minutes = dt_now.minute, seconds = dt_now.second, microseconds = dt_now.microsecond)
        dt_start = dt_end - timedelta(hours = 2)

        stl = SummaryETL(dt_start, dt_end)
        stl.run()
Пример #3
0
 def __init__(self):
     self.log = EventLogIO()
     self.etl = EventLogETL()
Пример #4
0
 def __init__(self):
     self.log = EventLogIO()
     self.etl = EventLogETL()
Пример #5
0
# ensure some logging initialization
import logging
logging.basicConfig()
from multiproject.core.analytics.etl import EventLogETL

etl = EventLogETL()
etl.run()