def boot(self, scsynth_path=None, options=None, **kwargs): if self.is_running: return self self._options = new(options or BootOptions(), **kwargs) scsynth_path = BootOptions.find_scsynth(scsynth_path) self._server_process = self._options.boot(scsynth_path, self.port) self._is_owner = True self._connect() PubSub.notify("server-booted") return self
def boot(self, scsynth_path=None, server_options=None, **kwargs): import supriya.realtime if self.is_running: return self scsynth_path = scsynth_path or os.environ.get("SCSYNTH_PATH") if not scsynth_path: scsynth_path_candidates = uqbar.io.find_executable("scsynth") if not scsynth_path_candidates: raise RuntimeError("Cannot find scsynth") scsynth_path = scsynth_path_candidates[0] scsynth_path = pathlib.Path(scsynth_path).absolute() if not scsynth_path.exists(): raise RuntimeError("{} does not exist".format(scsynth_path)) self._osc_io.boot(ip_address=self.ip_address, port=self.port) self._setup_osc_callbacks() server_options = server_options or supriya.realtime.ServerOptions() assert isinstance(server_options, supriya.realtime.ServerOptions) if kwargs: server_options = utils.new(server_options, **kwargs) options_string = server_options.as_options_string(self.port) command = "{} {}".format(scsynth_path, options_string) if self.debug_subprocess: print("Boot:", command) process = self._server_process = subprocess.Popen( command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, start_new_session=True, ) try: self._read_scsynth_boot_output() except supriya.exceptions.ServerCannotBoot: self._osc_io.quit() try: process_group = os.getpgid(process.pid) os.killpg(process_group, signal.SIGINT) process.terminate() process.wait() except ProcessLookupError: pass raise self._is_running = True self._server_options = server_options self._setup() PubSub.notify("server-booted") return self
def quit(self, force=False): if not self.is_running: return if not self._is_owner and not force: raise supriya.exceptions.UnownedServerShutdown( "Cannot quit unowned server without force flag.") PubSub.notify("server-quitting") if self.recorder.is_recording: self.recorder.stop() QuitRequest().communicate(server=self) if self._server_process is not None and not self._server_process.terminate( ): self._server_process.wait() self._disconnect() PubSub.notify("server-quit") return self
def quit(self): import supriya.commands if not self.is_running: return PubSub.notify('server-quitting') if self.recorder.is_recording: self.recorder.stop() request = supriya.commands.QuitRequest() request.communicate(server=self) self._is_running = False if not self._server_process.terminate(): self._server_process.wait() self._osc_controller.quit() self._teardown() PubSub.notify('server-quit') return self
def quit(self, force=False): if not self.is_running: return if not self._is_owner and not force: raise supriya.exceptions.UnownedServerShutdown( "Cannot quit unowned server without force flag." ) PubSub.notify("server-quitting") if self.recorder.is_recording: self.recorder.stop() QuitRequest().communicate(server=self) if self._server_process is not None and not self._server_process.terminate(): self._server_process.wait() self._disconnect() PubSub.notify("server-quit") return self
def boot( self, server_options=None, **kwargs ): import supriya.realtime if self.is_running: return self scsynth_path = 'scsynth' if not uqbar.io.find_executable(scsynth_path): raise RuntimeError('Cannot find scsynth') self._osc_controller.boot() server_options = server_options or supriya.realtime.ServerOptions() assert isinstance(server_options, supriya.realtime.ServerOptions) if kwargs: server_options = utils.new(server_options, **kwargs) options_string = server_options.as_options_string(self.port) command = '{} {}'.format(scsynth_path, options_string) if self.debug_subprocess: print(command) self._server_process = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) start_time = time.time() while True: line = self._server_process.stdout.readline().decode() if line.startswith('SuperCollider 3 server ready'): break elif line.startswith('Exception in World_OpenUDP: bind: Address already in use'): raise Exception elif (time.time() - start_time) > 1: raise Exception self._is_running = True self._server_options = server_options self._setup() PubSub.notify('server-booted') return self