Beispiel #1
0
    def changeAreaOption(self, ip, continentIndex, languageCountry,
                         hwSettings):
        print('changeAreaOption : ' + languageCountry + ', ' + hwSettings)
        result = TvModel()
        isConnected = self.tvController.connect(ip)
        if isConnected:
            result = self.tvController.execCommand(
                LunaCommands.changeAreaOption(self, languageCountry,
                                              hwSettings, continentIndex))
            if result.resultType == RESULT_SUCCESS:
                try:
                    result = self.tvController.execCommand(
                        LunaCommands.setContinentIndex(self, continentIndex))
                    if result.resultType == RESULT_SUCCESS:
                        result = self.tvController.execCommand(
                            LunaCommands.setLanguageCountry(
                                self, languageCountry))
                        if result.resultType == RESULT_SUCCESS:
                            result = self.tvController.execCommand(
                                LunaCommands.setHwSettings(self, hwSettings))
                            if result.resultType == RESULT_SUCCESS:
                                result = self.__refreshSettingValueWithGroup(
                                    result)

                except Exception as e:
                    print('*** Caught exception: %s: %s' % (e.__class__, e))
                    traceback.print_exc()
                    result.message = MESSAGE_ERROR + str(e)
            self.tvController.disconnect()
        else:
            result.message = MESSAGE_TV_ABNORMAL

        return result
Beispiel #2
0
    def __refreshSettingValue(self, result):
        result = self.tvController.execCommand(
            LunaCommands.getCurrentAreaOption(self))
        if result.resultType == RESULT_SUCCESS:
            self.__loadCurrentAreaOption(result.resultValue)
            self.__loadServiceCountryFile()
            result = self.tvController.execCommand(
                LunaCommands.getCountry(self))
            if result.resultType == RESULT_SUCCESS:
                self.__loadCurrentCountry(result.resultValue)

        return result
Beispiel #3
0
    def inquery(self, ip, platform, displayType, hasGroup):
        print('inquery : ' + platform)
        result = TvModel()
        self.countryModel = CountryModel()
        self.countryModel.platform = platform
        self.countryModel.displayType = displayType
        isConnected = self.tvController.connect(ip)
        if isConnected:
            result = self.tvController.execCommand(
                LunaCommands.getAreaOptionValues(self))
            if result.resultType == RESULT_SUCCESS:
                try:
                    self.__loadAreaOption(result.resultValue)
                    if hasGroup:
                        result = self.__refreshSettingValueWithGroup(result)
                    else:
                        result = self.__refreshSettingValue(result)
                except Exception as e:
                    print('*** Caught exception: %s: %s' % (e.__class__, e))
                    traceback.print_exc()
                    result.message = MESSAGE_ERROR + str(e)
            self.tvController.disconnect()
        else:
            result.message = MESSAGE_TV_ABNORMAL

        return result
Beispiel #4
0
    def downloadCountryFile(self, ip):
        print('downloadCountryFile : ')
        result = TvModel()

        #### TBD : 확인해보기
        self.countryModel = CountryModel()

        isConnected = self.tvController.connect(ip)
        if isConnected:
            result = self.tvController.execCommand(
                LunaCommands.getCountryListPath(self))
            if result.resultType == RESULT_SUCCESS:
                try:
                    res = json.loads(result.resultValue)
                    countryListPath = res['path'].strip()

                    # cmd = 'cp '+str(countryListPath)+' /tmp/'
                    # print("cmd === ",cmd)
                    # self.tvController.execSimpleCommand(cmd)
                    # time.sleep(0.3)
                    fileName = countryListPath.split('/')[-1]
                    if os.path.exists('download/' + fileName):
                        print("already existed!!!")
                    else:
                        result = self.tvController.downloadFile(
                            countryListPath)
                        if result.resultType == RESULT_SUCCESS:
                            try:
                                # cmd = 'mv ../download/'+str(fileName)+' ../resources/'
                                # print("cmd === ",cmd)
                                # self.tvController.execSimpleCommand(cmd)
                                # time.sleep(0.3)
                                # if os.exist('../resources/'+fileName):
                                #     self.countryModel.countryFilePath = '../resources/'+fileName
                                if os.path.exists('download/' + fileName):
                                    self.countryModel.countryFilePath = 'download/' + fileName
                                else:
                                    print("error anything!!!")
                            except Exception as e:
                                print('*** Caught move exception: %s: %s' %
                                      (e.__class__, e))
                                traceback.print_exc()
                                result.message = MESSAGE_ERROR + str(e)
                        else:
                            print(
                                "download fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
                            )
                except Exception as e:
                    print('*** Caught download exception: %s: %s' %
                          (e.__class__, e))
                    traceback.print_exc()
                    result.message = MESSAGE_ERROR + str(e)
            self.tvController.disconnect()
        else:
            result.message = MESSAGE_TV_ABNORMAL

        return result
Beispiel #5
0
    def inputKey(self, ip, key, times):
        result = TvModel()
        isConnected = self.tvController.connect(ip)
        if isConnected:
            for i in range(times):
                result = self.tvController.execCommand(
                    LunaCommands.inputKey(self, key))
            self.tvController.disconnect()

        return result
 def reboot(self, ip, excelVer):
     try:
         result = TvModel()
         isConnected = self.tvController.connect(ip)
         time.sleep(0.1)
         if isConnected:
             if excelVer == EXCEL_VERSION[0]:
                 result = self.tvController.execCommand(LunaCommands.reboot(self))
             else:
                 result = self.tvController.execCommandForWO35(LunaCommands.reboot(self))
             self.tvController.disconnect()
         else:
             self.reboot(ip, excelVer)
             time.sleep(3)
         return result
     except Exception as e:
         print('*** reboot, Caught exception: %s: %s' % (e.__class__, e))
         self.reboot(ip, excelVer)
         time.sleep(3)
