コード例 #1
0
class VisualizerConnector:
    remote_matcher = re.compile('^remote:(.*)$')
    shell_matcher = re.compile('^(shell:)?(.*)$')

    def __init__(self, spec, server):
        self.server = server
        remote_match = self.remote_matcher.match(spec)
        shell_match = self.shell_matcher.match(spec)
        if remote_match:
            self.host = remote_match.group(1)
        elif shell_match:
            self.host = self.server.host
            command_line = shell_match.group(2)
            self._spawn_visualizer(command_line)
        else:
            raise Exception("failed to parse visualizer spec '%s'" % spec)
        self.informed_about_torrent = False

    def _spawn_visualizer(self, command_line):
        command_line_with_port = "%s -port %d" % (command_line, self.server.port)
        subprocess.Popen(command_line_with_port, shell=True, stdin=None)

    def connect_to(self, port):
        self._sender = OscSender(
            host=self.host,
            port=port,
            log_filename=self.server.options.osc_log)

    def send(self, *args):
        self._sender.send(*args)
コード例 #2
0
ファイル: orchestra.py プロジェクト: alex-berman/tforms
class VisualizerConnector:
    remote_matcher = re.compile('^remote:(.*)$')
    shell_matcher = re.compile('^(shell:)?(.*)$')

    def __init__(self, spec, server):
        self.spec = spec
        self.server = server
        remote_match = self.remote_matcher.match(spec)
        shell_match = self.shell_matcher.match(spec)
        if remote_match:
            self.host = remote_match.group(1)
        elif shell_match:
            self.host = self.server.host
            command_line = shell_match.group(2)
            self._spawn_visualizer(command_line)
        else:
            raise Exception("failed to parse visualizer spec %r" % spec)
        self._reset()

    def _reset(self):
        self.informed_about_torrent = False
        self.informed_about_peer = {}
        self.connected = False

    def _spawn_visualizer(self, command_line):
        command_line_with_port = "%s -port %d" % (command_line, self.server.port)
        subprocess.Popen(command_line_with_port, shell=True, stdin=None)

    def connect_to(self, port):
        self._sender = OscSender(
            host=self.host,
            port=port)
        self.connected = True

    def send(self, *args):
        if self.connected:
            try:
                self._sender.send(*args)
                return True
            except IOError:
                warn(logger, "failed to send to visualizer %r - ignoring it from now on" % self.spec)
                self._reset()
コード例 #3
0
 def connect_to(self, port):
     self._sender = OscSender(
         host=self.host,
         port=port,
         log_filename=self.server.options.osc_log)
コード例 #4
0
ファイル: test_send_input_osc.py プロジェクト: gaborpapp/AIam
from osc_sender import OscSender

osc_sender = OscSender(50001)
osc_sender.send("/input_position", 0.3, 0.6, -0.5)
コード例 #5
0
ファイル: orchestra.py プロジェクト: alex-berman/tforms
 def connect_to(self, port):
     self._sender = OscSender(
         host=self.host,
         port=port)
     self.connected = True