Ejemplo n.º 1
0
To use this API, you'll need an API key, which you can get 
at http://api.wordnik.com/signup .

Once you got your API key, put it in the following file: ~/wordnik.txt

# from jabbapylib.dictionary import wordnik
"""

import json
from jabbapylib.web.web import get_page
from jabbapylib.filesystem import fs
from jabbapylib.platform import platform
from urllib import quote

WORDNIK = '{home}/wordnik.txt'.format(home=platform.get_home_dir())

############
## common ##
############

def add_api_key(url):
    """
    Adds your API key to the end of the URL.
    """
    key = fs.read_first_line(WORDNIK)
    sep = '&' if '?' in url else '?'
    return '{url}{sep}api_key={key}'.format(url=url, sep=sep, key=key)

def prepare_url(template, word):
    """
Ejemplo n.º 2
0
def test_get_home_dir():
    username = platform.get_username()
    assert username in platform.get_home_dir()
Ejemplo n.º 3
0
#!/usr/bin/env python

"""
Play a sound when the Internet connection is back.
"""

import socket
from time import sleep
from jabbapylib.network import network
from jabbapylib.multimedia.play import play
from jabbapylib.platform import platform

TIMEOUT = 3
# put a symbolic link on an audio file in your HOME directory called ~/net_alive.mp3
AUDIO = platform.get_home_dir() + '/net_alive.mp3'


def main():
    cnt = 0
    while True:
        cnt += 1
        print '# testing...' if cnt == 1 else '# test again...'
        if network.is_internet_on(method=2):
            print '# Whoa, your net is alive!'
            play(AUDIO)
            break
        else:
            print '# no connection, waiting...'
            sleep(10)

#############################################################################
Ejemplo n.º 4
0
class HyperBot(RedBot):
    def __init__(self):
        super(HyperBot, self).__init__()
        self.name = 'HyperBot'
        
Now you are ready to flood reddit :)

# from jabbapylib.reddit import red
"""

import sys
import reddit
from jabbapylib.filesystem import fs
from jabbapylib.platform import platform

USERNAME_TXT = '{home}/reddit_username.txt'.format(home=platform.get_home_dir())
PASSWORD_TXT = '{home}/reddit_password.txt'.format(home=platform.get_home_dir())
#
USERNAME = fs.read_first_line(USERNAME_TXT)
PASSWORD = fs.read_first_line(PASSWORD_TXT)


class RedBot(object):
    def __init__(self):
        self.name = 'RedBot'
        self.username = USERNAME
        self.password = PASSWORD
        #
        self.r = reddit.Reddit(user_agent=self.name)
        self.r.login(username=self.username, password=self.password)
        self.last_post = None   # Submission object
Ejemplo n.º 5
0
def test_read_ini():
    ini_file = '{home}/.mozilla/firefox/profiles.ini'.format(home=platform.get_home_dir())
    path = ini.read_ini('Profile0', ini_file)['path']
    assert re.search('.{8}\.default', path)