Beispiel #7
0
 def checkForegroundAppIsHome(self, ip):
     result = TvModel()
     isConnected = self.tvController.connect(ip)
     if isConnected:
         result = self.tvController.execCommand(
             LunaCommands.getForegroundApp(self))
         self.tvController.disconnect()
         foregroundApp = json.loads(result.resultValue)
         for app in foregroundApp[FOREGROUND_APP_INFO]:
             if app["appId"] == "com.webos.app.home":
                 return True
         return False
Beispiel #8
0
    def searchApp(self, ip, appTitle):
        print('searchApp : ' + appTitle)
        result = TvModel()
        isConnected = self.tvController.connect(ip)
        if isConnected:
            result = self.tvController.execCommand(
                LunaCommands.searchApp(self, appTitle))
            self.tvController.disconnect()
        else:
            result.message = MESSAGE_TV_ABNORMAL

        return result
Beispiel #9
0
    def changeCountry(self, ip, countryName):
        print('changeCountryAndGroup : ' + countryName)
        result = TvModel()
        isConnected = self.tvController.connect(ip)
        if not isConnected:
            for i in range(7):
                isConnected = self.tvController.connect(ip)
                if isConnected:
                    break
                time.sleep(0.5)

        if isConnected:
            country = self.countryModel.getCountryByName(countryName)
            if country != None:
                self.countryModel.currentLanguageCountry = country[KEY_CODE]
                languageCountry = self.countryModel.currentLanguageCountry
                hwSettings = self.countryModel.currentHwSettings
                continentIndx = str(self.countryModel.currentContinentIndex)
                result = self.tvController.execCommand(
                    LunaCommands.changeAreaOption(self, languageCountry,
                                                  hwSettings, continentIndx))
                if result.resultType == RESULT_SUCCESS:
                    result = self.tvController.execCommand(
                        LunaCommands.setLanguageCountry(self, languageCountry))
                    if result.resultType == RESULT_SUCCESS:
                        result = self.tvController.execCommand(
                            LunaCommands.setHwSettings(self, hwSettings))
                        if result.resultType == RESULT_SUCCESS:
                            result = self.tvController.execCommand(
                                LunaCommands.changeCountry(
                                    self, country[KEY_CODE2],
                                    country[KEY_CODE3]))
                            if result.resultType == RESULT_SUCCESS:
                                self.countryModel.currentCountry = countryName
            self.tvController.disconnect()

        else:
            result.message = MESSAGE_TV_ABNORMAL

        return result
    def doScreenCapture(self, ip, fileName):
        fileName = '/tmp/captured_' + fileName + '.png'
        print('captureApp : ' + fileName)
        result = TvModel()
        isConnected = self.tvController.connect(ip)
        if isConnected:
            result = self.tvController.execCommand(
                LunaCommands.doScreenCapture(self, fileName))
            if result.resultType == RESULT_SUCCESS:
                result = TvModel()
                result = self.tvController.downloadFile(fileName)
            self.tvController.disconnect()

        return result
Beispiel #11
0
 def checkHomeShowing(self, ip):
     print('checkHomeShowing')
     result = TvModel()
     isConnected = self.tvController.connect(ip)
     if isConnected:
         result = self.tvController.execCommand(
             LunaCommands.confirmCurrentState(self))
         self.tvController.disconnect()
         if self.__loadCurrentState(result.resultValue) == STATE_HOME:
             return True, STATE_HOME
         elif self.__loadCurrentState(result.resultValue) == STATE_ALERT:
             print("STATE ALERT!!!!!!!!!!!!!!!!!!!!!")
             return False, STATE_ALERT
         else:
             return False, 'None'
 def setEULA(self, ip, state=False):
     try:
         result = TvModel()
         isConnected = self.tvController.connect(ip)
         time.sleep(0.1)
         if isConnected:
             print('set EULA to - ',state)
             result = self.tvController.execCommand(LunaCommands.setEULA(ip, state))
             self.tvController.disconnect()
         else:
             self.setEULA(ip, state)
             time.sleep(3)
         return result
     except Exception as e:
         print('*** keyBlock, Caught exception: %s: %s' % (e.__class__, e))
         self.setEULA(ip, state)
         time.sleep(3)
 def keyBlock(self, ip, block=True):
     try:
         result = TvModel()
         isConnected = self.tvController.connect(ip)
         time.sleep(0.1)
         if isConnected:
             print('key block!!!')
             result = self.tvController.execCommand(LunaCommands.keyBlock(block))
             self.tvController.disconnect()
         else:
             self.keyBlock(ip, block)
             time.sleep(3)
         return result
     except Exception as e:
         print('*** keyBlock, Caught exception: %s: %s' % (e.__class__, e))
         self.keyBlock(ip, block)
         time.sleep(3)
Beispiel #14
0
    def changeCountryWithGroup(self, ip, countryName):
        print('changeCountry : ' + countryName)
        result = TvModel()
        isConnected = self.tvController.connect(ip)
        if isConnected:
            country = self.countryModel.getCountryByName(countryName)
            if country != None:
                result = self.tvController.execCommand(
                    LunaCommands.changeCountry(self, country[KEY_CODE2],
                                               country[KEY_CODE3]))

            self.tvController.disconnect()

        else:
            result.message = MESSAGE_TV_ABNORMAL

        return result