示例#1
0
def cache_retry(config, logger):
    """
    Thread timer for the cache retry logic.

    :param config: config (ConfigParser obj)
    """

    retry = 3600
    logger.info('starting cache_retry thread.')
    user_name = config['lastfm']['user_name']
    password = config['lastfm']['password']
    api_key = config['lastfm']['api_key']
    api_secret = config['lastfm']['api_secret']
    cache_location = config['plex-scrobble']['cache_location']

    while True:
        try:
            cache = ScrobbleCache(api_key,
                                  api_secret,
                                  user_name,
                                  password,
                                  cache_location=cache_location)
        except Exception as e:
            logger.warning('ERROR: {0}, retrying in {1} seconds'.format(
                e, retry))
            time.sleep(retry)
            continue
        # do not retry if cache is empty.
        if cache.length() > 0:
            cache.retry_queue()

        time.sleep(retry)
 def setUp(self):
     """ create an empty scrobble_cache object. """
     user_name = password = api_key = api_secret = config['lastfm'][
         'user_name']
     self.sc = ScrobbleCache(
         api_key,
         api_secret,
         user_name,
         password,
         cache_location=config['plex-scrobble']['cache_location'])
     self.album = six.u('Björk').encode('utf-8')
     self.artist = six.u('CR∑∑KS').encode('utf-8')
     self.title = six.u('deep burnt').encode('utf-8')
     self._clean_file()
示例#3
0
def cache_retry(config):
    """
    Thread timer for the cache retry logic.

    :param config: config (ConfigParser obj)
    """

    while True:
        logger.info('starting cache_retry thread.')
        cache = ScrobbleCache(config)
        # do not retry if cache is empty.
        if cache.length() > 0:
            cache.retry_queue()

        cache.close()
        time.sleep(3600)
示例#4
0
 def setUp(self):
     """ create an empty scrobble_cache object. """
     self.sc = ScrobbleCache(config)