Example #1
0
    def test_it_allows_set_current_channel_within_a_given_range(self):
        tv = TV(channels=[1, 2, 3, 5])
        for channel in [1, 2, 3, 5]:
            tv.channel = channel
            tv.channel | should | be(channel)

        def set_channel(channel):
            tv.channel = channel

        (set_channel, 0) | should | throw(InvalidChannel)
        (set_channel, 4) | should | throw(InvalidChannel)
        (set_channel, 6) | should | throw(InvalidChannel)
Example #2
0
    def refreshLiveUrl(self):
        if self.shared_data.get('playing.what') == 'nba_tv_live':
            video = TV.get_live()
        elif self.shared_data.get('playing.what') == 'nba_tv_episode':
            start_timestamp = self.shared_data.get('playing.data.start_timestamp')
            duration = self.shared_data.get('playing.data.duration')
            video = TV.get_episode(start_timestamp, duration)

        if video is not None:
            self.readExpiresFromUrl(video)
            utils.log("Updating live url from service, new url (%s) and expire (%d)" % (video, self.expires))
            self.player.play(video)
Example #3
0
class TestTV(unittest.TestCase):

    def setUp(self):
        self.tv1 = TV(5, 10)

    def test_canal(self):
        self.assertEqual(self.tv1.canal, 5)

    def test_aumenta(self):
        self.assertEqual(self.tv1.aumentar(15), 25)

    def test_diminui(self):
        self.assertEqual(self.tv1.diminuir(6), 4)
Example #4
0
    def refreshLiveUrl(self):
        if self.shared_data.get('playing.what') == 'nba_tv_live':
            video_url = TV.get_live_url(force_login=True)
        elif self.shared_data.get('playing.what') == 'nba_tv_episode':
            start_timestamp = self.shared_data.get('playing.data.start_timestamp')
            duration = self.shared_data.get('playing.data.duration')
            video_url = TV.get_episode_url(start_timestamp, duration, force_login=True)

        if video_url:
            self.readExpiresFromUrl(video_url)
            utils.log("Updating live url from service, new url (%s) and expire (%d)" 
                % (video_url, self.expires))

            self.player.play(video_url)
Example #5
0
def createTVObjects(tvList):
	# Creates a list of TV objects
	# PRE: list of strings
	# POST: list of objects of TV

	for i, s in enumerate(tvList):
		tvObjects.append(TV(s))
    chooseGameVideoMenu()
elif mode == "oldseason":
    previousSeasonMenu()
elif mode == "live":
    liveMenu()
elif mode.startswith("video"):
    if mode == "videoplay":
        videoPlay()
    elif mode == "videolist":
        videoListMenu()
    elif mode == "videodate":
        videoDateMenu()
    else:
        videoMenu()
elif mode == 'nba_tv_menu':
    TV.menu()
elif mode == 'nba_tv_play_live':
    TV.play_live()
elif mode == 'nba_tv_episode_menu':
    TV.episode_menu()
elif mode == 'nba_tv_play_episode':
    TV.play_episode()
elif mode == "nba_tv_series":
    TV.series_Menu()
elif mode == "nba_tv_seasons":
    TV.season_Menu()
elif mode == "nba_tv_episode":
    TV.episodes_list_Menu()
elif mode == 'nba_tv_play_serieepisode':
    TV.play_serieepisode()
elif mode == 'nba_tv_videolist':
Example #7
0
 def test_it_can_be_turn_on(self):
     tv = TV()
     tv.turn_on()
     tv | should | be_on
Example #8
0
 def setUp(self):
     self.tv = TV(volume_range=(0, 30))
Example #9
0
class TvVolumeTest(unittest.TestCase):
    def setUp(self):
        self.tv = TV(volume_range=(0, 30))

    def test_it_starts_at_the_minimum(self):
        self.tv.volume | should | be(0)
        TV(volume_range=(10, 20)).volume | should | be(10)

    def test_it_increases(self):
        self.tv.increase_volume()
        self.tv.volume | should | be(1)
        self.tv.increase_volume()
        self.tv.volume | should | be(2)

    def test_it_decreases(self):
        self.tv.increase_volume()
        self.tv.increase_volume()
        self.tv.volume | should | be(2)
        self.tv.decrease_volume()
        self.tv.volume | should | be(1)
        self.tv.decrease_volume()
        self.tv.volume | should | be(0)

    def test_it_does_nothing_when_trying_to_increase_beyond_the_maximum(self):
        for i in range(30):
            self.tv.increase_volume()
        self.tv.volume | should | be(30)
        self.tv.increase_volume()
        self.tv.volume | should | be(30)

    def test_it_does_nothing_when_trying_to_decrease_under_the_minimum(self):
        self.tv.volume | should | be(0)
        self.tv.decrease_volume()
        self.tv.volume | should | be(0)
Example #10
0
 def test_it_can_be_turn_off(self):
     tv = TV()
     tv.turn_on()
     tv.turn_off()
     tv | should_not | be_on
