• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python settings.MythSettings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mythbox.settings.MythSettings的典型用法代码示例。如果您正苦于以下问题:Python MythSettings类的具体用法?Python MythSettings怎么用?Python MythSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MythSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: MythEventPublisherTest

class MythEventPublisherTest(unittest.TestCase):

    def setUp(self):
        self.platform = getPlatform()
        self.translator = Mock()
        self.settings = MythSettings(self.platform, self.translator)
        
        privateConfig = OnDemandConfig()
        self.settings.put('mysql_host', privateConfig.get('mysql_host'))
        self.settings.put('mysql_port', privateConfig.get('mysql_port'))
        self.settings.setMySqlDatabase(privateConfig.get('mysql_database'))
        self.settings.setMySqlUser(privateConfig.get('mysql_user'))  
        self.settings.put('mysql_password', privateConfig.get('mysql_password'))
        self.settings.put('paths_recordedprefix', privateConfig.get('paths_recordedprefix'))
        self.bus = EventBus()
        self.domainCache = Mock()
        pools['dbPool']   = Pool(MythDatabaseFactory(settings=self.settings, translator=self.translator, domainCache=self.domainCache))
        pools['connPool'] = Pool(ConnectionFactory(settings=self.settings, translator=self.translator, platform=self.platform, bus=self.bus))
        
    def tearDown(self):
        pools['connPool'].shutdown()
        pools['dbPool'].shutdown()

    def test_event_publisher(self):
        publisher = MythEventPublisher(settings=self.settings, translator=self.translator, platform=self.platform, bus=self.bus)
        publisher.startup()
        time.sleep(5)
        publisher.shutdown()
开发者ID:Berimor66,项目名称:mythbox,代码行数:28,代码来源:test_publish.py


示例2: EventConnectionTest

class EventConnectionTest(unittest.TestCase):

    def setUp(self):
        self.platform = getPlatform()
        self.translator = Mock()
        self.domainCache = Mock()
        self.settings = MythSettings(self.platform, self.translator)
        
        privateConfig = OnDemandConfig()
        self.settings.put('mysql_host', privateConfig.get('mysql_host'))
        self.settings.put('mysql_port', privateConfig.get('mysql_port'))
        self.settings.setMySqlDatabase(privateConfig.get('mysql_database'))
        self.settings.setMySqlUser(privateConfig.get('mysql_user'))  
        self.settings.put('mysql_password', privateConfig.get('mysql_password'))
        self.settings.put('paths_recordedprefix', privateConfig.get('paths_recordedprefix'))
        
        self.db = MythDatabase(self.settings, self.translator, self.domainCache)
        self.bus = EventBus()
        self.conn = EventConnection(self.settings, self.translator, self.platform, self.bus, self.db)

    def tearDown(self):
        self.conn.close()

    def test_read_a_system_event(self):
        x  = 1
        if 'MYTH_SNIFFER' in os.environ:
            x = 9999999
        for i in xrange(x):
            msg = self.conn.readEvent()
            print(msg)
            log.debug(msg)
开发者ID:Jajcus,项目名称:mythbox,代码行数:31,代码来源:test_conn.py


示例3: test_saveSettings_LoadedDefaultsCreatesNewSettingsFile

 def test_saveSettings_LoadedDefaultsCreatesNewSettingsFile(self):
     filename = "settings.xml"
     filepath = os.path.join(self.sandbox, filename)
     when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
     self.assertFalse(os.path.exists(filepath))
     s = MythSettings(self.platform, self.translator)
     s.save()
     self.assertTrue(os.path.exists(filepath))
开发者ID:Berimor66,项目名称:mythbox,代码行数:8,代码来源:test_settings.py


示例4: test_getRecordingDirs_SingleDirectory

 def test_getRecordingDirs_SingleDirectory(self):
     when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
     settings = MythSettings(self.platform, self.translator)
     settings.put("paths_recordedprefix", "/mnt/mythtv")
     log.debug("Recording prefix = %s" % settings.get("paths_recordedprefix"))
     dirs = settings.getRecordingDirs()
     self.assertEquals(1, len(dirs))
     self.assertEquals("/mnt/mythtv", dirs[0])
开发者ID:Berimor66,项目名称:mythbox,代码行数:8,代码来源:test_settings.py


示例5: test_verifyRecordingDirs_OneInvalidOutOfManyOKThrowsSettingsException

 def test_verifyRecordingDirs_OneInvalidOutOfManyOKThrowsSettingsException(self):
     try:
         MythSettings.verifyRecordingDirs(
             tempfile.gettempdir() + os.pathsep + "someBogusDir" + os.pathsep + os.getcwd()
         )
         self.fail("expected failure")
     except SettingsException, se:
         log.debug("PASS: %s" % se)
开发者ID:Berimor66,项目名称:mythbox,代码行数:8,代码来源:test_settings.py


