Beispiel #1
0
def cacheDay(dest, day):
    """
    Cache a day, by calling wget in "mirror" mode
    """

    dbi = DBMgr.getInstance()
    dbi.startRequest()

    index = {}

    calIdx = IndexesHolder().getIndex('calendar')

    objs = calIdx.getObjectsInDay(day)

    for confId in objs:

	if confId == '': continue

        obj = ConferenceHolder().getById(confId)
        url = str(urlHandlers.UHConferenceDisplay.getURL(obj))

        savedDirs = re.match(r'http:\/\/(.*)', url).group(1).split('/')

        print "Calling wget for %s..." % url
        os.system(WGET_COMMAND % (confId, url,
                                  os.path.join(dest, confId),
                                  savedDirs[0]))

        print "done!"

        index[confId] = (os.path.join(confId,*savedDirs)+'.html', obj.getTitle())

    dbi.endRequest(False)

    return index
def cacheDay(dest, day):
    """
    Cache a day, by calling wget in "mirror" mode
    """

    dbi = DBMgr.getInstance()
    dbi.startRequest()

    index = {}

    calIdx = IndexesHolder().getIndex('calendar')

    objs = calIdx.getObjectsInDay(day)

    for confId in objs:

	if confId == '': continue

        obj = ConferenceHolder().getById(confId)
        url = str(urlHandlers.UHConferenceDisplay.getURL(obj))

        savedDirs = re.match(r'http:\/\/(.*)', url).group(1).split('/')

        print "Calling wget for %s..." % url
        os.system(WGET_COMMAND % (confId, url,
                                  os.path.join(dest, confId),
                                  savedDirs[0]))

        print "done!"

        index[confId] = (os.path.join(confId,*savedDirs)+'.html', obj.getTitle())

    dbi.endRequest(False)

    return index
Beispiel #3
0
class PiwikReport(PiwikReportBase):

    fossilizes(IPiwikReportFossil)
    _defaultReportInterval = 14

    def __init__(self, startDate, endDate, confId, contribId=None):
        """
        Builds the map of generators to fill this object's variables before
        fossilization.
        """

        PiwikReportBase.__init__(self)
        report = BaseReportGenerator

        self._conf = ConferenceHolder().getById(confId)
        self._confId = confId
        self._contribId = contribId
        self._buildDateRange(startDate, endDate)
        self._contributions = []

        params = {
            'startDate': self._startDate,
            'endDate': self._endDate,
            'confId': confId
        }

        if contribId:
            params['contribId'] = contribId

        # This report only has need for images and values, not for widgets.
        self._reportGenerators = {
            'values': {
                'visits':
                report(pq.PiwikQueryMetricConferenceVisits, params),
                'uniqueVisits':
                report(pq.PiwikQueryMetricConferenceUniqueVisits, params),
                'visitLength':
                report(pq.PiwikQueryMetricConferenceVisitLength, params),
                'referrers':
                report(pq.PiwikQueryMetricConferenceReferrers, params),
                'peakDate':
                report(pq.PiwikQueryMetricConferencePeakDateAndVisitors,
                       params)
            }
        }

        self._buildReports()
        self._buildConferenceContributions()

    def _buildDateRange(self, startDate, endDate):
        """
        If the default values are passed through, computes the appropriate date
        range based on whether today is before or after the conference end date.
        If after, end of period is set as conference end date. Start date is then
        calculated by the _defaultReportInterval difference.
        """
        def getStartDate():
            interval = datetime.timedelta(days=self._defaultReportInterval)
            adjustedStartDate = self._endDateTime - interval

            return str(adjustedStartDate.date())

        def getEndDate():
            today = nowutc()
            confEndDate = self._conf.getEndDate()

            self._endDateTime = confEndDate if today > confEndDate else today

            return str(self._endDateTime.date())

        self._endDate = endDate if endDate else getEndDate()
        self._startDate = startDate if startDate else getStartDate()

    def _buildConferenceContributions(self):
        """
        As this implementation permits the viewing of individual contributions,
        we make a list of tuples associating the uniqueId with the title
        (and start time) to be fossilized.
        """
        contributions = self._conf.getContributionList()

        if contributions:
            self._contributions.append(
                ('None', str(_('Conference: ') + self._conf.getTitle())))

            for ctrb in contributions:

                if not ctrb.isScheduled():
                    continue

                ctrbTime = str(ctrb.getStartDate().hour) + ':' + str(
                    ctrb.getStartDate().minute)
                ctrbInfo = _(
                    'Contribution: ') + ctrb.getTitle() + ' (' + ctrbTime + ')'
                value = (ctrb.getUniqueId(), ctrbInfo)
                self._contributions.append(value)
        else:
            self._contributions = False

    def _getContributions(self):
        return self._contributions

    def getConferenceId(self):
        return self._confId

    def getContributionId(self):
        return self._contribId
