当前位置: 首页>>代码示例>>Python>>正文


Python MythSettings.setMySqlUser方法代码示例

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


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

示例1: MythEventPublisherTest

# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import setMySqlUser [as 别名]
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,代码行数:30,代码来源:test_publish.py

示例2: EventConnectionTest

# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import setMySqlUser [as 别名]
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,代码行数:33,代码来源:test_conn.py

示例3: MythThumbnailResolverTest

# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import setMySqlUser [as 别名]
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,代码行数:44,代码来源:test_resolver.py

示例4: MythChannelIconResolverTest

# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import setMySqlUser [as 别名]
class MythChannelIconResolverTest(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'))
        
        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_When_channel_has_icon_Then_download_icon(self):
        # Setup
        channels = filter(lambda x: x.getIconPath(), self.db.getChannels()) # filter out channels that don't have an icon
        self.assertTrue(len(channels) > 0, 'Channels with icon needed in db to run test')
        downloader = MythChannelIconResolver(self.conn)
         
        # Test - download icons for first 5 channels
        for channel in channels[:min(5, len(channels))]:
            if channel.getIconPath():
                dest = os.path.sep.join([tempfile.gettempdir(), 'channel_' + str(channel.getChannelId()) + channel.getCallSign() + str(time.time()) + '.png'])
                downloader.store(channel, dest)
        
                # Verify
                log.debug('Downloaded %s to %s' % (channel.getIconPath(), dest))
                self.assertTrue(os.path.exists(dest))
                self.assertTrue(os.path.isfile(dest))
                self.assertTrue(os.path.getsize(dest) > 0)
                
                # Cleanup
                os.remove(dest)        
    
    def test_store_When_channel_has_no_icon_Then_do_nothing(self):
        # Setup
        channel = Channel({'name':'Bogus Channel', 'icon':None, 'chanid': '9', 'callsign': 'WXYZ'})
        conn = Mock()
        downloader = MythChannelIconResolver(conn)
         
        # Test 
        downloader.store(channel, 'bogusDestDir')
    
        # Verify
        verifyZeroInteractions(conn)

    def test_store_When_channel_has_iconpath_but_filename_misspelled_Then_do_nothing(self):
        # Setup
        channel = Channel({'name':'Bogus Channel', 'icon': 'bogusIcon.png', 'chanid': '9', 'callsign': 'WXYZ'})
        downloader = MythChannelIconResolver(self.conn)
         
        # Test - download icons for first 5 channels
        dest = os.path.sep.join([tempfile.gettempdir(), str(channel.getChannelId()) + channel.getCallSign() + str(time.time()) + ".png"])
        downloader.store(channel, dest)

        # Verify
        self.assertFalse(os.path.exists(dest))
开发者ID:Berimor66,项目名称:mythbox,代码行数:68,代码来源:test_resolver.py

示例5: DeleteOrphansTest

# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import setMySqlUser [as 别名]
class DeleteOrphansTest(unittest.TestCase):

    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)

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

    def test_getAllRecordings(self):
        recordings = self.conn.getAllRecordings()
        log.debug('Num Recordings = %s' % len(recordings))
        for i,r in enumerate(recordings):
            print i,r.getBareFilename()
 
        dirs = ['/usr2/mythtv','/usr2/mythtv2', '/usr2/mythtv3']
        
        mpgs = []
        
        for d in dirs:
            files = os.listdir(d)
            for f in files:
                if f.endswith('.mpg'):
                    mpgs.append(f)
                    print f
                    
        print 'Recs  total = ', len(recordings)
        print 'Files total = ', len(mpgs)
        print 'Extras      = ', len(mpgs) - len(recordings)    
        
        todelete = mpgs[:]
        for r in recordings:
            if r.getBareFilename() in mpgs:
                todelete.remove(r.getBareFilename())
                
        print 'Todelete    = ', len(todelete)

        bucket = []
        
        import datetime
        
        for f in todelete:
            for d in dirs:
                path = os.path.join(d,f)
                if os.path.exists(path):
                    bucket.append(path)
                    print path, os.path.getsize(path)
                        
        print 'Bucket     = ', len(bucket)
        sorted(bucket)
        
        total = 0
        for f in bucket:
            s = os.path.getsize(f)
            total += s
            
        print total/1000000000
        
        import shutil
        
        for src in bucket[:25]:
            dest = '/usr2/mythtv/backup/' + os.path.basename(src)
            print src,' -> ', dest
开发者ID:Berimor66,项目名称:mythbox,代码行数:80,代码来源:test_orphans.py

示例6: ConnectionTest

# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import setMySqlUser [as 别名]
class ConnectionTest(unittest.TestCase):

    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)

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

    def test_getServerVersion(self):
        sock = self.conn.connect(announce=None)
        try:
            version = self.conn.getServerVersion()
            log.debug('Server Protcol = %s'%version)
            self.assertTrue(version > 0)
        finally:
            sock.close()

    def test_negotiateProtocol_RaisesProtocolException_When_ClientVersion_NotSupported_By_Server(self):
        sock = self.conn.connect(announce=None)
        try:
            try:
                self.conn.negotiateProtocol(sock, clientVersion=8, versionToken='')
                self.fail('Should have thrown ProtocolException')
            except ProtocolException, pe:
                log.debug('PASS: %s', pe)
        finally:
            sock.close()

    def test_getSetting(self):
        reply = self.conn.getSetting('mythfillstatus', 'none')
        log.debug('reply = %s' % reply)
        if reply[0] == "-1":
            pass # fail
        else:
            pass # success
        # TODO : Left off here!
        
    def test_getTunerStatus_Success(self):
        tuners = self.db.getTuners()
        if len(tuners) == 0:
            log.warn('SKIPPING: need tuners to run test')
            return 
        status = self.conn.getTunerStatus(tuners.pop())
        log.debug('Tuner status = %s' % status)
        self.assertFalse(status is None)

    def test_getDiskUsage(self):
        du = self.conn.getDiskUsage()
        log.debug('Disk usage = %s' % du)
        self.assertTrue(du['hostname'] is not None)
        self.assertTrue(du['dir'] is not None)
        self.assertTrue(du['total'] is not None)
        self.assertTrue(du['used'] is not None)
        self.assertTrue(du['free'] is not None)
        
    def test_getLoad(self):
        load = self.conn.getLoad()
        log.debug('CPU Load = %s' % load)
        self.assertEquals(3, len(load))
        self.assertTrue(load['1'])
        self.assertTrue(load['5'])
        self.assertTrue(load['15'])

    def test_getUptime(self):
        uptime = self.conn.getUptime()
        log.debug('Uptime = %s' % uptime)
        self.assertFalse(uptime is None)
        
    def test_getGuideDataStatus(self):
        guideStatus = self.conn.getGuideDataStatus()
        log.debug('Guide data status = %s' % guideStatus)
        self.assertFalse(guideStatus is None)

    def test_getAllRecordings(self):
        recordings = self.conn.getAllRecordings()
        log.debug('Num Recordings = %s' % len(recordings))
        self.assertTrue(len(recordings) > 0)

    def test_getRecordings_AllRecordingGroupsAndTitles(self):
        recordings = self.conn.getRecordings()
        log.debug('Num Recordings = %s' % len(recordings))
        for i, r in enumerate(recordings):
            log.debug('%d - %s' %(i+1, r))
        self.assertTrue(len(recordings) > 0)
#.........这里部分代码省略.........
开发者ID:Jajcus,项目名称:mythbox,代码行数:103,代码来源:test_conn.py


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