示例6: test_getRecordingDirs_ManyDirectories

 def test_getRecordingDirs_ManyDirectories(self):
     when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
     settings = MythSettings(self.platform, self.translator)
     settings.put("paths_recordedprefix", os.pathsep.join(["a", "b", "c"]))
     log.debug("Recording prefix = %s" % settings.get("paths_recordedprefix"))
     dirs = settings.getRecordingDirs()
     self.assertEquals(3, len(dirs))
     self.assertEquals(["a", "b", "c"], dirs)
开发者ID:Berimor66,项目名称:mythbox,代码行数:8,代码来源:test_settings.py


示例7: test_verifyBoolean_AllValuesThatShouldRaiseException

 def test_verifyBoolean_AllValuesThatShouldRaiseException(self):
     badValues = ("true", "false", "", "2", "crap")
     for b in badValues:
         try:
             MythSettings.verifyBoolean(b, "blah")
             self.fail("should have throws SettingsException")
         except SettingsException, se:
             log.debug("PASS: %s %s" % (b, se))
开发者ID:Berimor66,项目名称:mythbox,代码行数:8,代码来源:test_settings.py


示例8: test_When_existing_setting_changed_to_different_value_Then_event_published_to_bus

    def test_When_existing_setting_changed_to_different_value_Then_event_published_to_bus(self):
        # Setup
        when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
        s = MythSettings(self.platform, self.translator, bus=self.bus)

        # Test
        s.get("mysql_host")
        s.put("mysql_host", "foo")

        # Verify
        verify(self.bus, 1).publish(any(dict))
开发者ID:Berimor66,项目名称:mythbox,代码行数:11,代码来源:test_settings.py


示例9: setUp

 def setUp(self):
     translator = mockito.Mock()
     platform = mockito.Mock()
     bus = mockito.Mock()
     settings = MythSettings(platform, translator)
     privateConfig = OnDemandConfig()
     settings.put('mysql_host', privateConfig.get('mysql_host'))
     settings.put('mysql_password', privateConfig.get('mysql_password'))
     settings.put('mysql_database', privateConfig.get('mysql_database'))
     self.db = MythDatabase(settings, translator)
     self.conn = Connection(settings, translator, platform, bus, self.db)
     self.brain = FileLiveTvBrain(self.conn, self.db)
开发者ID:Berimor66,项目名称:mythbox,代码行数:12,代码来源:test_livetv.py


示例10: MythDatabaseTest

class MythDatabaseTest(unittest.TestCase):
    def setUp(self):
        self.platform = Platform()

        # self.translator = Mock()
        self.langInfo = util_mock.XBMCLangInfo(self.platform)
        self.translator = util_mock.Translator(self.platform, self.langInfo)

        self.bus = Mock()
        self.domainCache = Mock()
        self.settings = MythSettings(self.platform, self.translator)

        privateConfig = OnDemandConfig()
        self.settings.put("mysql_host", privateConfig.get("mysql_host"))
        self.settings.put("mysql_database", privateConfig.get("mysql_database"))
        self.settings.put("mysql_password", privateConfig.get("mysql_password"))

        self.db = MythDatabase(self.settings, self.translator, self.domainCache)
        self.conn = Connection(self.settings, self.translator, self.platform, self.bus, self.db)

    def tearDown(self):
        # self.db.close()
        self.conn.close()

    def test_saveSchedule_NewSchedule(self):
        now = datetime.datetime.now()
        programs = self.db.getTVGuideDataFlattened(now, now, self.db.getChannels())
        if len(programs) == 0:
            log.warn("Cannot run unit tests without program listings in the database")
            return

        schedule = RecordingSchedule.fromProgram(programs[0], self.translator)
        log.debug("Test schedule = %s" % schedule)
        result = self.db.saveSchedule(schedule)
        log.debug("Save schedule result = %s" % result)

    def test_addJob_UserJob1(self):
        recordings = self.conn.getAllRecordings()
        if not recordings:
            log.warn("Cannot run unit tests without program listings in the database")
            return

        job = Job.fromProgram(recordings[-1], JobType.USERJOB & JobType.USERJOB1)
        log.debug(job)

        self.assertIsNone(job.id)
        self.db.addJob(job)
        log.debug(job)
        self.assertIsNotNone(job.id)
开发者ID:Berimor66,项目名称:mythbox,代码行数:49,代码来源:itest_db.py


示例11: setUp

 def setUp(self):
     p = Platform()
     langInfo = util_mock.XBMCLangInfo(p)
     translator = util_mock.Translator(p, langInfo)
     settings = MythSettings(p, translator)
     domainCache = Mock()
     
     privateConfig = OnDemandConfig()
     settings.put('mysql_host', privateConfig.get('mysql_host'))
     settings.put('mysql_database', privateConfig.get('mysql_database'))
     settings.put('mysql_user', privateConfig.get('mysql_user'))  
     settings.put('mysql_password', privateConfig.get('mysql_password'))
     
     self.dbPool = pool.pools['dbPool'] = pool.Pool(MythDatabaseFactory(settings=settings, translator=translator, domainCache=domainCache))
