コード例 #1
0
async def set_user_contributions(username: str, lang: str) -> None:
    challenges_contributions, solutions_contributions, all_contributions = get_user_contributions_data(
        username, lang)
    timestamp = datetime.now().isoformat()

    if challenges_contributions is not None:
        await app.redis.set(
            f'{lang}.{username}.contributions.challenges',
            json.dumps({
                'body': challenges_contributions,
                'last_update': timestamp
            }))
    if solutions_contributions is not None:
        await app.redis.set(
            f'{lang}.{username}.contributions.solutions',
            json.dumps({
                'body': solutions_contributions,
                'last_update': timestamp
            }))
    await app.redis.set(
        f'{lang}.{username}.contributions',
        json.dumps({
            'body': all_contributions,
            'last_update': timestamp
        }))
    log.debug('set_user_contributions_success', username=username, lang=lang)
コード例 #2
0
async def set_user_stats(username: str, lang: str) -> None:
    response = get_user_stats_data(username, lang)
    await app.redis.set(
        f'{lang}.{username}.stats',
        json.dumps({
            'body': response,
            'last_update': datetime.now().isoformat()
        }))
    log.debug('set_user_stats_success', username=username, lang=lang)
コード例 #3
0
ファイル: __init__.py プロジェクト: ddinsight/dd-streamworks
def addCellTower(cursor, node):
    strSql = """INSERT INTO
                    apmain.cellinfo (fullid, plmnid, cellid, lac, celltype, regdtm, lat, lng, acc, geosrc, seq)
                VALUES('%s','%s','%s','%s','%d','%s','%s','%f','%f','%s', '1')
                ON DUPLICATED UPDATE lat=((lat*seq)+VALUES(lat))/(seq+1), lng=((lng*seq)+VALUES(lng))/(seq+1), seq=seq+1, geosrc=VALUES(geosrc)"""

    try:
        strSql = strSql % (node.cellid, node.plmnid, node.cid, node.lac, 0, node.regdtm, node.geoloc.lat, node.geoloc.lng, node.geoloc.acc, 'cellLoc' if node.geoloc.from_cell else node.geoloc.geosrc)
        cursor.execute(strSql)
        log.debug("INSERT - %s" % node.cellid)
    except Exception, e:
        # Duplicate entry error
        if e[0] != 1062:
            log.error(e)
            log.error(strSql)
        return False
コード例 #4
0
async def set_all_challenges(lang: str) -> None:
    html = http_get(f'{URL}/{lang}/Challenges/')
    if html is None:
        log.error('challenges_page_not_found')
        return

    categories = extract_categories(html)
    if not categories:
        log.warn('fetch_all_categories_failed', lang=lang)
        return

    log.debug('fetched_categories', categories=categories, lang=lang)
    tp_func = partial(retrieve_category_info, lang)
    with ThreadPool(len(categories)) as tp:
        response = tp.map(tp_func, categories)

    timestamp = datetime.now().isoformat()
    await app.redis.set(
        f'{lang}.challenges',
        json.dumps({
            'body': response,
            'last_update': timestamp
        }))
    await app.redis.set(
        f'{lang}.categories',
        json.dumps({
            'body': categories,
            'last_update': timestamp
        }))
    for category_data in response:
        await app.redis.set(
            f'{lang}.categories.{category_data[0]["name"]}',
            json.dumps({
                'body': category_data,
                'last_update': timestamp
            }))

    log.debug('set_all_challenges_success', lang=lang)
コード例 #5
0
ファイル: __init__.py プロジェクト: ddinsight/dd-streamworks
                    ON DUPLICATED UPDATE
                      lat = IF(VALUES(seq) > seq, VALUES(lat), lat),
                      lng = IF(VALUES(seq) > seq, VALUES(lng), lng),
                      seq = IF(VALUES(seq) > seq, VALUES(seq), seq),
                      acc = IF(VALUES(seq) > seq, VALUES(acc), acc),
                      geosrc=VALUES(geosrc)"""

    try:
        strSql = strSql % (node.bssid, node.ssid, node.regdtm, int(node.bregap), int(node.bmap), node.geoloc.lat, node.geoloc.lng, node.geoloc.acc, node.geoloc.geosrc, node.optrcom, node.rssi)
    except Exception, e:
        log.error("SQL GEN ERR - %s" % bytes(node.ssid))
        strSql = strSql % (node.bssid, '', node.regdtm, int(node.bregap), int(node.bmap), node.geoloc.lat, node.geoloc.lng, node.geoloc.acc, node.geoloc.geosrc, node.optrcom, node.rssi)

    try:
        cursor.execute(strSql)
        log.debug("INSERT - %s" % node.bssid)
    except Exception, e:
        # Duplicate entry error
        if e[0] != 1062:
            log.error(e)
            log.error(strSql)
        return False

    return True


netTypeCode = {'gsm':1, 'cdma':2, 'lte':3}


def addCellTower(cursor, node):
    strSql = """INSERT INTO
コード例 #6
0
ファイル: profile.py プロジェクト: zteeed/Root-Me-API
async def set_user_profile(username: str, lang: str) -> None:
    response = get_user_profile_data(username, lang)
    response = {'body': response, 'last_update': datetime.now().isoformat()}
    await app.redis.set(f'{lang}.{username}', json.dumps(response))
    await app.redis.set(f'{lang}.{username}.profile', json.dumps(response))
    log.debug('set_user_profile_success', username=username, lang=lang)