示例#1
0
async def get_wine_ratings():
    start = datetime.now()
    styledprint.print_info_begin('Getting Wine Ratings')
    ratings = await winelist.get_ratings()
    styledprint.print_info_begin('Getting Wine Ratings Done')
    end = datetime.now()
    styledprint.print_debug('get_wine_ratings took:',
                            (end - start).total_seconds())
    return ratings
示例#2
0
async def get_applist(options):
    start = datetime.now()
    styledprint.print_info_begin('AppList Refresh')
    applist = await steamlist.refresh_applist(options.dryrun,
                                              options.skip,
                                              from_scratch=False)
    styledprint.print_info_begin('AppList Refresh Done')
    end = datetime.now()
    styledprint.print_debug('get_applist took:', (end - start).total_seconds())
    return applist
示例#3
0
async def parse_list(options):
    start = datetime.now()
    styledprint.print_info_begin('Parsing HFR')
    if (options.liste == None):
        games = await hfrparser.parse_hfr()
    else:
        games = await hfrparser.parse_list(options.liste)
    styledprint.print_info_end('Parsing HFR Done')
    end = datetime.now()
    styledprint.print_debug('parse_list took:', (end - start).total_seconds())
    return games
示例#4
0
def merge_applists(first, second):
    for name in second:
        if (name in first):
            styledprint.print_debug('{} in first'.format(name))
            for t in second[name]:
                if (t not in first[name]):
                    styledprint.print_debug(
                        't {} not in first[name]'.format(t))
                    first[name].append(t)
                else:
                    styledprint.print_debug('t {} in first[name]'.format(t))
        else:
            styledprint.print_debug('{} not in first'.format(name))
            first[name] = second[name]
示例#5
0
async def get_game_info(options, game, cachedgames, steamgames, winedb,
                        cleansteamgames, cleanwinedb, name, urlsmapping,
                        webSession):
    try:
        if ((not options.all) and (not game.hfr.is_available)):
            # Ignoring not available games for now
            # it may be better in the future to ignore them in output
            # or allow the user to do so in the html page.
            return

        cleanname = None
        #cache    = webSession.cache

        if (name in cachedgames):
            # Whether the cache is ignored or not,
            # if a game cached has a gift_date we keep it
            if (cachedgames[name].hfr.gift_date):
                game.hfr.gift_date = cachedgames[name].hfr.gift_date

            if (not options.ignorecache):
                game.store = cachedgames[name].store
                game.wine = cachedgames[name].wine

        # query the store if:
        # - not cacheonly
        # - not in cache
        # - in cache and to be refreshed
        if ((not options.cacheonly) and
            ((not game.store.link) or
             ((options.game) and (options.game.lower() in name.lower())))):

            # keep the old information if there is no new one
            if (game.store.link):
                storeBU = copy.deepcopy(game.store)
                worked = await steam.get_store_info(game, name, webSession)
                if (worked):
                    styledprint.print_info(
                        'Info for game {0} was retrieved, {1}'.format(
                            name, str(datetime.now().time())))
                else:
                    game.store = storeBU
            else:
                mapping = urlsmapping.get_mapping(name)

                if (mapping == None):
                    appidstried = []
                    matches = None
                    while (True):
                        appid, typ = get_appid_and_type(
                            name, steamgames, appidstried)
                        if (appid):
                            styledprint.print_debug(
                                'The game {0} got its appid simply'.format(
                                    name))
                        elif (options.fuzzymatching):
                            # it seems quicker to recompute it than use redis
                            #cleanname = await cache.function(namematching.nameclean, name)
                            cleanname = namematching.nameclean(name)
                            appid, typ = get_appid_and_type(
                                cleanname, cleansteamgames, appidstried)
                            if (appid):
                                styledprint.print_debug(
                                    'The game {0} got its appid '
                                    'by namecleaning'.format(name))
                            else:
                                appid, typ = get_appid_and_type_from_namematching(
                                    name, cleanname, cleansteamgames,
                                    appidstried, matches)

                        if ((appid in appidstried) or (not appid)):
                            game.store = StoreData()
                            game.store.description = 'The game was not found in the steam db'
                            styledprint.print_error('{0}: {1}'.format(
                                game.store.description, name))
                            cleanname = None
                            return
                        else:
                            appidstried.append(appid)

                            if (await steam.get_store_info_from_appid(
                                    game, name, appid, typ, webSession)):
                                break

                else:
                    url = mapping[0]

                    if (url == 'ignore'):
                        styledprint.print_debug(
                            '{0} cannot be found and is to be ignored'.format(
                                name))
                        return

                    styledprint.print_debug(
                        'URL mapping found for game {0}'.format(name))
                    await steam.get_store_info_from_url(
                        game, name, url, webSession)
                    # overwriting the steam provided category
                    if (len(mapping) == 2):
                        game.store.category = Category[mapping[1].upper()]
                        game.store.override = True

                styledprint.print_info(
                    'Info for game {0} was retrieved, {1}'.format(
                        name, str(datetime.now().time())))

        # TODO
        # compute cleanname once
        # cache heavy stuff
        if (name in winedb):
            game.wine = winedb[name]
        elif (options.fuzzymatching):
            if (cleanname is None):
                # it seems quicker to recompute it than use redis
                #cleanname = await cache.function(namematching.nameclean, name)
                cleanname = namematching.nameclean(name)
            if (cleanname in cleanwinedb):
                game.wine = cleanwinedb[cleanname]
            else:
                cleanmatches = get_clean_matches(cleanname, cleanwinedb)
                if (len(cleanmatches)):
                    game.wine = cleanwinedb[cleanmatches[0]]

    except Exception as e:
        styledprint.print_error('An exception was raised for', name)
        raise e
示例#6
0
    try:
        tasks = [
            asyncio.ensure_future(get_applist(options)),
            asyncio.ensure_future(get_wine_ratings()),
            asyncio.ensure_future(parse_list(options))
        ]

        loop.run_until_complete(asyncio.gather(*tasks))
        steamgames = tasks[0].result()
        winedb = tasks[1].result()
        games = tasks[2].result()

        start = datetime.now()
        gamesinfo.get_games_info(options, games, steamgames, winedb)
        end = datetime.now()
        styledprint.print_debug('get_games_info took:',
                                (end - start).total_seconds())

        start = datetime.now()
        write_output_files(options, games)
        end = datetime.now()
        styledprint.print_debug('write_output_files took:',
                                (end - start).total_seconds())

    except Exception as e:
        print(e)
        print(traceback.format_exc())

    parallelism.shutdown_pool(wait=True)
    # this genereates a stack overflow
    # when the loop was previously stopped
    #loop.close()