示例#1
0
def redditTerminalBackground(arg):
    for submission in reddit.subreddit(arg).random_rising(limit=25):

        # ensuring nobody gets fired
        if submission.over_18:
            print("THIS IS NSFW WE ARE SKIPPIN")
            continue

        print('trying to download: ' + submission.url)
        # the url ends in jpg, jpeg, or png, so we know we can download the image
        if (re.search('(.jpg|.jpeg|.png)$', submission.url)):
            # just force it to a jpg
            downloadImage(submission.url, 'downloadedPic.jpg')
            scripter.change_terminal()
            break
        #it didn't end in jpg, but it is on imgur
        elif ('imgur.com' in submission.url):
            if ('imgur.com/a/' in submission.url
                    or 'imgur.com/gallery' in submission.url):
                #it's an album, so skip
                continue
            elif (re.search('(.gif|.gifv)$', submission.url)):
                #it's a gif, skip
                continue
            else:
                #append .jpg to the end of the url then download image
                downloadImage(submission.url + '.jpg', 'downloadedPic.jpg')
                scripter.change_terminal()
                break
示例#2
0
def slideshow(db, start, end):
    # Show each Pokemon in order, one by one.
    try:
        for x in range(start, end):
            pokemon = db.get_pokemon(x)
            scripter.change_terminal(pokemon)
            time.sleep(0.25)
    except KeyboardInterrupt:
        print("Program was terminated.")
        sys.exit()
示例#3
0
def change_terminal_background(db, arg):  # arg is a pokemon_name
    """Change the terminal background to the specified Pokemon, if it exists."""
    if arg in db:
        pokemon = db.get_pokemon(arg)
        scripter.change_terminal(pokemon.get_path())
    else:  # If not found in the database, try to give suggestions.
        suggestions = db.names_with_infix(arg)
        if len(suggestions) == 0:
            print("No such Pokemon was found and no suggestions are available.")
        else:
            pokemon = suggestions[0]
            scripter.change_terminal(pokemon.get_path())
            print("Did you mean {}?".format(pokemon.get_name().title()))
            if len(suggestions) > 1:
                print("Other suggestions:")
                print_columns(suggestions[1:])
示例#4
0
def slideshow(db, start, end, seconds="0.25", rand=False):
    delay = 0.25
    if seconds is not None:
        delay = float(seconds)

    # Show each Pokemon, one by one.
    r = list(range(start, end))
    if rand:
        random.shuffle(r)
    try:
        for x in r:
            pokemon = db.get_pokemon(x)
            scripter.change_terminal(pokemon.get_path())
            time.sleep(delay)
    except KeyboardInterrupt:
        print("Program was terminated.")
        sys.exit()
示例#5
0
def main(argv=sys.argv):
    """Entrance to the program."""
    if len(argv) == 1:
        print('No command line arguments specified.')
        return
    if argv[1] == "random":
        print('choosing random wallpaper')
        fpath = random.choice(
            glob.glob("/home/shubh/Documents/term_wall/Data/*"))
    elif len(
            glob.glob("/home/shubh/Documents/term_wall/Data/*" + argv[1] +
                      "*")) > 0:
        fpath = random.choice(
            glob.glob("/home/shubh/Documents/term_wall/Data/*" + argv[1] +
                      "*"))
    else:
        print("no such background exists")
        fpath = "/home/shubh/Documents/term_wall/Data/black.jpg"
    scripter.change_terminal(fpath)
示例#6
0
def change_terminal_background(arg):
    #next step here is to just check submission.url to see if it ends in jpg, then check if it's a common image upload site like imgur
    for submission in reddit.subreddit(arg).hot(limit=3):
        print(submission.url)
        if ('imgur.com' in submission.url):
            if ('imgur.com/a/' in submission.url):
                #it's an album, so skip
                continue
            elif ('jpg' in submission.url):
                #download image right away
                downloadImage(submission.url, 'downloadedPic.jpg')
                scripter.change_terminal()
                break
            else:
                #append .jpg to the end of the url then download image
                downloadImage(submission.url + '.jpg', 'downloadedPic.jpg')
                scripter.change_terminal()
                break
        else:
            print('not imgur')
示例#7
0
def change_terminal_background(db, arg):
    # Change the terminal background to the specified Pokemon, if it exists.
    if arg in db:
        pokemon = db.get_pokemon(arg)
        scripter.change_terminal(pokemon)
    else:  # If not found in the database, try to give suggestions.
        suggestions = db.names_with_infix(arg)
        if len(suggestions) == 0:
            print(
                "No such Pokemon was found and no suggestions are available.")
        elif len(suggestions) == 1:
            scripter.change_terminal(suggestions[0])
            print("Did you mean " + suggestions[0].get_name().capitalize() +
                  "?")
            scripter.change_terminal(suggestions[0])
        else:
            print("Did you mean " + suggestions[0].get_name().capitalize() +
                  "?")
            print("Other suggestions:")
            print_columns(suggestions[1:])
            scripter.change_terminal(suggestions[0])