import feedparser

from ebi import oauthtwitter
import logging
import urllib2
import json

from django.conf import settings

def get_feed(url):
    if url:
        try:
            feed = urllib2.urlopen(url, timeout=2)
            content = feed.read()
        except:
            content = ''
        return feedparser.parse(content)

def feed_first_entry(url):
    try:
        return feed_entries(url)[0]
    except:
        pass

    return {}
    
def feed_entries(url):
    feed = get_feed(url)

    if feed and len(feed['entries']) > 0:
        return feed['entries']

    return []
    
def send_tweet(msg):
    api = oauthtwitter.OAuthApi('E0iCfzFo5Xzx64kYGvIa8w', '<KEY>', token='<KEY>', token_secret='<KEY>')
    
    try:
        status = api.UpdateStatus(msg.encode('utf-8'))
        logging.info('sent tweet %s', str(status))
        
        return status
    except:
        logging.error('sending tweet %s failed', msg)
import feedparser

from ebi import oauthtwitter
import logging
import urllib2
import json

from django.conf import settings

def get_feed(url):
    if url:
        try:
            feed = urllib2.urlopen(url, timeout=2)
            content = feed.read()
        except:
            content = ''
        return feedparser.parse(content)

def feed_first_entry(url):
    try:
        return feed_entries(url)[0]
    except:
        pass

    return {}
    
def feed_entries(url):
    feed = get_feed(url)

    if feed and len(feed['entries']) > 0:
        return feed['entries']

    return []
    
def send_tweet(msg):
    api = oauthtwitter.OAuthApi('E0iCfzFo5Xzx64kYGvIa8w', '<KEY>', token='<KEY>', token_secret='<KEY>')
    
    try:
        status = api.UpdateStatus(msg.encode('utf-8'))
        logging.info('sent tweet %s', str(status))
        
        return status
    except:
        logging.error('sending tweet %s failed', msg)