Exemple #1
0
    def perform(self, action, names):
        if action == 'load':
            return self._load_elements(names)

        if action == 'start':
            return self.start_elements(names)

        if isinstance(names, six.string_types):
            names = Split.split_words(names)

        return self.perform_element(action, names)
 def _display_lights(self):
   with self.lock:
     if self.failed:
       return
     # Fix for https://github.com/rec/echomesh/issues/342.
     data = Split.split_long_strings(base64.b64encode(self.data),
                                     _LONGEST_STRING)
     try:
       ClientServer.instance().write(type='light', data=data)
     except:
       self._fail()
Exemple #3
0
  def perform(self, action, names):
    if action == 'load':
      return self._load_elements(names)

    if action == 'start':
      return self.start_elements(names)

    if isinstance(names, six.string_types):
      names = Split.split_words(names)

    return self.perform_element(action, names)
Exemple #4
0
  def expand(*cmds):
    for command in cmds:
      parts = Split.split_words(command)
      name = parts.pop(0)
      alias = aliases.get_prefix(command)
      if alias:
        cmd, alias_commands = alias
        if cmd == command or name != REGISTRY.entry(name).name:
          assert cmd not in stack
          stack.add(cmd)
          expand(*alias_commands)
          stack.remove(cmd)
          continue

      result.append([REGISTRY.function(name), parts])
Exemple #5
0
    def expand(*cmds):
        for command in cmds:
            parts = Split.split_words(command)
            name = parts.pop(0)
            alias = aliases.get_prefix(command)
            if alias:
                cmd, alias_commands = alias
                if (cmd == command
                        or name != Registry.registry().entry(name).name):
                    assert cmd not in stack
                    stack.add(cmd)
                    expand(*alias_commands)
                    stack.remove(cmd)
                    continue

            result.append([Registry.registry().function(name), parts])
Exemple #6
0
  def start_elements(self, names):
    score_names = Split.split_scores(names)
    element_names = []
    for score_file, name in score_names:
      if name:
        is_file = True
      else:
        name = score_file
        is_file = Yaml.has_extension(score_file)
        if is_file:
          name = name[:-4]
        elif name not in self.elements:
          is_file = True
      if is_file:
        element_names.extend(self._load_raw_elements([[score_file, name]]))
      else:
        element_names.append(name)

    return self.perform_element('start', element_names)
Exemple #7
0
    def start_elements(self, names):
        score_names = Split.split_scores(names)
        element_names = []
        for score_file, name in score_names:
            if name:
                is_file = True
            else:
                name = score_file
                is_file = DataFileName.has_extension(score_file)
                if is_file:
                    name = name[:-4]
                elif name not in self.elements:
                    is_file = True
            if is_file:
                element_names.extend(
                    self._load_raw_elements([[score_file, name]]))
            else:
                element_names.append(name)

        return self.perform_element('start', element_names)
Exemple #8
0
 def _load_elements(self, names):
     return self._load_raw_elements(Split.split_scores(names))
Exemple #9
0
 def _load_elements(self, names):
   return self._load_raw_elements(Split.split_scores(names))