Beispiel #1
0
def getDictionaryStats(request):
    global g_wnWords, g_fDisabled
    global g_availableDicts
    initDictionary()
    if g_fDisabled:
        return (MODULE_DOWN, None)
    
    request = request.strip()
    if 0 == len(request) or "private" == request:
        # TODO: null request can return page, to select dictionary...
        private = False
        if "private" == request:
            private = True

        return _getAvailableDicts(private)

    res = []

    if request in g_availableDicts:
        res.append(["N",g_availableDicts[request][1]])
        res.append(["S", g_availableDicts[request][0]])
        res.append(["C",str(getWordsCount(request))])
    else:
        return INVALID_REQUEST, None
    return RESULTS_DATA, universalDataFormat(res)
Beispiel #2
0
def getDictionaryStats(request):
    global g_wnWords, g_fDisabled
    global g_availableDicts
    initDictionary()
    if g_fDisabled:
        return (MODULE_DOWN, None)

    request = request.strip()
    if 0 == len(request) or "private" == request:
        # TODO: null request can return page, to select dictionary...
        private = False
        if "private" == request:
            private = True

        return _getAvailableDicts(private)

    res = []

    if request in g_availableDicts:
        res.append(["N", g_availableDicts[request][1]])
        res.append(["S", g_availableDicts[request][0]])
        res.append(["C", str(getWordsCount(request))])
    else:
        return INVALID_REQUEST, None
    return RESULTS_DATA, universalDataFormat(res)
    def retrieveListings(self):
        h = self._date.tm_hour
        max_h = 24 - HOURS_RETRIEVED_IN_ONE_STEP
        if h > max_h:
            h = max_h
        for i in range(HOURS_RETRIEVED_IN_ONE_STEP):
            date = time.localtime(time.mktime((self._date.tm_year, self._date.tm_mon, self._date.tm_mday, h , 0, 0, -1, -1, -1)))
            _g_zap2it_cache_manager.finishCaching(self._provider, date)

        hours = range(h, h + HOURS_RETRIEVED_IN_ONE_STEP)
        res = TVLISTINGS_PARTIAL
        out = self._retrieveHours(hours, True)
        if out is None:
            out = self._retrieveFromDatabase()
            res = TVLISTINGS_FULL
        return res, universalDataFormat(out)
 def retrieveProviders(self):
     providers = _zap2it_retrieve_providers(self._jar, self._zipCode)
     if providers is None:
         return UNKNOWN_FORMAT, None
     out = []
     cursor = self._conn.cursor()
     try:
         for provider in providers.iteritems():
             id, name = provider
             out.append([str(id), name])
             name = self._conn.string_literal(name)
             try:
                 cursor.execute("INSERT INTO zap2it_providers (id, name) VALUES (%d, %s)" %
                                (id, name))
             except IntegrityError:
                 pass
     finally:
         cursor.close()
     return TVLISTINGS_PROVIDERS, universalDataFormat(out)