Ejemplo n.º 1
0
def main():

    parser = argparse.ArgumentParser(
        description="Populate a category and the pages associated with it")
    parser.add_argument("-a", "--append", type=int,default=True,
                        help="if set to false deletes category from database\
                        if already present.")
    #TODO(mtbvc):won't need this
    parser.add_argument("-cn", "--category_name", type=str,
                        help="Name of category.")
    parser.add_argument("-f", "--filename",
                        default= os.getcwd() + '/data/trends/game_data.txt', type=str,
                        help="relative path to population data file")
    parser.add_argument("-l", "-local", type=str, default=False,
                        help="If populating images from disk use this flag")

    args = parser.parse_args()
    if args.filename:
        data_list = get_trending_queries(args.filename)
        for data_tuple in data_list:
            cat = game_model_functions.get_category(data_tuple[0],'icon','',append=args.append)
            #data_tuple[1] is url
            #game_model_functions.populate_pages([data_tuple[1]],cat)
            deployment_model_functions.populate_pages([data_tuple[1]],cat,halved_screen_shot=True)
        return 0
    else:
        print parser.print_help()
        return 2
Ejemplo n.º 2
0
def main():
    populate_cats()
    #split line into tokens
    meta_data_file = sys.argv[1]
    data_list = get_trending_queries(meta_data_file)
    for data_tuple in data_list:
        cat = game_model_functions.get_category(data_tuple[0],'icon','',append=True)
        p = Page(category=cat, title=data_tuple[2], is_shown=True, url=data_tuple[1], screenshot=data_tuple[3])
        p.save()
    return 0
Ejemplo n.º 3
0
def populate_cats():
    game_model_functions.get_category('Space Objects', 'cat_images/the25.png','SpaceObjects',append=True)
    game_model_functions.get_category('Actors', 'cat_images/oscars.png', 'Actors', append=True)
    game_model_functions.get_category('Musical Artists','cat_images/dj1.png','MusicalArtists',append=True)
    game_model_functions.get_category('Films', 'cat_images/clapper.png','Films',append=True)
    game_model_functions.get_category('Games', 'cat_images/games4.png','Games',append=True)
    game_model_functions.get_category('Kids TV', 'cat_images/television4.png','KidsTv',append=True)
    game_model_functions.get_category('Business People', 'cat_images/career.png','BusinessPeople',append=True)
    game_model_functions.get_category('Universities', 'cat_images/university2.png','Universities',append=True)