Exemplo n.º 1
0
def scrape_events(num):
    # Most of this is cribbed from obra_upgrade_calculator.commands
    if 'NO_SCRAPE' in os.environ:
        logger.debug('Year scrape disabled by NO_SCRAPE')
        return

    global full_scrape_done
    cur_year = date.today().year

    if full_scrape_done:
        years = [cur_year]
    else:
        years = range(cur_year - 6, cur_year + 1)
        full_scrape_done = True

    for discipline in data.DISCIPLINE_MAP.keys():
        clear_cache = False

        # Do the entire discipline re-scrape in a transaction
        with models.db.atomic('IMMEDIATE'):
            for year in years:
                scrapers.scrape_year(year, discipline)
                scrapers.scrape_parents(year, discipline)
                scrapers.clean_events(year, discipline)

            if scrapers.scrape_new(discipline):
                if upgrades.recalculate_points(discipline, incremental=True):
                    rankings.calculate_race_ranks(discipline, incremental=True)
                    upgrades.sum_points(discipline)
                    upgrades.confirm_pending_upgrades(discipline)
                    clear_cache = True

        if clear_cache:
            uwsgi.cache_clear('default')
Exemplo n.º 2
0
def invalidate_cache(cache_name):
    """Deletes everything in the specificed cache"""
    try:
        import uwsgi

        uwsgi.cache_clear(cache_name)
    except ImportError:
        pass
Exemplo n.º 3
0
def scrape_recent(num):
    if 'NO_SCRAPE' in os.environ:
        logger.debug('Recent event re-scrape disabled by NO_SCRAPE')
        return

    for discipline in data.DISCIPLINE_MAP.keys():
        clear_cache = False

        # Do the entire discipline update in a transaction
        with models.db.atomic('IMMEDIATE'):
            if scrapers.scrape_recent(discipline, 3):
                if upgrades.recalculate_points(discipline, incremental=True):
                    rankings.calculate_race_ranks(discipline, incremental=True)
                    upgrades.sum_points(discipline)
                    upgrades.confirm_pending_upgrades(discipline)
                    clear_cache = True

        if clear_cache:
            uwsgi.cache_clear('default')
Exemplo n.º 4
0
		def clear(self):
			'''
			Clears the cache of all keys/values and returns whether it was successful or not
			'''
			return uwsgi.cache_clear()
Exemplo n.º 5
0
 def setUp(self):
     for cache in self.__caches__:
         uwsgi.cache_clear(cache)
Exemplo n.º 6
0
 def test_multi_clear(self):
     for i in range(0, 100):
         self.assertTrue(uwsgi.cache_clear('items_4_10'))
Exemplo n.º 7
0
 def cache_clear(self):
     ''' '''
     return uwsgi.cache_clear()
from flask_login import login_required

SPOTIFY_API_BASE_URL = 'https://api.spotify.com'
API_VERSION = "v1"
SPOTIFY_API_URL = "{}/{}".format(SPOTIFY_API_BASE_URL, API_VERSION)

USER_PROFILE_ENDPOINT = "{}/{}".format(SPOTIFY_API_URL, 'me')
USER_PLAYLISTS_ENDPOINT = "{}/{}".format(USER_PROFILE_ENDPOINT, 'playlists')
USER_TOP_ARTISTS_AND_TRACKS_ENDPOINT = "{}/{}".format(USER_PROFILE_ENDPOINT,
                                                      'top')  # /<type>
USER_RECENTLY_PLAYED_ENDPOINT = "{}/{}/{}".format(USER_PROFILE_ENDPOINT,
                                                  'player', 'recently-played')
BROWSE_FEATURED_PLAYLISTS = "{}/{}/{}".format(SPOTIFY_API_URL, 'browse',
                                              'featured-playlists')

uwsgi.cache_clear()

spot = Blueprint('project_spotify', __name__)


@spot.route("/projects/spotify_auth/")
@login_required
def auth():
    response = startup.getUser()
    return redirect(response)


@spot.route("/projects/spotify_callback/")
@login_required
def callback():
    startup.getUserToken(request.args.get('code'))
Exemplo n.º 9
0
def clear_cache():
    if UWSGI:
        uwsgi.cache_clear()
    else:
        _cache.clear()