Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/FundraiserDataThreading.py |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +""" |
| 3 | + |
| 4 | +This module provides access to the threading classes for Fundraiser Analytics related tasks. |
| 5 | +This is configured as a set of classes that extend the python threading classes to build |
| 6 | +containers for multi-threading where needed |
| 7 | + |
| 8 | +""" |
| 9 | + |
| 10 | +__author__ = "Ryan Faulkner" |
| 11 | +__revision__ = "$Rev$" |
| 12 | +__date__ = "June 10th, 2011" |
| 13 | + |
| 14 | +import threading |
| 15 | +import re |
| 16 | +import Fundraiser_Tools.classes.DataMapper as DM |
| 17 | + |
| 18 | +""" |
| 19 | + This class handles executing a log mining process in a new thread |
| 20 | +""" |
| 21 | +class MinerThread ( threading.Thread ): |
| 22 | + |
| 23 | + _fdm_ = None |
| 24 | + _log_name_ = None |
| 25 | + |
| 26 | + def __init__(self, log_name): |
| 27 | + threading.Thread.__init__(self) |
| 28 | + self._fdm_ = DM.FundraiserDataMapper() |
| 29 | + self._log_name_ = log_name |
| 30 | + |
| 31 | + def run( self ): |
| 32 | + self.call_mine_log() |
| 33 | + |
| 34 | + def call_mine_log(self): |
| 35 | + |
| 36 | + if re.search('bannerImpressions', self._log_name_): |
| 37 | + print 'New Thread: Mining banner impressions from ' + self._log_name_ |
| 38 | + |
| 39 | + try: |
| 40 | + self._fdm_.mine_squid_impression_requests(self._log_name_ + '.log.gz') |
| 41 | + except: |
| 42 | + self._fdm_.mine_squid_impression_requests(self._log_name_ + '.log') |
| 43 | + |
| 44 | + elif re.search('landingpages', self._log_name_): |
| 45 | + print 'New Thread: Mining landing page views from ' + self._log_name_ |
| 46 | + |
| 47 | + try: |
| 48 | + self._fdm_.mine_squid_landing_page_requests(self._log_name_ + '.log.gz') |
| 49 | + except: |
| 50 | + self._fdm_.mine_squid_landing_page_requests(self._log_name_ + '.log') |
| 51 | + |
| 52 | + |
\ No newline at end of file |