本文整理汇总了Python中echomesh.base.Config.get方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get方法的具体用法?Python Config.get怎么用?Python Config.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类echomesh.base.Config
的用法示例。
在下文中一共展示了Config.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def __init__(self):
super(Instance, self).__init__()
self.score_master = ScoreMaster.ScoreMaster()
self.peers = Peers.Peers(self)
self.socket = PeerSocket.PeerSocket(self, self.peers)
self.display = Display.display()
self.keyboard = self.osc = None
if Config.get('control_program'):
from echomesh.util.thread import Keyboard
self.keyboard = Keyboard.keyboard(
self, USE_KEYBOARD_THREAD or self.display)
osc_client = Config.get('osc', 'client', 'enable')
osc_server = Config.get('osc', 'server', 'enable')
if osc_client or osc_server:
from echomesh.sound.Osc import Osc
self.osc = Osc(osc_client, osc_server)
self.add_mutual_pause_slave(self.socket, self.keyboard, self.osc)
self.add_slave(self.score_master)
self.add_slave(self.display)
self.set_broadcasting(False)
self.mic = None
self.timeout = Config.get('network', 'timeout')
Quit.register_atexit(self.pause)
示例2: main
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def main():
import sys
times = []
def p(msg=''):
"""Print progress messages while echomesh loads."""
print(msg, end='\n' if msg else '')
global COUNT
dot = str(COUNT % 10) if USE_DIGITS_FOR_PROGRESS_BAR else '.'
print(dot, end='')
COUNT += 1
sys.stdout.flush()
import time
times.append(time.time())
p('Loading echomesh ')
from echomesh.base import Path
p()
Path.fix_sys_path()
p()
from echomesh.base import Args
p()
Args.set_arguments(sys.argv)
p()
from echomesh.base import Config
p()
Config.recalculate()
p()
if Config.get('autostart') and not Config.get('permission', 'autostart'):
print()
from echomesh.util import Log
Log.logger(__name__).info("Not autostarting because autostart=False")
exit(0)
p()
from echomesh import Instance
print()
if Config.get('diagnostics', 'startup_times'):
print()
for i in range(len(times) - 1):
print(i, ':', int(1000 * (times[i + 1] - times[i])))
print()
Instance.main()
if Config.get('diagnostics', 'unused_configs'):
import yaml
print(yaml.safe_dump(Config.get_unvisited()))
示例3: _on_run
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def _on_run(self):
super(ScoreMaster, self)._on_run()
if self.startup:
self.startup = False
try:
self._load_elements(Config.get('load'))
except:
LOGGER.error()
try:
self.start_elements(Config.get('start'))
except:
LOGGER.error()
示例4: make_command
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def make_command():
parts = []
config = Config.get('network', 'client')
parts.append(config['binary'] or COMMAND)
parts.append(config['host_name'])
parts.append(str(config['port']))
timeout = Expression.convert(Config.get('network', 'timeout'))
parts.append(str(timeout))
parts.append(str(config['buffer_size']))
parts.append(str(config['debug']))
return parts
示例5: __init__
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def __init__(self, device_index, sample_bytes, rates):
super(InputThread, self).__init__(name='InputThread')
self.chunk_size = max(MIN_CHUNK_SIZE,
min(MAX_CHUNK_SIZE,
Config.get('audio', 'input', 'chunk_size')))
self.input = Input()
fmt = GetFormatName.get_format_name(sample_bytes)
try:
len(rates)
except TypeError:
rates = [rates]
self.clients = set()
pyaud = Sound.PYAUDIO()
for rate in rates:
try:
self.stream = pyaud.open(format=fmt, channels=1, rate=rate,
input_device_index=device_index, input=True)
break
except IOError as e:
if 'Invalid sample rate' not in str(e):
raise
else:
raise Exception("Couldn't open audio device named %s." % name)
示例6: _interpret
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def _interpret(self, op, evaluator, element, is_evaluating):
parts = op.split('.')
if len(parts) == 1:
cmd = 'function'
else:
cmd = parts.pop(0)
name, _ = GetPrefix.get_prefix(self.table, cmd)
name = getattr(Names, name.upper())
if name == Names.CONFIGURATION:
from echomesh.base import Config
# TODO: Why can't this import be at the top? Does it even work?!
return is_evaluating and Config.get(*parts)
if name == Names.FUNCTION:
return (is_evaluating and
self.functions.get('.'.join(parts))(evaluator()))
if name == Names.SYSTEM:
func, is_constant = self.system.get('.'.join(parts))
if not is_evaluating:
return is_constant
elif name in ELEMENT_NAMES:
func = Locator.get_variable(element, Names.reverse(name).lower(), parts)
else:
raise Exception("Shouldn't get here.")
return Call.call(func) if is_evaluating else func.is_constant()
示例7: transfer
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def transfer(_, **data):
backup_directory = os.path.join(Path.COMMAND_PATH, '.echomesh-xfer')
try:
shutil.rmtree(backup_directory)
except OSError:
pass
directories = data.get('directories', [])
if '' in directories:
directories = os.listdir(Path.COMMAND_PATH)
for directory in directories:
parent = os.path.dirname(os.path.join(backup_directory, directory))
MakeDirs.parent_makedirs(parent)
shutil.move(os.path.join(Path.COMMAND_PATH, directory), parent)
for f, value in six.iteritems(data.get('files')):
fname = os.path.join(Path.COMMAND_PATH, f)
MakeDirs.parent_makedirs(fname)
with open(fname, 'w') as o:
o.write(value['contents'])
os.utime(fname, (value['atime'], value['mtime']))
if Config.get('delete_backups_after_transfer'):
try:
shutil.rmtree(backup_directory)
except:
pass
示例8: config_update
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def config_update(self, get):
count = Config.get('light', 'count')
def _get(*items):
return get(*(('light', 'visualizer') + items))
last_get = _get()
if self.last_get == last_get and self.count == count:
return
self.last_get = copy.deepcopy(last_get)
self.count = count
def _color(*items):
return ColorTable.to_tk(ColorTable.to_color(_get(*items)))
self.border_color = _color('instrument', 'border', 'color')
self.button_background = _color('instrument', 'background')
self.background = _color('background')
self.border_width = _get('instrument', 'border', 'width')
self.shape = _get('instrument', 'shape')
self.size = _get('instrument', 'size')
self.light_padding = _get('instrument', 'padding')
self.padding = _get('padding')
self.columns, self.rows = _get_dimension(self.count, *_get('layout'))
self.width = (self.padding['top'] +
self.columns * (self.size[0] + self.light_padding[0]) +
self.padding['right'])
self.height = (self.padding['top'] +
self.rows * (self.size[1] + self.light_padding[1]) +
self.padding['bottom'])
TkThreadRunner.defer(self.initialize_tk)
示例9: _make_lights
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def _make_lights(self):
with self.lock:
if self.lights:
return
classpath = _TYPE_MAP[Config.get('light', 'visualizer', 'type')]
self.lights = Importer.imp(classpath, defer_failure=False)()
self.lights.start()
示例10: get
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def get(self, *path):
with self.lock:
value = self.clients.get(path)
if not value:
value = Expression.convert(Config.get(*path))
self.clients[path] = value
return value
示例11: spread
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def spread(colors=None, steps=None, transforms=None):
assert colors
if not isinstance(colors, list):
colors = [colors]
if steps is None:
steps = math.ceil(Config.get('light', 'count') / len(colors))
if not isinstance(steps, list):
steps = [steps]
if transforms is not None and not isinstance(transforms, list):
transforms = [transforms]
if len(colors) == 1:
colors = [colors[0], colors[0]]
result = []
for i in xrange(len(colors) - 1):
s = steps[i if i < len(steps) else -1]
t = transforms and transforms[i if i < len(transforms) else -1]
result.extend(ColorSpread.color_name_spread(begin=colors[i],
end=colors[i + 1],
steps=s,
transform=t))
return result
示例12: get
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def get(self, *path):
Config.add_client(self)
with self.lock:
value = self.clients.get(path)
if not value:
value = Units.convert(Config.get(*path))
self.clients[path] = value
return value
示例13: play
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def play(element, **kwds):
if 'type' in kwds:
del kwds['type']
if 'use_aplay' in kwds:
use_aplay = kwds['use_aplay']
del kwds['use_aplay']
else:
use_aplay = Config.get('audio', 'output', 'use_aplay')
return Aplay.play(**kwds) if use_aplay else FilePlayer(element, **kwds)
示例14: __init__
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def __init__(self, parent, description):
super(Audio, self).__init__(parent, description)
if Config.get('audio', 'output', 'enable'):
try:
from echomesh.sound import Play
self.add_mutual_pause_slave(Play.play(self, **description))
except:
LOGGER.error()
else:
LOGGER.info('Audio disabled for %s', description.get('file', None))
description.clear_accessed()
示例15: __init__
# 需要导入模块: from echomesh.base import Config [as 别名]
# 或者: from echomesh.base.Config import get [as 别名]
def __init__(self, parent, description):
super(Audio, self).__init__(parent, description)
if Config.get('audio', 'output', 'enable'):
try:
from echomesh.sound import FilePlayer
self.add_mutual_pause_slave(FilePlayer.play(self, **description))
except:
LOGGER.error("Couldn't play audio with %s", description)
else:
LOGGER.debug('Audio disabled for %s', description.get('file', None))
description.clear_accessed()