本文整理汇总了Python中mythbox.settings.MythSettings.put方法的典型用法代码示例。如果您正苦于以下问题:Python MythSettings.put方法的具体用法?Python MythSettings.put怎么用?Python MythSettings.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mythbox.settings.MythSettings
的用法示例。
在下文中一共展示了MythSettings.put方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getRecordingDirs_SingleDirectory
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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])
示例2: test_getRecordingDirs_ManyDirectories
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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)
示例3: test_When_setting_has_a_unicode_value_Then_saving_and_loading_should_still_work
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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))
示例4: test_When_existing_setting_changed_to_different_value_Then_event_published_to_bus
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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))
示例5: setUp
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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)
示例6: MythDatabaseTest
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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)
示例7: test_verifyMythTVConnectivity_OK
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
def test_verifyMythTVConnectivity_OK(self):
when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
settings = MythSettings(self.platform, self.translator)
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"))
settings.verifyMythTVConnectivity()
示例8: test_verifyMySQLConnectivity_InvalidUsernamePasswordThrowsSettingsException
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
def test_verifyMySQLConnectivity_InvalidUsernamePasswordThrowsSettingsException(self):
when(self.platform).getScriptDataDir().thenReturn(self.sandbox)
settings = MythSettings(self.platform, self.translator)
privateConfig = OnDemandConfig()
settings.put("mysql_host", privateConfig.get("mysql_host"))
settings.put("mysql_database", privateConfig.get("mysql_database"))
settings.put("mysql_user", "bogususer")
settings.put("mysql_password", "boguspassword")
try:
settings.verifyMySQLConnectivity()
self.fail("expected failure on invalid username and password")
except SettingsException, se:
log.debug("PASS: %s" % se)
示例9: MythEventPublisherTest
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [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()
示例10: EventConnectionTest
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [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)
示例11: setUp
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
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))
示例12: MythDatabaseTest
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [as 别名]
class MythDatabaseTest(unittest.TestCase):
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)
def tearDown(self):
try:
self.db.close()
except:
pass
def test_constructor(self):
self.assertTrue(self.db)
def test_toBackend(self):
master = self.db.getMasterBackend()
self.assertEqual(master, self.db.toBackend(master.hostname))
self.assertEqual(master, self.db.toBackend(master.ipAddress))
self.assertTrue(master, self.db.toBackend('bogus'))
self.assertEqual(master, self.db.toBackend(master.hostname.upper()))
self.assertEqual(master, self.db.toBackend(master.hostname.lower()))
def test_getBackends(self):
bes = self.db.getBackends()
self.assertTrue(len(bes) >= 1)
def test_getMasterBackend(self):
mbe = self.db.getMasterBackend()
log.debug(mbe)
self.assertTrue(mbe.hostname)
self.assertTrue(mbe.ipAddress)
self.assertTrue(mbe.port)
self.assertTrue(mbe.master)
self.assertFalse(mbe.slave)
def test_getSlaveBackends(self):
slaves = self.db.getSlaveBackends()
for slave in slaves:
log.debug(slave)
self.assertFalse(slave.master)
self.assertTrue(slave.slave)
def test_getChannels(self):
channels = self.db.getChannels()
for i, channel in enumerate(channels):
log.debug("%d - %s"%(i+1, channel))
self.assertTrue('Expected int but was %s' % type(channel.getChannelId()), isinstance(channel.getChannelId(), int))
self.assertTrue('Expected str but was %s' % type(channel.getChannelNumber()), isinstance(channel.getChannelNumber(), str))
self.assertTrue('Expected str but was %s' % type(channel.getCallSign()), isinstance(channel.getCallSign(), str))
self.assertTrue('Expected str but was %s' % type(channel.getChannelName()), isinstance(channel.getChannelName(), str))
self.assertTrue('Expected str but was %s' % type(channel.getIconPath()), isinstance(channel.getIconPath(), str))
self.assertTrue('Expected int but was %s' % type(channel.getTunerId()), isinstance(channel.getTunerId(), int))
def test_getRecordingProfileNames(self):
self.assertTrue(self.db.getRecordingProfileNames())
def test_getRecordingGroups(self):
groups = self.db.getRecordingGroups()
self.assertTrue('Default' in groups)
def test_getRecordingTitles_InAllGroups(self):
titles = self.db.getRecordingTitles('All Groups')
self.assertTrue(len(titles) > 0)
total = titles[0][1]
for i, title in enumerate(titles):
titleName = title[0]
titleCount = title[1]
log.debug('%d - %s x %s' %(i+1, titleCount, titleName))
def test_getRecordingTitles_ForNonExistantRecordingGroupReturnsAllShowsWithCountOfZero(self):
titles = self.db.getRecordingTitles('bogus group')
self.assertEquals(1, len(titles))
self.assertEquals('All Shows', titles[0][0])
self.assertEquals(0, titles[0][1])
def test_getRecordingTitles_ForDeletedRecordingsGroup(self):
deleted = self.db.getRecordingTitles('Deleted')
for i, title in enumerate(deleted):
titleName = title[0]
titleCount = title[1]
log.debug('%d - Deleted recording %s recorded %s times' % (i+1, titleName, titleCount))
self.assertTrue(len(deleted) > 0)
def test_getTuners(self):
tuners = self.db.getTuners()
self.assertTrue(len(tuners) > 0, 'No tuners found')
for i, tuner in enumerate(tuners):
log.debug('%d - %s' %(i+1, tuner))
#.........这里部分代码省略.........
示例13: DeleteOrphansTest
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [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
示例14: ConnectionTest
# 需要导入模块: from mythbox.settings import MythSettings [as 别名]
# 或者: from mythbox.settings.MythSettings import put [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)
#.........这里部分代码省略.........