def run(record_dir, amp_name, amp_serial, eeg_only=False, queue=None): recordLogger = logger recordLogger.info('\nOutput directory: %s' % (record_dir)) # spawn the recorder as a child process recordLogger.info('\n>> Press Enter to start recording.') key = input() recordState = mp.Value('i', 1) proc = mp.Process( target=record, args=[recordState, amp_name, amp_serial, record_dir, eeg_only]) proc.start() # clean up time.sleep(1) # required on some Python distribution input() recordState.value = 0 recordLogger.info('(main) Waiting for recorder process to finish.') proc.join(10) if proc.is_alive(): recordLogger.error( 'Recorder process not finishing. Are you running from Spyder?') recordLogger.error('Dropping into a shell') qc.shell() sys.stdout.flush() recordLogger.info('Recording finished.')
def run_gui(recordState, protocolState, record_dir, recordLogger=logger, amp_name=None, amp_serial=None, eeg_only=False, queue=None): redirect_stdout_to_queue(recordLogger, queue, 'INFO') # configure LSL server name and device serial if available if not amp_name: amp_name, amp_serial = pu.search_lsl(recordState, recordLogger, ignore_markers=True) recordLogger.info('\nOutput directory: %s' % (record_dir)) # spawn the recorder as a child process recordLogger.info('\n>> Recording started.') #proc = mp.Process(target=record, args=[recordState, amp_name, amp_serial, record_dir, eeg_only, recordLogger, queue]) proc = mp.Process(target=record, args=[recordState, amp_name, amp_serial, record_dir, eeg_only]) proc.start() # Launching the protocol (shared variable) with protocolState.get_lock(): protocolState.value = 1 # Continue recording until the shared variable changes to 0. while recordState.value: time.sleep(1) recordLogger.info('(main) Waiting for recorder process to finish.') proc.join(10) if proc.is_alive(): recordLogger.error('Recorder process not finishing. Are you running from Spyder?') recordLogger.error('Dropping into a shell') qc.shell() sys.stdout.flush() recordLogger.info('Recording finished.')
def main(record_dir, eeg_only=False): # configure LSL server name and device serial if available if len(sys.argv) == 2: amp_name = sys.argv[1] amp_serial = None elif len(sys.argv) == 3: amp_name, amp_serial = sys.argv[1:3] else: amp_name, amp_serial = pu.search_lsl(ignore_markers=True) if amp_name == 'None': amp_name = None qc.print_c('\nOutput directory: %s' % (record_dir), 'W') # spawn the recorder as a child process qc.print_c('\n>> Press Enter to start recording.', 'G') key = input() state = mp.Value('i', 1) proc = mp.Process(target=record, args=[state, amp_name, amp_serial, record_dir, eeg_only]) proc.start() # clean up time.sleep(1) # required on some Python distribution input() state.value = 0 qc.print_c('(main) Waiting for recorder process to finish.', 'W') proc.join(10) if proc.is_alive(): qc.print_c( '>> ERROR: Recorder process not finishing. Are you running from Spyder?', 'R') qc.print_c('Dropping into a shell', 'R') qc.shell() sys.stdout.flush() print('>> Done.')