def test(self):
        self.logger.info("----- " + self.__class__.__name__ + " START -----")
        ''' prestep '''
        self.logStepResults("AT_THE_BEGINNING")

        self.delay = 0  # w godzinach
        self.interval = 5.0  # jako float
        self.firstChannel = 1
        self.lastChannel = 9999
        self.iterations = 5000
        ''' step '''
        self.timeReportFile = open(
            getReportsDirPath() + "/" + self.reportsPath + "/times.txt", "a")
        self.i = self.lastChannel - self.firstChannel

        self.rc.zap(self.firstChannel)
        time.sleep(5)
        ''' step '''
        self.logStepBeginning(
            "start zapping - interval >%i< - firstChannel >%i< - lastChannel >%i<"
            % (self.interval, self.firstChannel, self.lastChannel))

        if self.delay != 0:
            self.logger.info("sleeping for: " + str(self.delay * 3600 - 180) +
                             " seconds")
            time.sleep(self.delay * 3600 - 180)
            self.resetSTB()

        self.foo = 60 / self.interval
        if self.foo % 2 == 0:
            self.foo += 1

        self.start = datetime.datetime.now()

        self.logger.info("Start time: " + str(self.start))

        while self.startZapping():
            pass

        self.timeReportFile.close()
        self.logStepBeginning(
            "start zapping - interval >%i< - firstChannel >%i< - lastChannel >%i<"
            % (self.interval, self.firstChannel, self.lastChannel))

        self.test_passed = True
        self.logger.info("----- " + self.__class__.__name__ + " END -----")
Пример #2
0
    def test(self):
        self.logger.info("----- " + self.__class__.__name__ + " START -----")

        self.logger.info("REMEMBER TO SET DATAMODEL T1 TIME TO 1800")

        self.logger.info("REMEMBER TO SET DATAMODEL T1 TIME TO 1800")

        self.logger.info("REMEMBER TO SET DATAMODEL T1 TIME TO 1800")
        ''' prestep '''
        self.logStepResults("AT_THE_BEGINNING")
        ''' step '''
        self.logStepBeginning("start zapping")

        KANAL_STARTOWY = 266
        KANAL_KONCOWY = 266 + 30 - 4
        self.sleep_time_in_mins = 15
        self.shutdown_interval_in_hours = 24
        self.proactivre_reboot_in_hours = 6
        self.pvr_interval_in_hours = 1

        self.timeReportFile = open(
            getReportsDirPath() + "/" + self.reportsPath + "/times.txt", "a")

        keyup = Rpi.URL_RPI_KEY + "KEY_CHANNELUP"
        keyepg = Rpi.URL_RPI_KEY + "KEY_GUIDE"
        keyok = Rpi.URL_RPI_KEY + "KEY_OK"
        keyback = Rpi.URL_RPI_KEY + "KEY_BACK"
        keydown = Rpi.URL_RPI_KEY + "KEY_DOWN"
        keytv = Rpi.URL_RPI_KEY + "KEY_TV"
        keymwnu = Rpi.URL_RPI_KEY + "KEY_MENU"

        if not self.page.zapToChannel(KANAL_STARTOWY):
            self.rc.sendKeys(["KEY_BACK", "KEY_BACK", "KEY_MENU", "KEY_BACK"])
            time.sleep(2)
            self.page.zapToChannel(KANAL_STARTOWY)

        self.rc.startLogs()
        time.sleep(15)
        self.set_next_shutdown()

        self.set_next_proactive_reboot()
        self.set_next_pvr()

        i = KANAL_STARTOWY

        while True:
            try:
                if datetime.datetime.now() > self.next_shutdown:
                    self.go_standby()
                elif datetime.datetime.now() > self.next_proactive_reboot:
                    self.set_next_proactive_reboot()
                    self.logger.warning("Hard Reset PROACTIVE REBOOT")
                    self.rc.hardReset()
                    screenshot(
                        generateScreenFilePath(self.reportsPath,
                                               "PROACTIVE REBOOT"))
                    time.sleep(120)
                    screenshot(
                        generateScreenFilePath(self.reportsPath,
                                               "PROACTIVE REBOOT ===END==="))
