Example #1
0
    def testShouldDisplayTheFeed(self):
        app = TestApp(self.application)
        feed = Feed(url='example.com')
        feed.save()

        response = app.get("/feeds/example.com")
        self.assertTrue('<h1>example.com</h1>' in response)
Example #2
0
def run():
    parser = argparse.ArgumentParser(description='Read RSS feeds on any device with an IMAP client.')
    parser.add_argument('-v', '--verbose', action='store_true', help='print verbose output')
    parser.add_argument('-p', '--password', default=None, help='IMAP password')
    parser.add_argument('server', default=None, help='IMAP server')
    parser.add_argument('user', default=None, help='IMAP username')
    options = parser.parse_args()

    if options.verbose:
        logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger(__name__)

    if options.password is None:
        options.password = getpass.getpass('Password for %s: ' % options.user)

    logger.debug('Connecting to %s as %s', options.server, options.user)
    server = Imap(options.server, options.user, options.password)

    for feed_name, feed_url in feeds.items():
        feed = Feed()
        logger.debug("parsing feed %s" % feed_url)
        feed.parsefeed(feed_url)

        for entry in feed.entries:
            server.store_feedentry(entry, feed_name, feed_name)
Example #3
0
def add_feed(params, channel_mentions):
    '''
    Add feed to be check for updates, which will be posted to specificed channel
    Params: feed - Website that will be parsed for updates
            channel - Discord channel where updates will be posted
    '''
    feed = params[0]
    channel = channel_mentions[0]
    global feeds
    feed = Feed(feed, channel)
    feeds.append(feed)
    return Message_Successful_Add_Feed
Example #4
0
File: rss.py Project: stephegn/rss
def getFeed(feedname):
    global processPool

    print(('getting ' + feedname))
    item_node = processor.getXMLItems(feedname)

    #save the title and link of each
    print(feedname)
    if feedname in AllFeeds.feedList:
        print('not new feeds')
    else:
        AllFeeds.feedList[feedname] = Feed(feedname)

    for item in item_node:
        print('add processing task')
        processPool.add_task(processFeed, item, feedname)
    if args.print_log:
        print_log = True
    else:
        print_log = False

    if args.addfeed:
        new_feed_list = args.addfeed.replace(" ", "").split("=")
        config_file.new_feed(new_feed_list[0], new_feed_list[1])

    fd = initFile()
    config = config_file.config_read()

    if print_log:
        print(config['time'])

    email_flag = False

    for i in config['feeds']:
        temp = Feed(i, fd, config['time'], print_log)
        result = temp.feed_write()
        if result is True:
            email_flag = True
    fd.close()

    config_file.write_last_fetch()

    if email_flag is True:
        sendEmail()
    else:
        print("No mail was sent!")
Example #6
0
 def testShouldReturnNoneWhenThereIsNothingToBeFound(self):
     self.assertEquals(None, Feed.find('somthing'))
Example #7
0
 def testShouldFindOneFeed(self):
     self.feed.save()
     Feed(url='example.com').save()
     self.assertEquals('example.com', Feed.find('example.com').url)
Example #8
0
 def testShouldDeleteAnEntry(self):
     self.feed.save()
     self.assertEquals(1, len(Feed.findAll()))
     self.feed.delete()
     self.assertEquals(0, len(Feed.findAll()))
Example #9
0
 def testShouldSaveMoreThanOneFeedAndReturnThem(self):
     self.feed.save()
     Feed(url='some.other.url').save()
     self.assertEquals(2, len(Feed.findAll()))
Example #10
0
 def testShouldSaveAFeedAndReturnAListWithOneFeedOnly(self):
     self.feed.save()
     self.assertEquals(1, len(Feed.findAll()))
Example #11
0
 def testShouldProvideEmptyListIfNoFeedsExist(self):
     self.assertEquals([], Feed.findAll())
Example #12
0
    sys.exit(1)

conf = read_config(sys.argv[1])

print conf

client = BTSX(
    conf["client"]["rpc_user"],
    conf["client"]["rpc_password"],
    conf["client"]["rpc_port"]
)

bter = BterFeeds()
btc38 = BTC38Feeds()
feeds = {}
feeds["bter_usd_per_btsx"] = Feed.from_func(bter.avg_usd_per_btsx)
feeds["btc38_usd_per_btsx"] = Feed.from_func(btc38.last_usd_per_btsx)
feeds["usd_per_btsx"] = Average({k: feeds[k] for k in ["bter_usd_per_btsx"]})

# fetch them all once to cache
for key, feed in feeds.iteritems():
    print key
    print feed.fetch()

bots = []
for botconfig in conf["bots"]:
    bot_type = botconfig["bot_type"]
    if bot_type == "market_maker":
        bots.append(MarketMaker(client, feeds, botconfig, log))
    elif bot_type == "market_speculator":
        bots.append(MarketSpeculator(client, feeds, botconfig, log))
Example #13
0
if len(sys.argv) < 2:
    print "Usage:  main.py config_path"
    sys.exit(1)

conf = read_config(sys.argv[1])

print conf

client = BTSX(conf["client"]["rpc_user"], conf["client"]["rpc_password"],
              conf["client"]["rpc_port"])

bter = BterFeeds()
btc38 = BTC38Feeds()
feeds = {}
feeds["bter_usd_per_btsx"] = Feed.from_func(bter.avg_usd_per_btsx)
feeds["btc38_usd_per_btsx"] = Feed.from_func(btc38.last_usd_per_btsx)
feeds["usd_per_btsx"] = Average(
    {k: feeds[k]
     for k in ["bter_usd_per_btsx", "btc38_usd_per_btsx"]})

# fetch them all once to cache
for key, feed in feeds.iteritems():
    print key
    print feed.fetch()

bots = []
for botconfig in conf["bots"]:
    bot_type = botconfig["bot_type"]
    print bot_type
    if bot_type == "market_maker":