Beispiel #4
0
class PiwikReport(PiwikReportBase):

    fossilizes(IPiwikReportFossil)
    _defaultReportInterval = 14

    def __init__(self, startDate, endDate, confId, contribId=None):
        """
        Builds the map of generators to fill this object's variables before
        fossilization.
        """

        PiwikReportBase.__init__(self)
        report = BaseReportGenerator

        self._conf = ConferenceHolder().getById(confId)
        self._confId = confId
        self._contribId = contribId
        self._buildDateRange(startDate, endDate)
        self._contributions = []

        params = {'startDate': self._startDate,
                  'endDate': self._endDate,
                  'confId': confId}

        if contribId:
            params['contribId'] = contribId

        # This report only has need for images and values, not for widgets.
        self._reportGenerators = {
            'values': {'visits': report(pq.PiwikQueryMetricConferenceVisits, params),
                    'uniqueVisits': report(pq.PiwikQueryMetricConferenceUniqueVisits, params),
                    'visitLength': report(pq.PiwikQueryMetricConferenceVisitLength, params),
                    'referrers': report(pq.PiwikQueryMetricConferenceReferrers, params),
                    'peakDate': report(pq.PiwikQueryMetricConferencePeakDateAndVisitors, params)}
             }

        self._buildReports()
        self._buildConferenceContributions()

    def _buildDateRange(self, startDate, endDate):
        """
        If the default values are passed through, computes the appropriate date
        range based on whether today is before or after the conference end date.
        If after, end of period is set as conference end date. Start date is then
        calculated by the _defaultReportInterval difference.
        """

        def getStartDate():
            interval = datetime.timedelta(days=self._defaultReportInterval)
            adjustedStartDate = self._endDateTime - interval

            return str(adjustedStartDate.date())

        def getEndDate():
            today = nowutc()
            confEndDate = self._conf.getEndDate()

            self._endDateTime = confEndDate if today > confEndDate else today

            return str(self._endDateTime.date())

        self._endDate = endDate if endDate else getEndDate()
        self._startDate = startDate if startDate else getStartDate()

    def _buildConferenceContributions(self):
        """
        As this implementation permits the viewing of individual contributions,
        we make a list of tuples associating the uniqueId with the title
        (and start time) to be fossilized.
        """
        contributions = self._conf.getContributionList()

        if contributions:
            self._contributions.append(('None', str(_('Conference: ') + self._conf.getTitle())))

            for ctrb in contributions:

                if not ctrb.isScheduled():
                    continue

                ctrbTime = str(ctrb.getStartDate().hour) + ':' + str(ctrb.getStartDate().minute)
                ctrbInfo = _('Contribution: ') + ctrb.getTitle() + ' (' + ctrbTime + ')'
                value = (ctrb.getUniqueId(), ctrbInfo)
                self._contributions.append(value)
        else:
            self._contributions = False

    def _getContributions(self):
        return self._contributions

    def getConferenceId(self):
        return self._confId

    def getContributionId(self):
        return self._contribId