#                 elif datetime.datetime.now() > self.next_pvr:
#                     time.sleep(60)
#                     self.logger.info(" Start Recording Video")
#                     self.rc.sendKeys(["KEY_RECORD"])
#                     #============================= count time since start video=======================
#                     currentDate = time.time()
#                     time.sleep(17)
#                     checkProblems=self.page.actionInstantRecord(10)
#                     time.sleep(11*60)
#                     self.set_next_pvr()
#                     self.rc.sendKeys(["KEY_BACK", "KEY_BACK","KEY_TV"])

                try:
                    #if Env.STB_MODEL != "DAKOTA":
                    log = self.page.findInLogs(
                        'stb.event> StbEvent> HANDLER: MEDIA - REASON: AREA_CHANGED - ATTRIBUTES: {"session_id":"LIVE"}',
                        10,
                        False,
                        repeats=3)
                    log.start()
                    self.rc.sendUrl(keyup)
                    self.logger.info("P+ send")
                    signal = datetime.datetime.now()
                    while log.working:
                        time.sleep(0.1)

                    if not log.found:
                        self.timeReportFile.write(
                            str(datetime.datetime.now()).split(".")[0] +
                            ";0\n")

                    else:
                        self.timeReportFile.write(
                            str(datetime.datetime.now()).split(".")[0] + ";" +
                            str((datetime.datetime.now() -
                                 signal).total_seconds()) + "\n")

                    self.timeReportFile.flush()

                    if Env.VIDEO:
                        screenshot(
                            generateScreenFilePath(self.reportsPath,
                                                   "screenshot P+"))

                except Exception, e:
                    self.logger.error(str(e))

                finally:
                    dream = 15.0 - (datetime.datetime.now() -
                                    signal).total_seconds()
                    if dream > 0:
                        time.sleep(dream)

                self.rc.sendUrl(keyepg)
                time.sleep(5)

                self.rc.sendUrl(keyok)
                time.sleep(10)

                self.rc.sendUrl(keyback)
                time.sleep(5)

                self.rc.sendUrl(keydown)
                time.sleep(5)

                self.rc.sendUrl(keyok)
                time.sleep(10)

                self.rc.sendUrl(keyup)
                time.sleep(10)
                ''' Sprawdzenie streszczenia'''
                time.sleep(30)
                self.rc.sendUrl(keyok)
                time.sleep(10)
                self.rc.sendUrl(keyok)
                time.sleep(30)

                writeStbLogsToFile(
                    self.rc.getLogs(),
                    generateStbLogFilePath(self.reportsPath,
                                           "after single run"))

                if i > KANAL_KONCOWY:
                    if not self.page.zapToChannel(KANAL_STARTOWY):
                        self.rc.sendKeys(
                            ["KEY_BACK", "KEY_BACK", "KEY_MENU", "KEY_BACK"])
                        time.sleep(2)
                        self.page.zapToChannel(KANAL_STARTOWY)
                    i = KANAL_STARTOWY
                else:
                    i += 1

            except Exception, e:
                self.logger.error(str(e))
                try:
                    self.rc.stopLogs()
                    writeStbLogsToFile(
                        self.rc.getLogs(),
                        generateStbLogFilePath(self.reportsPath,
                                               "on exception"))
                    self.rc.startLogs()
                    if Env.VIDEO:
                        screenshot(
                            generateScreenFilePath(self.reportsPath,
                                                   "screenshot on exception"))
                    self.logger.error(str(e))
                except Exception, e:
                    self.logger.error(str(e))
