Example #1
0
 def __init__(self, subreddit='FusionTest'):
     self.cred = credentials.read_credentials('reddit')
     self.connection = praw.Reddit(
         client_id=self.cred['reddit']['client_id'],
         client_secret=self.cred['reddit']['client_secret'],
         user_agent=self.cred['reddit']['user_agent'],
         username=self.cred['reddit']['username'],
         password=self.cred['reddit']['password'])
     self.subreddit = self.connection.subreddit(subreddit)
Example #2
0
def test_read_credentials_when_deployed():
    with open('pytest_data/vcap_services.json') as ifile:
        json_string = ifile.read()

    os.environ['VCAP_SERVICES'] = json_string
    os.environ['CONVERSATION_WORKSPACE_ID'] = "fake workspace id"

    expected_output = {
        'CONVERSATION_USERNAME': '******',
        'CONVERSATION_PASSWORD': '******',
        'CONVERSATION_WORKSPACE_ID': "fake workspace id",
        'TRANSLATOR_USERNAME': '******',
        'TRANSLATOR_PASSWORD': '******'
    }
    output = credentials.read_credentials_when_deployed()
    assert output == expected_output

    output = credentials.read_credentials()
    assert output == expected_output
def start_discord_bot(clear_database, no_reddit):
    # create database connection
    db_log.info('Starting connection')
    db = Backend()
    if clear_database:
        db_log.info('Clearing database')
        db.destroy_db()
        db.initialize_db()

    # create reddit connection
    reddit_log.info('Starting connection')
    sr = fusion_subreddit()
    sr.test_bot_authentication()

    # create discord bot and pass it credentials as well as other connections
    cred = credentials.read_credentials('discord')
    bot.subreddit = sr
    bot.backend = db

    # bot.loop.create_task(check_subreddit())
    bot.no_reddit = no_reddit
    bot.run(cred['discord']['bot_token'])
Example #4
0
 def __init__(self):
     # self.process_eq_board()
     cred = read_credentials('trello')
     self.client = TrelloClient(api_key=cred['trello']['api_key'],
                                api_secret=cred['trello']['api_secret'],
                                token=cred['trello']['api_token'])
Example #5
0
 def main(self):
     cred = read_credentials('pocket')
     self.instance = p.Pocket(
         consumer_key=cred['pocket']['consumer_key'],
         access_token=cred['pocket']['access_token'],
     )
Example #6
0
    def main(self):
        cred = read_credentials('dropbox')
        dbx = dropbox.Dropbox(cred['dropbox']['access_token'])

        dbx.users_get_current_account()
Example #7
0
 def __init__(self):
     cred = read_credentials('twitch')
     self.client = twitch.Helix(cred['twitch']['client_id'])
Example #8
0
 def test_read(self):
     c = read_credentials('test')
     self.assertEqual(c['test']['client_id'], 'deadbeef')
     self.assertEqual(c['test']['client_secret'],
                      'blah blah whoanelly-77777777.123123Az')
Example #9
0
                except (NoSuchElementException):
                    log.warning(
                        f'Did not find \'Like\' button on loaded page. Probably browser did not load it fast enough.'
                    )

                self._mock_user_delay(2, 1)

            if len(liked_posts) > PHOTOS_PER_PAGE:
                photo_number_diff = len(liked_posts) - PHOTOS_PER_PAGE
                for _ in range(photo_number_diff):
                    liked_posts.pop(0)

            log.info(f'Liked {liked_posts_counter} posts so far.')
            self._wait_for_browser(30)


# TODO: Allow for more than 1 hashtag and introduce multithreading for that.
if __name__ == '__main__':
    credential = credentials.read_credentials()
    if len(HASHTAGS) is not 1:
        log.exception(
            f'Liking only one hashtag at the time is presetly implemented.')
        raise exceptions.NoImplementation

    for hashtag in HASHTAGS:
        with Instagram(hashtag) as instagram:
            try:
                instagram.login(credential.login, credential.password)
                instagram.like_photos()
            except (KeyboardInterrupt):
                instagram.close()