def main():
    data = checktextfile()

    # Skapa TV-objekten med indata från textfil
    x = TV("Vardagsrums TV", data[0], int(data[1]))
    y = TV("Köks TV", data[2], int(data[3]))

    # Initialparametrar för huvudmenyn
    print("**Välkommen till TV-simulatorn***\n", "1.", x.namn, "\n", "2.", y.namn, "\n", "3. Avsluta")
    kontroll_menu = "1. Byt kanal\n2. Sänk ljudvolym\n3. Höj ljudvolym\n4. Gå till huvudmenyn"
    tv_val = input("Välj: ")

    # ------- While loop för menyhanteringen av huvudmenyn, när TV apparat ska väljas -------
    while tv_val:

        # Val av inre meny till Vardagsrums TV'n när den ska modifieras
        if tv_val[0] == "1":

            clear()
            print(x.namn, "\nKanal:", x.kanal, "\nLjudvolymen", x.volym, "\n")
            print(kontroll_menu)
            tv_kontroll = input("Välj: ")

            while tv_kontroll:
                if tv_kontroll[0] == "1":
                    bytkanal(x)
                    tv_kontroll = ""
                    tv_val = "1"
                elif tv_kontroll[0] == "2":
                    x.sankVolym()
                    tv_kontroll = ""
                    tv_val = "1"
                elif tv_kontroll[0] == "3":
                    x.hojVolym()
                    tv_kontroll = ""
                    tv_val = "1"
                elif tv_kontroll[0] == "4":
                    tv_kontroll = ""
                    clear()
                    print("**Välkommen till TV-simulatorn***\n", "1.", x.namn, "\n", "2.", y.namn, "\n", "3. Avsluta")
                    tv_val = input("Välj: ")
                else:
                    tv_kontroll = input("Fel val, försök igen: ")

        # Val av inre meny till Köks TV'n när den ska modifieras
        elif tv_val[0] == "2":

            clear()
            print(y.namn, "\nKanal:", y.kanal, "\nLjudvolymen", y.volym, "\n")
            print(kontroll_menu)
            tv_kontroll = input("Välj: ")

            while tv_kontroll:
                if tv_kontroll[0] == "1":
                    bytkanal(y)
                    tv_kontroll = ""
                    tv_val = "2"
                elif tv_kontroll[0] == "2":
                    y.sankVolym()
                    tv_kontroll = ""
                    tv_val = "2"
                elif tv_kontroll[0] == "3":
                    y.hojVolym()
                    tv_kontroll = ""
                    tv_val = "2"
                elif tv_kontroll[0] == "4":
                    tv_kontroll = ""
                    clear()
                    print("**Välkommen till TV-simulatorn***\n", "1.", x.namn, "\n", "2.", y.namn, "\n", "3. Avsluta")
                    tv_val = input("Välj: ")
                else:
                    tv_kontroll = input("Fel val, försök igen: ")

        # Stänger menyn
        elif tv_val[0] == "3":
            tv_val = ""

        # Ogiltigt val
        else:
            tv_val = input("Fel val, försök igen: ")
    # -------------------- While loop för menyhanteringen slutar här -------------------- #

    # Skriver data till textfil
    writedata(x.kanal, x.volym, y.kanal, y.volym)
Example #12
0
# -*- coding: utf-8 -*-

import flask
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import tinyurl
from models import Channel
from tv import TV
from feed import Feed

app = Flask(__name__)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db = SQLAlchemy(app)
tv = TV('http://chelsea.local:8090/tv/api/v1.0/')

@app.route('/tv/stop')
def tv_stop():
    tv.stop()
    return flask.redirect(flask.request.referrer)

@app.route('/tv/pause')
def tv_pause():
    tv.pause()
    return flask.redirect(flask.request.referrer)

@app.route('/tv/play')
def tv_play():
    tv.play()
    return flask.redirect(flask.request.referrer)

@app.route('/tv/start/<int:channel_id>')
    chooseGameVideoMenu()
elif mode == "oldseason":
    previousSeasonMenu()
elif mode == "live":
    liveMenu()
elif mode.startswith("video"):
    if mode == "videoplay":
        videoPlay()
    elif mode == "videolist":
        videoListMenu()
    elif mode == "videodate":
        videoDateMenu()
    else:
        videoMenu()
elif mode == 'nba_tv_menu':
    TV.menu()
elif mode == 'nba_tv_play_live':
    TV.play_live()
elif mode == 'nba_tv_episode_menu':
    TV.episode_menu()
elif mode == 'nba_tv_play_episode':
    TV.play_episode()
elif mode == "favteam":
    if url == "older":
        favTeamOlderMenu()
    else:
        favTeamMenu()
else:
    chooseGameMenu(mode, url)

xbmcplugin.endOfDirectory(int(sys.argv[1]))
Example #14
0
 def setUp(self):
     self.tv1 = TV(5, 10)
Example #15
0
def slideshow():

    folder = None
    time = None
    args = sys.argv[:1]

    for arg in sys.argv[2:]:
        if arg.startswith("--"):
            args.append(arg)
            continue
        if not folder:
            folder = arg
            continue
        time = arg

    if folder is None or time is None:  # awwww :)
        print("""usage: %s ROOT SECONDS
ROOT points to the root directory where the images are going to be picked up.
SECONDS is the time between images.""" % sys.argv[0])
        sys.exit(1)

    sys.argv = args

    cursor = Qt.BlankCursor

    app = QApplication(sys.argv)
    win = QMainWindow()

    QApplication.setOverrideCursor(cursor)
    QApplication.changeOverrideCursor(cursor)

    scene = QGraphicsScene()

    view = QGraphicsView(scene, win)
    view.setFrameShadow(QFrame.Plain)
    view.setFrameStyle(QFrame.NoFrame)
    view.show()

    brush = QBrush(QColor(0, 0, 0))
    brush.setStyle(Qt.SolidPattern)
    view.setBackgroundBrush(brush)

    runner = MainWindow(view, scene, folder)

    timer = QTimer(app)
    timer.timeout.connect(runner.nextImage)
    timer.start(float(time) * 1000)
    QTimer.singleShot(200, runner.nextImage)

    timer2 = QTimer(app)
    timer2.timeout.connect(runner.updateAlbum)
    timer2.start(60 * 60 * 1000)

    win.setCentralWidget(view)

    win.showFullScreen()

    tv = TV()

    app.exec_()

    tv.stop()