开发者ID:Berimor66,项目名称:mythbox,代码行数:14,代码来源:test_threadlocal.py


示例12: MythThumbnailResolverTest

class MythThumbnailResolverTest(unittest.TestCase):

    def setUp(self):
        self.platform = getPlatform()
        self.translator = Mock()
        self.domainCache = Mock()
        self.settings = MythSettings(self.platform, self.translator)
        
        privateConfig = OnDemandConfig()
        self.settings.setMySqlHost(privateConfig.get('mysql_host'))
        self.settings.setMySqlPort(privateConfig.get('mysql_port'))
        self.settings.setMySqlDatabase(privateConfig.get('mysql_database'))
        self.settings.setMySqlUser(privateConfig.get('mysql_user'))  
        self.settings.setMySqlPassword(privateConfig.get('mysql_password'))
        
        log.debug('%s' % self.settings)
        
        self.db = MythDatabase(self.settings, self.translator, self.domainCache)
        self.bus = EventBus()
        self.conn = Connection(self.settings, self.translator, self.platform, self.bus, self.db)

    def tearDown(self):
        self.conn.close()

    def test_store_download_thumbnail(self):
        # Setup
        recordings = self.conn.getRecordings()
        self.assertTrue(recordings, 'Recordings needed in to run test')
        downloader = MythThumbnailResolver(self.conn, self.db)
        dest = os.path.sep.join([tempfile.gettempdir(), 'thumbnail_' + str(random.randint(1, 999999)) + '.png'])

        # Test
        downloader.store(recordings[-1], dest)
         
        # Verify
        log.debug('Downloaded %s to %s' % (safe_str(recordings[-1].title()), dest))
        self.assertTrue(os.path.exists(dest))
        self.assertTrue(os.path.isfile(dest))
        self.assertTrue(os.path.getsize(dest) > 0)
                
        # Cleanup
        os.remove(dest)        
开发者ID:Berimor66,项目名称:mythbox,代码行数:42,代码来源:test_resolver.py


示例13: test_When_setting_has_a_unicode_value_Then_saving_and_loading_should_still_work

    def test_When_setting_has_a_unicode_value_Then_saving_and_loading_should_still_work(self):
        when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
        s = MythSettings(self.platform, self.translator)
        unicodeStr = u"Königreich der Himmel"
        s.put("recordings_selected_group", unicodeStr)
        s.save()

        s2 = MythSettings(self.platform, self.translator)
        actualStr = s2.get("recordings_selected_group")
        self.assertTrue(unicodeStr == actualStr)
        self.assertTrue(isinstance(unicodeStr, unicode))
开发者ID:Berimor66,项目名称:mythbox,代码行数:11,代码来源:test_settings.py


示例14: test_constructor_NonExistentSettingsFilesLoadsDefaults

 def test_constructor_NonExistentSettingsFilesLoadsDefaults(self):
     when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
     s = MythSettings(self.platform, self.translator)
     self.assertEquals("localhost", s.get("mysql_host"))
     self.assertEquals("3306", s.get("mysql_port"))
     self.assertEquals("mythconverg", s.get("mysql_database"))
     self.assertEquals("mythtv", s.get("mysql_user"))
     self.assertEquals("change_me", s.get("mysql_password"))
开发者ID:Berimor66,项目名称:mythbox,代码行数:8,代码来源:test_settings.py


示例15: setUp

 def setUp(self):
     self.platform = Platform()
     self.langInfo = util_mock.XBMCLangInfo(self.platform)
     self.translator = util_mock.Translator(self.platform, self.langInfo)
     self.settings = MythSettings(self.platform, self.translator)
     self.protocol = protocol.Protocol56()
     privateConfig = OnDemandConfig()
     self.settings.put('mysql_host', privateConfig.get('mysql_host'))
     self.settings.put('mysql_port', privateConfig.get('mysql_port'))
     self.settings.put('mysql_database', privateConfig.get('mysql_database'))
     self.settings.put('mysql_user', privateConfig.get('mysql_user'))  
     self.settings.put('mysql_password', privateConfig.get('mysql_password'))
     self.domainCache = Mock()
     self.db = MythDatabase(self.settings, self.translator, self.domainCache)
开发者ID:Berimor66,项目名称:mythbox,代码行数:14,代码来源:test_db.py


