コード例 #1
0
ファイル: Instance.py プロジェクト: florian-f/echomesh
  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
0
ファイル: Execute.py プロジェクト: sagistrauss/echomesh
 def _on_pause(self):
     Quit.unregister_atexit(self.pause)
     super(Execute, self)._on_pause()
     if self.process:
         try:
             self.process.kill()
         except:
             pass
         self.process = None
コード例 #3
0
 def _on_pause(self):
   Quit.unregister_atexit(self.pause)
   super(Execute, self)._on_pause()
   if self.process:
     try:
       self.process.kill()
     except:
       pass
     self.process = None
コード例 #4
0
ファイル: ClientServer.py プロジェクト: florian-f/echomesh
 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
0
  def _on_run(self):
    super(Execute, self)._on_run()
    self.process = subprocess.Popen(self.command_line, stdout=subprocess.PIPE)
    Quit.register_atexit(self.pause)

    result = self.process.stdout.read()
    if not self.process.returncode:
      LOGGER.debug('Successful completion!')  # Send out a message.
    self.process = None
    self.pause()
コード例 #6
0
ファイル: Execute.py プロジェクト: sagistrauss/echomesh
    def _on_run(self):
        super(Execute, self)._on_run()
        self.process = subprocess.Popen(self.command_line,
                                        stdout=subprocess.PIPE)
        Quit.register_atexit(self.pause)

        result = self.process.stdout.read()
        if not self.process.returncode:
            LOGGER.debug('Successful completion!')  # Send out a message.
        self.process = None
        self.pause()
コード例 #7
0
 def callback(self, data):
     data = Yaml.decode_one(data)
     event = data['event']
     if event == 'start':
         self.after_server_starts()
     elif event == 'closeButtonPressed':
         if Settings.get('execution', 'close_button_quits'):
             Quit.request_quit()
         elif Settings.get('execution', 'close_button_closes_window'):
             Visualizer.set_visible(False)
     else:
         # print(data)
         pass
コード例 #8
0
    def __init__(self):
        super(Instance, self).__init__()

        def do_quit():
            pause_outputs()
            self.pause()
            self.unload()

        Quit.register_atexit(do_quit)
        gpio = Settings.get('hardware', 'gpio')
        if gpio['enable']:
            GPIO.on_gpio(Quit.request_quit,
                         gpio['shutdown_pin'],
                         gpio['shutdown_pin_pull_up'],
                         gpio['shutdown_pin_bounce_time'])

        CLog.initialize()
        self.score_master = ScoreMaster.ScoreMaster()
        self.peers = Peers.Peers(self)
        self.socket = PeerSocket.PeerSocket(self, self.peers)

        self.display = Display.display(self.callback)
        self.keyboard_runnable = self.osc = None
        if Settings.get('execution', 'control_program'):
            from echomesh.util.thread import Keyboard
            args = {}
            keyboard, self.keyboard_runnable = Keyboard.keyboard(
              self, new_thread=USE_KEYBOARD_THREAD or self.display)

        osc_client = Settings.get('osc', 'client', 'enable')
        osc_server = Settings.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_runnable, self.osc)
        self.add_slave(self.score_master)
        self.add_slave(self.display)
        self.set_broadcasting(False)
        self.timeout = Settings.get('network', 'timeout')
コード例 #9
0
ファイル: RemoteCommands.py プロジェクト: florian-f/echomesh
def _quit(_):
  Quit.request_quit()
  return True
コード例 #10
0
ファイル: Main.py プロジェクト: TopRamenGod/echomesh
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 Version
    if Version.TOO_NEW:
        print(Version.ERROR)

    from echomesh.base import Path
    if not Path.project_path():
        return
    p()

    Path.fix_home_directory_environment_variable()
    p()

    Path.fix_sys_path()
    p()

    from echomesh.base import Settings
    p()

    Settings.read_settings(sys.argv[1:])
    p()

    if Settings.get('execution', 'autostart') and not Settings.get(
            'permission', 'autostart'):
        print()
        from echomesh.util import Log
        Log.logger(__name__).info('No permission to autostart')
        return
    p()

    from echomesh.base import Quit
    p()

    Quit.register_atexit(Settings.save)
    p()

    from echomesh.Instance import Instance
    p()

    instance = Instance()
    print()
    p()

    if Settings.get('diagnostics', 'startup_times'):
        print()
        for i in range(len(times) - 1):
            print(i, ':', int(1000 * (times[i + 1] - times[i])))
        print()

    instance.main()
コード例 #11
0
def _quit(_):
    Quit.request_quit()
    return True
コード例 #12
0
ファイル: Main.py プロジェクト: sagistrauss/echomesh
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 Version
    if Version.TOO_NEW:
        print(Version.ERROR)

    from echomesh.base import Path
    if not Path.project_path():
        return
    p()

    Path.fix_home_directory_environment_variable()
    p()

    Path.fix_sys_path()
    p()

    from echomesh.base import Settings
    p()

    Settings.read_settings(sys.argv[1:])
    p()

    if Settings.get('execution', 'autostart') and not Settings.get(
            'permission', 'autostart'):
        print()
        from echomesh.util import Log
        Log.logger(__name__).info('No permission to autostart')
        return
    p()

    from echomesh.base import Quit
    p()

    Quit.register_atexit(Settings.save)
    p()

    from echomesh.Instance import Instance
    p()

    instance = Instance()
    print()
    p()

    if Settings.get('diagnostics', 'startup_times'):
        print()
        for i in range(len(times) - 1):
            print(i, ':', int(1000 * (times[i + 1] - times[i])))
        print()

    instance.main()