Write a command to _write_pipe. Parameters ---------- command : string The command to send to Audacity timer : bool, optional If true, time the execution of the command Example ------- write("GetInf
(self, command, timer=False)
| 171 | read_thread.start() |
| 172 | |
| 173 | def write(self, command, timer=False): |
| 174 | """Write a command to _write_pipe. |
| 175 | |
| 176 | Parameters |
| 177 | ---------- |
| 178 | command : string |
| 179 | The command to send to Audacity |
| 180 | timer : bool, optional |
| 181 | If true, time the execution of the command |
| 182 | |
| 183 | Example |
| 184 | ------- |
| 185 | write("GetInfo: Type=Labels", timer=True): |
| 186 | |
| 187 | """ |
| 188 | self.timer = timer |
| 189 | print('Sending command:', command) |
| 190 | self._write_pipe.write(command + EOL) |
| 191 | # Check that read pipe is alive |
| 192 | if PipeClient.reader_pipe_broken.isSet(): |
| 193 | sys.exit('PipeClient: Read-pipe error.') |
| 194 | try: |
| 195 | self._write_pipe.flush() |
| 196 | if self.timer: |
| 197 | self._start_time = time.time() |
| 198 | self.reply = '' |
| 199 | PipeClient.reply_ready.clear() |
| 200 | except IOError as err: |
| 201 | if err.errno == errno.EPIPE: |
| 202 | sys.exit('PipeClient: Write-pipe error.') |
| 203 | else: |
| 204 | raise |
| 205 | |
| 206 | def _reader(self): |
| 207 | """Read FIFO in worker thread.""" |