Пример #1
0
def getShowsAsJson(tot=HARD_LIMIT, from_show=None):
    try: tot=int(tot)
    except: tot = HARD_LIMIT
    try: from_show = int(from_show)
    except: from_show = ShowBusiness.getLatestShowNum()

    shows = ShowBusiness.getShowsBefore(from_show, min(tot, HARD_LIMIT))
    return map(ShowBusiness.showToObj, shows)
Пример #2
0
def getShowTracksAsJson(from_show):
    if from_show in [IntType,LongType]:
        from_show = ShowBusiness.getShow(from_show)
    tracks = map(lambda x: {'artist':x['artist'], 
                            'title':x['title'],
                            'start_mspos':x['start_mspos']
                            }, ShowBusiness.getShowTracks(from_show))
    return json.dumps(tracks)
Пример #3
0
def test_showDatastoreAccess():
    cnt = ShowBusiness.getShowCount()
    assert type(cnt) == IntType

    sh = ShowBusiness.addShow("asdf", 3, date(10, 2, 4), "asdfasdf", "asdfasfd", 10, [])
    assert ShowBusiness.getShowCount() == cnt+1
    db.delete(sh)
    assert ShowBusiness.getShowCount() == cnt
Пример #4
0
def test_refreshShowIndex():
    show_cnt = ShowBusiness.getShowCount()

    newnum = ShowScrape.refreshShowIndex(650)
    assert ShowBusiness.getShowCount() == newnum+show_cnt

    ## do it twice and make sure it doesn't repeat
    ShowScrape.refreshShowIndex(600)
    assert ShowBusiness.getShowCount() == newnum+show_cnt
Пример #5
0
def test_scrapeAndStore():

    show_info = ShowScrape.parseShowPage(open(SHOW_PAGE,"r").read())
    assert len(show_info["tracks"]) > 0

    sh_cnt = ShowBusiness.getShowCount()
    show = ShowBusiness.addShow(**show_info)
    assert ShowBusiness.getShowCount() == sh_cnt+1
    assert ShowBusiness.getShow(show_info["number"]) != None
    assert ShowBusiness.getShowTrackCount(show_info["number"]) > 0
Пример #6
0
def pullShowInfo(show):
    if ShowBusiness.getShow(show["number"]) != None:
        return False  ## already in datastore
    show_url = urllib.basejoin(SHOW_URL, show['href'])

    logging.debug("adding show to queue: %s" % (show_url,))
    taskqueue.add(url='/admin/update/%s/' % (urllib.quote_plus(show_url),))
    return True
Пример #7
0
def clear_all_shows():
    return "%s shows cleared" % (str(ShowBusiness.clearAllShows()),)
Пример #8
0
def del_show(shownum):
    return ShowBusiness.deleteShow(shownum)
Пример #9
0
def get_tracks_for_show(show):
    return ",".join(ShowBusiness.getShowTracks(show))
Пример #10
0
def addShowFromPage(show_url):
    show_url = urllib.unquote_plus(show_url)
    show_info = parseShowPage(fetchPage(show_url))
    ShowBusiness.addShow(**show_info)