def _connect_fired(self): try: connection = SerialManager(device=self.serial_device, baudrate=self.baudrate, sleep_after_connect=self.sleep_after_connect, timeout=self.timeout) connection.open() print ArduinoApi(connection=connection).millis() except Exception as e: traceback.print_exc() message(traceback.format_exc(), buttons=['OK']) return a = self.tree = ArduinoTree(connection=connection) d = a.define.as_dict s = [GuiDefine(name=k, value=str(v)) for k, v in d.items()] s.sort(key=lambda x: x.name) self.defines = s self.digital_pins = [PinWrapper(pin=a.pin.get(x)) for x in a.pin.names_digital] self.analog_pins = [PinWrapper(pin=a.pin.get(x)) for x in a.pin.names_analog] self.pins = self.digital_pins + self.analog_pins fw = a.firmware_info self.arduino_version = fw.get('arduino_version') self.firmware_build_time = str(fw.get('compile_datetime')) self.avr_name = fw.get('avr_name') self.gcc_version = fw.get('gcc_version') self.libc_version = fw.get('libc_version') self.libc_date = str(fw.get('libc_date')) self.connected = True
def _info_button_fired(self): """Open dialog with description of statistics.""" if self.statistics_name in GLOBAL_STATS: stat_func = GLOBAL_STATS[self.statistics_name] else: stat_func = PAIRWISE_STATS[self.statistics_name] message(message = stat_func.__doc__, title='Statistics info')
def _info_button_fired(self): """Open dialog with description of statistics.""" if self.statistics_name in GLOBAL_STATS: stat_func = GLOBAL_STATS[self.statistics_name] else: stat_func = PAIRWISE_STATS[self.statistics_name] message(message=stat_func.__doc__, title='Statistics info')
def log(self, msg, alert=False): """Log a message to the console and, optionally, to terminal and/or pop-up dialog.""" _msg = msg.strip() txt = "\n[{}]: {}\n".format(datetime.now(), _msg) self._log += txt if self.debug: print(txt) if alert: message(_msg, "PyAMI Alert")
def _gcuts_fired(self): sp = os.path.join(self.project_surface_directory,self.subject_id) if os.path.exists(os.path.join(sp,'mri','brainmask.braincuts.mgz')): message(message='gcuts has already been run for subject %s'%self.subject_id) else: if not os.path.isfile(os.path.join(sp,'mri','brainmask_backup_%s.mgz'%self.date)): copy(os.path.join(sp,'mri','brainmask.mgz'),os.path.join(sp,'mri','brainmask_backup_%s.mgz'%self.date)) os.system('recon-all -skullstrip -clean-bm -gcut -subjid %s'%self.subject_id) os.system('echo "gcuts was run on %s" >> %s' %(time.strftime("%Y_%b_%d_%H%M",time.localtime()),os.path.join(sp,'edit.log')))
def _check_for_subjects_surfaces_fired(self): project_surface_directory=self.project_surface_directory subject_id=self.subject_id os.environ['SUBJECTS_DIR']=self.project_surface_directory if os.path.isfile(os.path.join(project_surface_directory,subject_id, 'mri','aparc+aseg.mgz')): self.subjects_existence=True message(message='Subject %s was successfully found at %s.'%(subject_id,os.path.join(project_surface_directory,subject_id)),title='Subject successfully found', buttons=['OK']) else: self.subjects_existence=False error(message='Subject %s was not found at %s. Please check your subject directory and subject id'%(subject_id,os.path.join(project_surface_directory,subject_id)), title='Subject not found', buttons=['OK'])
def _delete_fired(self): assert self.measurement res = message( 'Delete "%s" ?' % self.measurement, buttons=['OK', 'Cancel']) if res: # path (self.project.result_dir / self.measurement).remove() self.update_available_measurements()
def _delete_fired(self): assert self.measurement res = message('Delete "%s" ?' % self.measurement, buttons=['OK', 'Cancel']) if res: # path (self.project.result_dir / self.measurement).remove() self.update_available_measurements()
def _delete_action(self): # open dialog asking are you sure msg = 'Remove selected result from database?' result = message(message=msg, title='Delete result from database', buttons=['OK', 'Cancel']) if result: # remove from results_table self.results_table.remove(self.current_selection) self.current_selection = None
def _delete_action(self): # open dialog asking are you sure msg = 'Remove selected result from database?' result = message(message=msg, title='Delete result from database', buttons = ['OK', 'Cancel']) if result: # remove from results_table self.results_table.remove(self.current_selection) self.current_selection = None
def _get_info_on_model_fired(self): """Open dialog with model description.""" model_class = self._model_name_to_class[self.model_name] message(message = model_class.__doc__, title='Model info')
def _check_on_jobs_fired(self): user=getuser() recon_jobs=subprocess.check_output("qstat -u %s | grep 'recon'"%user,shell = True) message(message='%s'%recon_jobs)
def _get_info_on_model_fired(self): """Open dialog with model description.""" model_class = self._model_name_to_class[self.model_name] message(message=model_class.__doc__, title='Model info')
def _fire_event_fired(): message("Button clicked!")