Ejemplo n.º 1
0
    def setUp(self):
        """
        Required Setup for testing:
            -Create a user with permission to add favourites
            -Create a user with default premissions
            -Create a show with dummy data
            -Create blank user profile so favourites can be added
        """
        user = User.objects.create_user('john', '*****@*****.**',
            'password')
        perm = Permission.objects.get(codename="can_have_favs")
        user.save()
        user.user_permissions.add(perm)
        profile = UserProfile()
        profile.user = user
        profile.save()

        user = User.objects.create_user('jane', '*****@*****.**',
            'password')
        user.save()
        profile = UserProfile()
        profile.user = user
        profile.save()

        new_show = Show()
        new_show.name = "Some test show"
        new_show.id = 1234
        new_show.save()

        new_entry = GuideEntry()
        #Compile a date/time stamp for the show
        year = datetime.now().strftime("%Y")
        month = datetime.now().strftime("%m")
        day = datetime.now().strftime("%d")
        date_object = datetime.strptime(year + '-' + month
            + '-' + day + ' 5:00 pm', '%Y-%m-%d %I:%M %p')
        new_entry.start = date_object
        new_entry.network = "SPIKE TV"
        new_entry.show = new_show
        new_entry.save()
Ejemplo n.º 2
0
    def setUp(self):
        """
        Required Setup for testing:
            -Create a user with permission to add favourites
            -Create a user with default premissions
            -Create a show with dummy data
            -Create blank user profile so favourites can be added
        """
        user = User.objects.create_user('john', '*****@*****.**',
                                        'password')
        perm = Permission.objects.get(codename="can_have_favs")
        user.save()
        user.user_permissions.add(perm)
        profile = UserProfile()
        profile.user = user
        profile.save()

        user = User.objects.create_user('jane', '*****@*****.**',
                                        'password')
        user.save()
        profile = UserProfile()
        profile.user = user
        profile.save()

        new_show = Show()
        new_show.name = "Some test show"
        new_show.id = 1234
        new_show.save()

        new_entry = GuideEntry()
        #Compile a date/time stamp for the show
        year = datetime.now().strftime("%Y")
        month = datetime.now().strftime("%m")
        day = datetime.now().strftime("%d")
        date_object = datetime.strptime(
            year + '-' + month + '-' + day + ' 5:00 pm', '%Y-%m-%d %I:%M %p')
        new_entry.start = date_object
        new_entry.network = "SPIKE TV"
        new_entry.show = new_show
        new_entry.save()
Ejemplo n.º 3
0
import urllib2
from django.core.management.base import BaseCommand, CommandError
from xml.dom.minidom import parse, parseString
from tvSite.guide.models import Show, GuideEntry
from datetime import datetime

def dlGuide():
    """
    This function will download the XML file from the site provided
    and parse it into the database
    """
    xml_guide_url = "http://services.tvrage.com/feeds/fullschedule.php?country=US"
    print "Downloading TV Guide... "
    try:
        req = urllib2.Request(xml_guide_url)
        handle = urllib2.urlopen(req)
        thepage = handle.read()
    except Exception, e:
        print "failed to retrieve XML data"
        return
    print "Parsing XML File... "
    dom = parseString(thepage)  
    objList = []
    print "Adding entries to DB... "
    for day_node in dom.getElementsByTagName("DAY"):
        for time_node in day_node.getElementsByTagName("time"):
            for show_node in time_node.getElementsByTagName("show"):
                sid = -1
                #Get the show ID
                for a_node in show_node.getElementsByTagName("sid"): 
Ejemplo n.º 4
0
import urllib2
from django.core.management.base import BaseCommand, CommandError
from xml.dom.minidom import parse, parseString
from tvSite.guide.models import Show, GuideEntry
from datetime import datetime

def dlGuide():
    """
    This function will download the XML file from the site provided
    and parse it into the database
    """
    xml_guide_url = "http://services.tvrage.com/feeds/fullschedule.php?country=US"
    print "Downloading TV Guide... "
    try:
        req = urllib2.Request(xml_guide_url)
        handle = urllib2.urlopen(req)
        thepage = handle.read()
    except Exception, e:
        print "failed to retrieve XML data"
        return
    print "Parsing XML File... "
    dom = parseString(thepage)
    objList = []
    print "Adding entries to DB... "
    for day_node in dom.getElementsByTagName("DAY"):
        for time_node in day_node.getElementsByTagName("time"):
            for show_node in time_node.getElementsByTagName("show"):
                sid = -1
                #Get the show ID
                for a_node in show_node.getElementsByTagName("sid"):