def test_get_home_dir(): username = podium.get_username() assert username in podium.get_home_dir()
def test_read_ini(): ini_file = '{home}/.mozilla/firefox/profiles.ini'.format( home=podium.get_home_dir()) path = ini.read_ini('Profile0', ini_file)['path'] assert re.search('.{8}\.default', path)
#!/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.podium import podium TIMEOUT = 3 # put a symbolic link on an audio file in your HOME directory called ~/net_alive.mp3 AUDIO = podium.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) #############################################################################
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.podium import podium USERNAME_TXT = '{home}/reddit_username.txt'.format(home=podium.get_home_dir()) PASSWORD_TXT = '{home}/reddit_password.txt'.format(home=podium.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
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.podium import podium from urllib import quote WORDNIK = '{home}/wordnik.txt'.format(home=podium.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): """
def test_read_ini(): ini_file = '{home}/.mozilla/firefox/profiles.ini'.format(home=podium.get_home_dir()) path = ini.read_ini('Profile0', ini_file)['path'] assert re.search('.{8}\.default', path)
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.podium import podium from urllib import quote WORDNIK = '{home}/wordnik.txt'.format(home=podium.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)