def run(): sh = rmm.TwitterShepherd( KEYSDIR, flock_name = 'milton', sheep_class=rmm.PoemSheep ) if not LIVE: sh.perform_parallel_action( 'tweet', **{ 'publish' : False, 'inner_sleep' : 1, 'outer_sleep' : 1, 'lines_length' : 4 } ) else: sh.perform_parallel_action( 'tweet', **{ 'publish' : True, 'inner_sleep' : 3*60, 'outer_sleep' : 2*3600, 'lines_length' : 4 } )
def shepherd(): sh = rmm.TwitterShepherd( json_keys_dir = 'keys/', flock_name = 'ginsberg bot flock', sheep_class = rmm.PoemSheep ) return sh
def shepherd(): # Create a shepherd using the bot keys # created by the TwitterKeymaker above. sh = rmm.TwitterShepherd(json_keys_dir='keys/', flock_name='lucky penny flock', sheep_class=rmm.SocialSheep) return sh
def test_shepherd(self): """ Create a simple Shepherd. The Shepherd expects keys to exist already (that's the Keymaker's job). It will create one Sheep per key. The Shepherd constructor requires a label for the flock, a directory where JSON keys (one key per Sheep) are located, and what class of Sheep to use when creating Sheep. The Shepherd constructor calls _setup_keys() and _setup_sheep(). Function _setup_keys() expects each key (a dictionary) to contain a key-value pair for 'oauth_token'. This oauth token is what the Keymaker helps you generate. If your keys do not have all required fields, this is the method that will stop you. See _key_is_valid() method in Shepherd.py. Function _setup_sheep() iterates over each key processed by _setup_keys() and makes one Sheep from each key. """ ################################# ##### https://stackoverflow.com/a/31281467 ##### #with patch('sys.stdout', new=StringIO()) as fakeOutput: # print('hello world') # self.assertEqual(fakeOutput.getvalue().strip(), 'hello world') # # this "with" block ensures we capture stdout # with captured_output() as (out, err): # Create the Shepherd (this starts the logger) s = rmm.TwitterShepherd(json_keys_dir='tests/shepherd_test_keys', sheep_class=rmm.TwitterSheep) self.assertLogs('Creating flock') self.assertLogs('Successfully created')
def run(): sh = rmm.TwitterShepherd(KEYSDIR, flock_name='apollo', sheep_class=rmm.QueneauSheep) LIVE = True if not LIVE: sh.perform_parallel_action( 'tweet', **{ 'publish': False, 'inner_sleep': 1, #3*60, 'outer_sleep': 1, #2*3600, 'lines_length': 4 }) else: sh.perform_parallel_action( 'tweet', **{ 'publish': True, 'inner_sleep': 3 * 60, 'outer_sleep': 2 * 3600, 'lines_length': 4 })
def run(): sh = rmm.TwitterShepherd(json_keys_dir=KEYSDIR, flock_name='math_tripos', sheep_class=rmm.PhotoADaySheep) LIVE = True if not LIVE: sh.perform_parallel_action( 'photo_a_day', **{ 'publish': False, 'images_dir': DATADIR, 'images_pattern': '{i:03}.jpg', 'message': 'Your daily Mathematical Tripos question.' }) else: sh.perform_parallel_action( 'photo_a_day', **{ 'publish': True, 'images_dir': DATADIR, 'images_pattern': '{i:03}.jpg', 'message': 'Your daily Mathematical Tripos question.' })
def shepherd(): sh = rmm.TwitterShepherd(json_keys_dir='keys/', flock_name='paradise lost bot flock', sheep_class=rmm.PoemSheep) return sh
def test_queneau_shepherd(self): log_file = 'tests/test_queneau_shepherd.log' sh = rmm.TwitterShepherd(json_keys_dir=self.keys_dir, flock_name='My Fake Flock', sheep_class=rmm.QueneauSheep, log_file=log_file)
def shepherd(): sh = rmm.TwitterShepherd(json_keys_dir='keys/', flock_name='simple flock', sheep_class=TestSocialSheep) return sh
def shepherd(): sh = rmm.TwitterShepherd(json_keys_dir='keys/', flock_name='apollo space junk bot flock', sheep_class=rmm.QueneauSheep) return sh