Ejemplo n.º 1
0
    def mockXBMC(self):
        from mock import Mock
        sys.path.append("../xbmc-mocks/")
        import xbmc, xbmcaddon, xbmcgui, xbmcplugin, xbmcvfs
        #Setup basic xbmc dependencies
        sys.modules[ "__main__" ].xbmc = Mock(spec=xbmc)
        sys.modules[ "__main__" ].xbmc.getSkinDir = Mock()
        sys.modules[ "__main__" ].xbmc.translatePath = Mock()
        sys.modules[ "__main__" ].xbmc.translatePath.return_value = "./tmp/"
        sys.modules[ "__main__" ].xbmc.log = Mock()
        sys.modules[ "__main__" ].xbmc.log.side_effect = self.log
        sys.modules[ "__main__" ].xbmc.getSkinDir = Mock()
        sys.modules[ "__main__" ].xbmc.getSkinDir.return_value = "testSkinPath"
        sys.modules[ "__main__" ].xbmc.getInfoLabel = Mock()
        sys.modules[ "__main__" ].xbmc.getInfoLabel.return_value = "some_info_label"
        sys.modules[ "__main__" ].xbmcaddon = Mock(spec=xbmcaddon)
        sys.modules[ "__main__" ].xbmcgui = Mock(spec=xbmcgui)
        sys.modules[ "__main__" ].xbmcgui.WindowXMLDialog.return_value = "testWindowXML"
        sys.modules[ "__main__" ].xbmcgui.getCurrentWindowId.return_value = 1
        
        sys.modules[ "__main__" ].xbmcplugin = Mock(spec=xbmcplugin)
        sys.modules[ "__main__" ].xbmcvfs = xbmcvfs
        sys.modules[ "__main__" ].xbmcvfs = Mock(spec=xbmcvfs)
        sys.modules[ "__main__" ].xbmcvfs.exists.return_value = False
        import xbmcSettings
        sys.modules[ "__main__" ].settings = xbmcSettings.xbmcSettings()
        import xbmcLanguage
        sys.modules[ "__main__" ].language = xbmcLanguage.xbmcLanguage()

        sys.modules["DialogDownloadProgress"] = __import__("mock")
        sys.modules["DialogDownloadProgress"].DownloadProgress = Mock()
        sys.modules["storageserverdummy"] = Mock()
    def mockXBMC(self):
        from mock import Mock
        sys.path.append("../xbmc-mocks/")
        import xbmc
        import xbmcaddon
        import xbmcgui
        import xbmcplugin
        import xbmcvfsdummy as xbmcvfs

        # Setup basic xbmc dependencies
        sys.modules["__main__"].xbmc = Mock(spec=xbmc)
        sys.modules["__main__"].xbmc.getSkinDir = Mock()
        sys.modules["__main__"].xbmc.translatePath = Mock()
        sys.modules["__main__"].xbmc.log = Mock()
        sys.modules["__main__"].xbmc.log.side_effect = self.log
        sys.modules["__main__"].xbmc.getSkinDir = Mock()
        sys.modules["__main__"].xbmc.getSkinDir.return_value = "testSkinPath"
        sys.modules["__main__"].xbmc.getInfoLabel = Mock()
        sys.modules["__main__"].xbmc.getInfoLabel.return_value = "some_info_label"
        sys.modules["__main__"].xbmcaddon = Mock(spec=xbmcaddon)
        settingsdummy = Mock()

        try:
            plat = platform.uname()
        except:
            plat = ('', '', '', '', '', '')

        if plat[0] == "FreeBSD":
            settingsdummy.getSetting.side_effect = ["true", "5", "/usr/local/bin/rtmpdump", "usr/local/bin/rtmpdump", "/usr/local/bin/vlc", "/usr/local/bin/vlc", "/usr/local/bin/mplayer", "/usr/local/bin/mplayer", "10", "30"]
        else:
            settingsdummy.getSetting.side_effect = ["true", "5", "", "", "", "10", "30"]

        settingsdummy.getAddonInfo.return_value = "./tmp/tmp"
        sys.modules["__main__"].xbmcaddon.Addon.return_value = settingsdummy
        sys.modules["__main__"].xbmcgui = Mock(spec=xbmcgui)
        sys.modules["__main__"].xbmcgui.WindowXMLDialog.return_value = "testWindowXML"
        sys.modules["__main__"].xbmcgui.getCurrentWindowId.return_value = 1
        sys.modules["__main__"].xbmcplugin = Mock(spec=xbmcplugin)
        sys.modules["__main__"].xbmcvfs = xbmcvfs

        sys.modules["DialogDownloadProgress"] = __import__("mock")
        sys.modules["DialogDownloadProgress"].DownloadProgress = Mock()

        import xbmcSettings
        sys.modules["__main__"].settings = xbmcSettings.xbmcSettings()
aktHausStatus = statusCheck.HausStatus()
statusControl = statusCheck.StatusCheck()

fhzClientChk = fhzClientCheck.fhzClientCheck()

while 1:
	globalCnt = globalCnt + 1
	jetzt = datetime.datetime.now().time()

        debugWrite(globalCnt,'01')
        
	try:

                if USE_XBMC:
                    __settings__ = xbmcSettings.xbmcSettings("C:\\XBMC911\\userdata\\script_data\\HomeControl\\settings.xml")
                else:
                    try:
                        __settings__ = eHomeSettings.eHomeSettings("Q:\\eHome\\eHomeSettings.json")
                        ret = os.popen('copy Q:\\eHome\\eHomeSettings.json C:\\Users\\eHome\\Documents\\homeputer\\')
                    except Exception, err:
                        print "Q:\eHome... NOT FOUND... using C:\\"
                        __settings__ = eHomeSettings.eHomeSettings("C:\\Users\\eHome\\Documents\\homeputer\\eHomeSettings.json")                        

                        
                online = __settings__.getSetting("online")

                debugWrite(globalCnt,'02')

                # Internetverbindungscheck
                if (globalCnt % 30 == 0): # 3 = 1min, 15 = 5min