本文整理汇总了Python中echomesh.base.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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: get
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
示例3: __init__
def __init__(self, instance, peers, config_name):
super(PeerSocketBase, self).__init__()
self.instance = instance
self.peers = peers
self.config_name = config_name
self.add_slave(self.peers)
self.port = -1
self.socket = None
Config.add_client(self)
示例4: __init__
def __init__(self):
# TODO: the idea of not calling super.__init__ here is a hack - come up
# with a better way.
LOGGER.vdebug('Creating ClientServer')
ClientServer.INSTANCE = self
self.process = None
self.constructed = False
Config.add_client(self)
Quit.register_atexit(self.kill)
示例5: read_callback
def read_callback(self, data):
t = data.get('type')
if t == 'hide':
Config.assign(['light.visualizer.show=false'])
elif t == 'midi':
LOGGER.info('MIDI! %s', data)
elif t == 'move':
Config.assign(['light.visualizer.top_left=%s' % data['top_left']])
示例6: __init__
def __init__(self, port, bind_port, hostname, socket_type):
super(Socket, self).__init__()
self.port = port
self.bind_port = bind_port
self.hostname = hostname
self.socket_type = socket_type
self.socket = None
self.buffer = ''
self.queue = queue.Queue()
self.max_size = MAX_SIZE
Config.add_client(self)
示例7: _before_thread_start
def _before_thread_start(self):
self.tk_count = 0
self.light_count = 0
self.count_difference = 1
self.last_get = {}
self.tkwin = None
self.count = 0
self.lights = []
super(TkLightBank, self)._before_thread_start()
TkThreadRunner.run()
Config.add_client(self)
示例8: _on_run
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()
示例9: make_command
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
示例10: spread
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
示例11: config_update
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)
示例12: _make_lights
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()
示例13: _interpret
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()
示例14: __init__
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)
示例15: transfer
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