Пример #3
0
    def test(self):
        self.logger.info("----- " + self.__class__.__name__ + " START -----")

        ''' prestep '''
        self.logStepResults("AT_THE_BEGINNING")

        ''' step '''
        self.logStepBeginning("start zapping")


        KANAL_STARTOWY = 266
        KANAL_KONCOWY = 324

        self.timeReportFile = open(getReportsDirPath() + "/" + self.reportsPath + "/times.txt", "a")

        keyup = Rpi.URL_RPI_KEY + "KEY_CHANNELUP"
        keyepg = Rpi.URL_RPI_KEY + "KEY_GUIDE"
        keyok = Rpi.URL_RPI_KEY + "KEY_OK"
        keyback = Rpi.URL_RPI_KEY + "KEY_BACK"
        keydown = Rpi.URL_RPI_KEY + "KEY_DOWN"
        keytv = Rpi.URL_RPI_KEY + "KEY_TV"

        if not self.page.zapToChannel(KANAL_STARTOWY):
            self.rc.sendKeys(["KEY_BACK", "KEY_BACK", "KEY_TV"])
            time.sleep(2)
            self.page.zapToChannel(KANAL_STARTOWY)

        self.rc.startLogs()
        time.sleep(15)

        i = KANAL_STARTOWY

        while True:
            try:
                try:
                    log = self.page.findInLogs('stb.event> StbEvent> HANDLER: MEDIA - REASON: AREA_CHANGED - ATTRIBUTES: {"session_id":"LIVE"}', 10, False, repeats=3)
                    log.start()
                    self.rc.sendUrl(keyup)
                    self.logger.info("P+ send")
                    signal = datetime.datetime.now()
                    while log.working:
                        time.sleep(0.1)

                    if not log.found:
                        self.timeReportFile.write(str(datetime.datetime.now()).split(".")[0] + ";0\n")

                    else:
                        self.timeReportFile.write(str(datetime.datetime.now()).split(".")[0] + ";" + str((datetime.datetime.now() - signal).total_seconds()) + "\n")

                    self.timeReportFile.flush()
                    
                    if Env.VIDEO:
                        screenshot(generateScreenFilePath(self.reportsPath, "screenshot P+"))

                except Exception, e:                    
                    self.logger.error(str(e))

                finally:
                    dream = 15.0 - (datetime.datetime.now() - signal).total_seconds()
                    if dream > 0:
                        time.sleep(dream)

                self.rc.sendUrl(keyepg)
                time.sleep(5)

                self.rc.sendUrl(keyok)
                time.sleep(10)

                self.rc.sendUrl(keyback)
                time.sleep(5)

                self.rc.sendUrl(keydown)
                time.sleep(5)

                self.rc.sendUrl(keyok)
                time.sleep(10)

                self.rc.sendUrl(keytv)
                time.sleep(10)

                writeStbLogsToFile(self.rc.getLogs(), generateStbLogFilePath(self.reportsPath, "after single run"))

                if i > KANAL_KONCOWY:
                    if not self.page.zapToChannel(KANAL_STARTOWY):
                        self.rc.sendKeys(["KEY_BACK", "KEY_BACK", "KEY_TV"])
                        time.sleep(2)
                        self.page.zapToChannel(KANAL_STARTOWY)
                    i = KANAL_STARTOWY
                else:
                    i += 1

            except Exception, e:                
                self.logger.error(str(e))
                try:
                    self.rc.stopLogs()
                    writeStbLogsToFile(self.rc.getLogs(), generateStbLogFilePath(self.reportsPath, "on exception"))
                    self.rc.startLogs()
                    if Env.VIDEO:
                        screenshot(generateScreenFilePath(self.reportsPath, "screenshot on exception"))
                    self.logger.error(str(e))
                except Exception, e:                    
                    self.logger.error(str(e))
    def test(self):
        self.logger.info("----- " + self.__class__.__name__ + " START -----")
        ''' prestep '''
        self.logStepResults("AT_THE_BEGINNING")

        self.delay = 0  # w godzinach
        self.interval = 10.0  # jako float
        self.firstChannel = 1
        self.secondChannel = 22
        self.testTime = 142  # w godzinach
        ''' step '''
        self.timeReportFile = open(
            getReportsDirPath() + "/" + self.reportsPath + "/times.txt", "a")

        self.logStepBeginning("step set favorite channels")

        self.page.setFavoriteChannels([self.firstChannel, self.secondChannel])
        time.sleep(5)

        self.logStepResults("step set favorite channels")
        ''' step '''
        self.logStepBeginning(
            "start zapping - interval >%i< - firstChannel >%i< - secondChannel >%i< - testTime >%ih<"
            % (self.interval, self.firstChannel, self.secondChannel,
               self.testTime))

        self.assertTrue(
            self.page.zapToChannel(self.firstChannel),
            "   ERR   cannot zap to channel " + str(self.firstChannel))
        time.sleep(10)
        if Env.VIDEO:
            self.assertTrue(motionDetection(),
                            "   ERR    motion detection is not working")

        self.assertTrue(
            self.page.zapToChannel(self.secondChannel),
            "   ERR   cannot zap to channel " + str(self.secondChannel))
        time.sleep(10)

        if Env.VIDEO:
            self.assertTrue(motionDetection(),
                            "   ERR    motion detection is not working")

        self.rc.sendKeys(["KEY_LIST"])
        time.sleep(2)
        self.page.driver.get(Rpi.DUMP)
        time.sleep(1)

        try:
            item = self.page.driver.find_element_by_css_selector(
                ".zappingList .titleContent")
            item = item.text.encode('utf-8')
            while item != Description.favoriteInList:
                self.rc.sendKeys(["KEY_RIGHT"])
                time.sleep(2)
                self.page.driver.get(Rpi.DUMP)
                time.sleep(1)
                item = self.page.driver.find_element_by_css_selector(
                    ".zappingList .titleContent")
                item = item.text.encode('utf-8')
        except Exception, e:
            self.fail("   ERR   cannot load favorite list: " + str(e))