示例16: setUp

 def setUp(self):
     self.platform = getPlatform()
     self.translator = Mock()
     self.domainCache = Mock()
     self.settings = MythSettings(self.platform, self.translator)
     
     privateConfig = OnDemandConfig()
     self.settings.setMySqlHost(privateConfig.get('mysql_host'))
     self.settings.setMySqlPort(privateConfig.get('mysql_port'))
     self.settings.setMySqlDatabase(privateConfig.get('mysql_database'))
     self.settings.setMySqlUser(privateConfig.get('mysql_user'))  
     self.settings.setMySqlPassword(privateConfig.get('mysql_password'))
     
     self.db = MythDatabase(self.settings, self.translator, self.domainCache)
     self.bus = EventBus()
     self.conn = Connection(self.settings, self.translator, self.platform, self.bus, self.db)
开发者ID:Berimor66,项目名称:mythbox,代码行数:16,代码来源:test_resolver.py


示例17: setUp

 def setUp(self):
     self.platform = getPlatform()
     self.translator = Mock()
     self.settings = MythSettings(self.platform, self.translator)
     
     privateConfig = OnDemandConfig()
     self.settings.put('mysql_host', privateConfig.get('mysql_host'))
     self.settings.put('mysql_port', privateConfig.get('mysql_port'))
     self.settings.setMySqlDatabase(privateConfig.get('mysql_database'))
     self.settings.setMySqlUser(privateConfig.get('mysql_user'))  
     self.settings.put('mysql_password', privateConfig.get('mysql_password'))
     self.settings.put('paths_recordedprefix', privateConfig.get('paths_recordedprefix'))
     self.bus = EventBus()
     self.domainCache = Mock()
     pools['dbPool']   = Pool(MythDatabaseFactory(settings=self.settings, translator=self.translator, domainCache=self.domainCache))
     pools['connPool'] = Pool(ConnectionFactory(settings=self.settings, translator=self.translator, platform=self.platform, bus=self.bus))
开发者ID:Berimor66,项目名称:mythbox,代码行数:16,代码来源:test_publish.py


示例18: setUp

    def setUp(self):
        self.platform = Platform()

        # self.translator = Mock()
        self.langInfo = util_mock.XBMCLangInfo(self.platform)
        self.translator = util_mock.Translator(self.platform, self.langInfo)

        self.bus = Mock()
        self.domainCache = Mock()
        self.settings = MythSettings(self.platform, self.translator)

        privateConfig = OnDemandConfig()
        self.settings.put("mysql_host", privateConfig.get("mysql_host"))
        self.settings.put("mysql_database", privateConfig.get("mysql_database"))
        self.settings.put("mysql_password", privateConfig.get("mysql_password"))

        self.db = MythDatabase(self.settings, self.translator, self.domainCache)
        self.conn = Connection(self.settings, self.translator, self.platform, self.bus, self.db)
开发者ID:Berimor66,项目名称:mythbox,代码行数:18,代码来源:itest_db.py


示例19: setUp

 def setUp(self):
     self.platform = getPlatform()
     self.translator = Mock()
     self.domainCache = Mock()
     self.settings = MythSettings(self.platform, self.translator)
     self.settings.put('streaming_enabled', 'False')
     
     privateConfig = OnDemandConfig()
     self.settings.put('mysql_host', privateConfig.get('mysql_host'))
     self.settings.put('mysql_port', privateConfig.get('mysql_port'))
     self.settings.setMySqlDatabase(privateConfig.get('mysql_database'))
     self.settings.setMySqlUser(privateConfig.get('mysql_user'))  
     self.settings.put('mysql_password', privateConfig.get('mysql_password'))
     self.settings.put('paths_recordedprefix', privateConfig.get('paths_recordedprefix'))
     
     self.db = MythDatabase(self.settings, self.translator, self.domainCache)
     self.bus = EventBus()
     self.conn = Connection(self.settings, self.translator, self.platform, self.bus, self.db)
开发者ID:Berimor66,项目名称:mythbox,代码行数:18,代码来源:test_orphans.py


示例20: test_constructor_LoadExistingSettingsFile

    def test_constructor_LoadExistingSettingsFile(self):
        # Setup
        settingsDir = os.path.join("resources", "test")
        settingsFile = "test_mythtv_settings.xml"
        when(self.platform).getScriptDataDir().thenReturn(settingsDir)

        # Test
        s = MythSettings(self.platform, self.translator, settingsFile)

        # Verify
        self.assertEquals("test_host", s.get("mysql_host"))
        self.assertEquals("9999", s.get("mysql_port"))
        self.assertEquals("test_database", s.get("mysql_database"))
        self.assertEquals("test_user", s.get("mysql_user"))
        self.assertEquals("test_password", s.get("mysql_password"))
开发者ID:Berimor66,项目名称:mythbox,代码行数:15,代码来源:test_settings.py



注:本文中的mythbox.settings.MythSettings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.safe_str函数代码示例发布时间:2022-05-27
下一篇:
Python mytesttools.create_node函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap