def on_fanState(self, instance, value): #TODO 3 send turn on/off fans to serial port Logger.exception(self.__class__.__name__ + ': in [' + whoAmI() + '] fanState is ' + str(self.fanState) + ' but NOT IMPLEMENTED YET') popup = Popup(title='fanState Not implemented yet', content=Label(text='fanState Not implemented yet'), size_hint=(0.4, 0.2) ) popup.open()
def show_image(self, path): try: firefox = webbrowser.get('firefox') firefox.open(path) except Exception: Logger.exception( 'Calibration: Unable to open image "{}"'.format(path))
def show_image(path): try: firefox = webbrowser.get('firefox') firefox.open(path) except Exception as e: Logger.exception( 'Calibration: Unable to open image "{}", error: {}'.format( path, e))
def verify_registration(): try: if is_registered(): return True, None register() return True, None except Exception as e: Logger.exception(e) return False, e
def on_heaterState(self, instance, value): #TODO 3 set the heater duty cycle and make sure the duty cycle timer is running #also schedule a safety timer to force the heater off from time to time #TODO also add to initialisation and shutdown to force heater off Logger.exception(self.__class__.__name__ + ': in [' + whoAmI() + '] heaterState is ' + str(self.heaterState) + ' but NOT IMPLEMENTED YET') popup = Popup(title='heaterState Not implemented yet', content=Label(text='heaterState Not implemented yet'), size_hint=(0.4, 0.2) ) popup.open()
def _get(self, mimetype='text/plain'): clippy = PythonActivity._clipboard data = '' if sdk < 11: data = clippy.getText() else: ClipDescription = autoclass('android.content.ClipDescription') primary_clip = clippy.getPrimaryClip() if primary_clip: try: data = primary_clip.getItemAt(0) if data: data = data.coerceToText( PythonActivity.mActivity.getApplicationContext()) except Exception: Logger.exception('Clipboard: failed to paste') return data
def _update_from_metadata(self): ''' this updates the values of certain self fields listed in `augmented_fields`, with the values fetched from reading metadata.xml of that book. We shouldn't be doing this here, instead relying on all the right information being passed to the constructor, which will come when we can pass more structured Book objects (2.0-Release branch) ''' try: self.metadata = get_metadata(self.book_path) except Exception: Logger.exception( 'Failed to get book metadata from path: {}'.format( self.book_path)) self.metadata = None augmented_fields = ['isbn', 'shiptracking'] if self.metadata: for field in augmented_fields: if field in self.metadata: setattr(self, field, self._book_value_to_string(self.metadata, field))
def export_image(self, source, destination): try: shutil.copyfile(source, destination) Logger.info('Calibration: Image exported from "{}" to "{}"'.format( source, destination)) except shutil.Error: Logger.exception('Calibration: Image source path are the same. ' 'Source "{}", destionation "{}"'.format( source, destination)) except IOError: Logger.exception( 'Calibration: Destination "{}" is not writable'.format( destination)) except Exception: Logger.exception('Calibration: Unable to export image from "{}" ' 'to "{}"'.format(source, destination))