Пример #5
0
    def startZapping(self, iterations):
        firstToSecond = type('firstToSecond', (object, ), {
            'min': 99.0,
            'max': 0.0,
            'sum': 0.0
        })
        firstToSecond.timeReportFile = open(
            getReportsDirPath() + "/" + self.reportsPath + "/times1-2.txt",
            "a")
        secondToFirst = type('secondToFirst', (object, ), {
            'min': 99.0,
            'max': 0.0,
            'sum': 0.0
        })
        secondToFirst.timeReportFile = open(
            getReportsDirPath() + "/" + self.reportsPath + "/times2-1.txt",
            "a")
        try:
            for i in range(iterations):

                if i % 2 == 0:
                    obj = firstToSecond
                else:
                    obj = secondToFirst

                log = self.page.findInLogs(
                    'stb.event> StbEvent> HANDLER: MEDIA - REASON: AREA_CHANGED - ATTRIBUTES: {"session_id":"LIVE"}',
                    self.interval,
                    False,
                    repeats=3)
                log.start()
                signal = datetime.datetime.now()
                self.rc.sendUrl(Rpi.URL_RPI_KEY + "KEY_CHANNELUP")

                while log.working:
                    time.sleep(0.1)

                if not log.found:
                    obj.timeReportFile.write(
                        str(datetime.datetime.now()).split(".")[0] + ";0\n")
                    obj.timeReportFile.flush()
                else:
                    t = float(
                        (datetime.datetime.now() - signal).total_seconds())
                    obj.timeReportFile.write(
                        str(datetime.datetime.now()).split(".")[0] + ";" +
                        str(t) + "\n")
                    obj.timeReportFile.flush()
                    if (t < obj.min):
                        obj.min = t
                    if (t > obj.max):
                        obj.max = t

                    obj.sum += t

                dream = self.interval - (datetime.datetime.now() -
                                         signal).total_seconds()

                if dream > 0:
                    time.sleep(dream)
            firstToSecond.mean = firstToSecond.sum / (iterations / 2)
            secondToFirst.mean = secondToFirst.sum / (iterations / 2)

            timeReportFile = open(
                getReportsDirPath() + "/" + self.reportsPath +
                "/timeReport.txt", "a")

            timeReportFile.write("Zapping time_%i: Kanał numer %i -> kanał numer %i:min %f:śred %f:max %f" % (iterations, self.firstChannel, self.secondChannel, \
                                                    firstToSecond.min, firstToSecond.mean, firstToSecond.max))
            timeReportFile.write("\n\n")
            timeReportFile.write("Zapping time_%i: Kanał numer %i -> kanał numer %i:min %f:śred %f:max %f" % (iterations, self.secondChannel, self.firstChannel, \
                                                    secondToFirst.min, secondToFirst.mean, secondToFirst.max))

            timeReportFile.write("\n\n")

            timeReportFile.write("Zapping time_%i: min %f:śred %f:max %f" % (self.interval, min(firstToSecond.min, secondToFirst.min), (firstToSecond.mean + secondToFirst.mean) / 2, \
                                                                            max(firstToSecond.max, secondToFirst.max)))

            timeReportFile.write("\n\n")
            timeReportFile.close()
            firstToSecond.timeReportFile.write("\n\n")
            secondToFirst.timeReportFile.write("\n\n")
            firstToSecond.timeReportFile.close()
            secondToFirst.timeReportFile.close()

            return False
        except Exception, e:
            self.logger.info("   ERR   " + str(e))
            return True