def _create_media(self): # Create a VLC Media object if any(self.source.startswith(prefix) for prefix in [ 'rtsp://', 'http://', 'https://', 'file://']): uri = jUri.parse(self.source) self._mediaObj = jVlcMedia(VlcVideoView.libVLC, uri) Logger.info('VlcVideoView: uri %s (%s)' % (self.source, self.state)) else: self._mediaObj = jVlcMedia(VlcVideoView.libVLC, self.source) Logger.info('VlcVideoView: path %s (%s)' % (self.source, self.state)) if self.options: if self.options.has_key('network-caching'): self._mediaObj.setHWDecoderEnabled(True, False) Logger.info( "VlcVideoView: HWDecoder enabled by network-caching") for n, v in self.options.items(): if n == 'hw-decoder': hw_enable = (v in ['force', 'enable', '1', 'True']) hw_force = v in ['force'] self._mediaObj.setHWDecoderEnabled(hw_enable, hw_force) Logger.info( "VlcVideoView: HWDecoder enabled {}, forced {}".format( hw_enable, hw_force)) else: s = ':{}={}'.format(n, v) if v else ':{}'.format(n) Logger.info("VlcVideoView: Media option {}".format(s)) self._mediaObj.addOption(s) self._mediaObj.setEventListener(self._vlcMediaEventsRedirector)
def core_select_lib(category, llist, create_instance=False): category = category.lower() for option, modulename, classname in llist: try: # module activated in config ? if option not in kivy.kivy_options[category]: Logger.debug('%s: option <%s> ignored by config' % (category.capitalize(), option)) continue # import module mod = __import__(name='%s.%s' % (category, modulename), globals=globals(), locals=locals(), fromlist=[modulename], level=-1) cls = mod.__getattribute__(classname) # ok ! Logger.info('%s: using <%s> as %s provider' % (category.capitalize(), option, category)) if create_instance: cls = cls() return cls except Exception as e: Logger.warning('%s: Unable to use <%s> as %s' 'provider' % (category.capitalize(), option, category)) Logger.debug('', exc_info = e) Logger.critical('%s: Unable to find any valuable %s provider ' 'at all!' % (category.capitalize(), category.capitalize()))
def on_play(self, instance, value): if not value: Logger.info('Recorder: Stop playing %r' % self.filename) EventLoop.remove_input_provider(self) return if not exists(self.filename): Logger.error('Recorder: Unable to found %r file, play aborted.' % ( self.filename)) return with open(self.filename, 'r') as fd: data = fd.read().splitlines() if len(data) < 2: Logger.error('Recorder: Unable to play %r, file truncated.' % ( self.filename)) return if data[0] != '#RECORDER1.0': Logger.error('Recorder: Unable to play %r, invalid header.' % ( self.filename)) return # decompile data self.play_data = [literal_eval(x) for x in data[1:]] self.play_time = time() self.play_me = {} Logger.info('Recorder: Start playing %d events from %r' % (len(self.play_data), self.filename)) EventLoop.add_input_provider(self)
def on_vlcplayer_error(self, mediaPlayerEvent): errorMessage = jVlcUtil.getErrorMsg() Logger.info( 'VlcVideoView: on_vlcplayer_error {} for {}'.format( errorMessage, self.source)) self.player_state = 'error' self.eos = True
def read(self, keep_reading): """ Reads data from the socket. Will continue to read until either "\r\n" is found in the data read from the socket or keep_reading.is_set() returns false :param keep_reading: Event object that is checked while data is read :type keep_reading: threading.Event :return: String or None """ msg = '' Logger.info("SocketConnection: reading...") while keep_reading.is_set(): try: data = self.socket.recv(4096) if data == '': return None msg += data if msg[-2:] == '\r\n': if msg != '': Logger.info("SocketConnection: returning data {}".format(msg)) return msg else: return None except socket.timeout: pass
def on_start(self): ''' This is the start point of the kivy ui ''' import time Logger.info('Time to on_start: {} <<<<<<<<'.format(time.clock())) Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded)) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) # Register fonts without this you won't be able to use bold/italic... # inside markup. from kivy.core.text import Label Label.register('Roboto', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf') win.softinput_mode = 'below_target' self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path()) # init plugins run_hook('init_kivy', self) # were we sent a url? self.uri = self.electrum_config.get('url') # default tab self.switch_to('send' if self.uri else 'history')
def on_start(self): ''' This is the start point of the kivy ui ''' import time Logger.info('Time to on_start: {} <<<<<<<<'.format(time.clock())) Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded)) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) win.softinput_mode = 'below_target' self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path()) # init plugins run_hook('init_kivy', self) # default tab self.switch_to('history') # bind intent for bitcoin: URI scheme if platform == 'android': from android import activity from jnius import autoclass PythonActivity = autoclass('org.renpy.android.PythonActivity') mactivity = PythonActivity.mActivity self.on_new_intent(mactivity.getIntent()) activity.bind(on_new_intent=self.on_new_intent) # URI passed in config uri = self.electrum_config.get('url') if uri: self.set_URI(uri)
def protocol_line_received(self, line): Logger.info("Line received: {}".format(line)) header = line[:2] body = line[3:] if header == 'DL': self.save_available_endpoints(body) if self.enpoint_is_connected: pass else: self.endpoint_connecting_process() elif header == 'CD': if body == 'OK': self.enpoint_is_connected = True self.utility_lt.reset() self.con_widget.update_status('GREEN', self.selected_device) else: self.on_device_disconnected() elif header == 'DD': self.on_device_disconnected() elif header == 'RE': self.endpoint_request_received(body) elif header == 'SE': #@TODO #handle error Logger.warning("SERVER ERROR: {}".format(body)) pass else: #@TODO #handle undefined command Logger.warning("UNDEFINED COMMAND: {}".format(body)) pass
def do_pause(self): # should go to app pause mode. from kivy.app import App from kivy.base import stopTouchApp app = App.get_running_app() if not app: Logger.info('WindowSDL: No running App found, exit.') stopTouchApp() return if not app.dispatch('on_pause'): Logger.info('WindowSDL: App doesn\'t support pause mode, stop.') stopTouchApp() return # XXX FIXME wait for sdl resume while True: event = self._win.poll() if event is False: continue if event is None: continue action, args = event[0], event[1:] if action == 'quit': EventLoop.quit = True self.close() break elif action == 'windowrestored': break app.dispatch('on_resume')
def check_auth(self): """ Launch an authentication check """ Logger.info("Ndf : Checking auth : NDFAPP") _connection = self.get_connection() _connection.check_auth(self.check_auth_success, self.check_auth_error)
def core_register_libs(category, libs, base='kivy.core'): if 'KIVY_DOC' in os.environ: return category = category.lower() libs_loaded = [] libs_ignored = [] for option, lib in libs: try: # module activated in config ? if option not in kivy.kivy_options[category]: Logger.debug('{0}: option <{1}> ignored by config'.format( category.capitalize(), option)) libs_ignored.append(lib) continue # import module __import__(name='{2}.{0}.{1}'.format(category, lib, base), globals=globals(), locals=locals(), fromlist=[lib], level=0) libs_loaded.append(lib) except Exception as e: Logger.trace('{0}: Unable to use <{1}> as loader!'.format( category.capitalize(), option)) Logger.trace('', exc_info=e) libs_ignored.append(lib) Logger.info('{0}: Providers: {1} {2}'.format( category.capitalize(), ', '.join(libs_loaded), '({0} ignored)'.format( ', '.join(libs_ignored)) if libs_ignored else ''))
def on_video_loaded(self, instance, value): Logger.info('VlcExampleApp: on_video_loaded {}'.format(value)) if value and self._video.duration > 0: self._video.state = 'play' self._show_progress(True) else: self._hide_progress()
def LoadScript(self,uScriptName): ''' loads a specific script ''' if uScriptName in self.aScripts: return self.aModules.get(uScriptName) if uScriptName=="": return None Logger.info (u'Scripts: Loading Script: '+uScriptName) uScriptFilePy = AdjustPathToOs(oORCA.uScriptsPath+u'/'+uScriptName+u'/script.py') uScriptFile = uScriptFilePy if not FileExists(uScriptFile): return None try: oModule = imp.load_source('cScript'+"_"+uScriptName, uScriptFile) self.aModules[uScriptName]=oModule oScript = oModule.cScript() oScript.Init(oORCA,uScriptName, uScriptFile) self.aScripts[uScriptName]=oScript return oModule except Exception as e: uMsg=LogError(u'Scripts: Fatal Error Loading Script: '+uScriptName+ u' :',e) ShowErrorPopUp(uMessage=uMsg) return None
def on_start(self): ''' This is the start point of the kivy ui ''' import time Logger.info('Time to on_start: {} <<<<<<<<'.format(time.clock())) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) #win.softinput_mode = 'below_target' self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path()) # init plugins run_hook('init_kivy', self) # fiat currency self.fiat_unit = self.fx.ccy if self.fx.is_enabled() else '' self.network.register_callback(self.on_quotes, ['on_quotes']) self.network.register_callback(self.on_history, ['on_history']) # default tab self.switch_to('history') # bind intent for bitcoin: URI scheme if platform == 'android': from android import activity from jnius import autoclass PythonActivity = autoclass('org.kivy.android.PythonActivity') mactivity = PythonActivity.mActivity self.on_new_intent(mactivity.getIntent()) activity.bind(on_new_intent=self.on_new_intent) # URI passed in config uri = self.electrum_config.get('url') if uri: self.set_URI(uri)
def _activate_console(self): if not self in self.win.children: self.win.add_widget(self) self.y = 0 for addon in self._addons: addon.activate() Logger.info('Console: console activated')
def on_touch_move(self, touch): if super(ShapeBuilder, self).on_touch_move(touch): return True Logger.info('tesselate: on_touch_move (%5.2f, %5.2f)' % touch.pos) self.shape.extend(touch.pos) self.build() return True
def _on_gstplayer_message(mtype, message): if mtype == 'error': Logger.error('AudioGstplayer: {}'.format(message)) elif mtype == 'warning': Logger.warning('AudioGstplayer: {}'.format(message)) elif mtype == 'info': Logger.info('AudioGstplayer: {}'.format(message))
def _event_filter(self, action): from kivy.app import App if action == 'app_terminating': EventLoop.quit = True self.close() elif action == 'app_lowmemory': self.dispatch('on_memorywarning') elif action == 'app_willenterbackground': from kivy.base import stopTouchApp app = App.get_running_app() if not app: Logger.info('WindowSDL: No running App found, exit.') stopTouchApp() return 0 if not app.dispatch('on_pause'): Logger.info('WindowSDL: App doesn\'t support pause mode, stop.') stopTouchApp() return 0 self._pause_loop = True elif action == 'app_didenterforeground': # on iOS, the did enter foreground is launched at the start # of the application. in our case, we want it only when the app # is resumed if self._pause_loop: self._pause_loop = False app = App.get_running_app() app.dispatch('on_resume') return 0
def dripper_type_changed(self, instance, value): Logger.info("Drippper Type change to %s" % value) self.ids.setup_box_id.clear_widgets() self.ids.visuals_box_id.clear_widgets() self.ids.settings_box_id.clear_widgets() self.configuration_api.stop_counting_drips() self.configuration_api.set_dripper_type(value) self.circut_visuals.stop_animation() if value == 'emulated': self.ids.setup_box_id.add_widget(BoxLayout()) self.ids.visuals_box_id.add_widget(self.emulated_visuals) self.ids.settings_box_id.add_widget(self.emulated_settings) elif value == 'photo': self.ids.setup_box_id.add_widget(BoxLayout()) self.ids.visuals_box_id.add_widget(self.photo_visuals) self.ids.settings_box_id.add_widget(self.photo_settings) elif value == 'microcontroller': self.ids.setup_box_id.add_widget(self.circut_setup) self.ids.visuals_box_id.add_widget(self.circut_visuals) self.circut_visuals.start_animation() self.ids.settings_box_id.add_widget(self.circut_settings) self.configuration_api.start_counting_drips(self.drip_call_back)
def _request_meta_handler(self): if self._meta_is_stale_counter <= 0: Logger.info('DataBusPump: Sample Meta is stale, requesting meta') self._meta_is_stale_counter = SAMPLES_TO_WAIT_FOR_META self.request_meta() else: self._meta_is_stale_counter -= 1
def status_worker(self): Logger.info('StatusPump: status_worker starting') self._rc_api.addListener('status', self._on_status_updated) while self._running.is_set(): self._rc_api.get_status() sleep(self.STATUS_QUERY_INTERVAL) Logger.info('StatusPump: status_worker exiting')
def _init_datastore(dstore_path): if os.path.isfile(dstore_path): self._datastore.open_db(dstore_path) else: Logger.info('AnalysisView: creating datastore...') self._datastore.new(dstore_path) self.ids.sessions_view.datastore = self._datastore
def __init__(self,con): ''' pass the connection object. ''' self.con = con self.loaded = False loading = True lap = 0 while loading: f = con.openFile(self.path) val = f.uread() f.close() self.lb_string = val try: self.lb = logback.Logback(val) except ValueError as e: if lap == 0: Logger.info(("Octo.model: Value error while loading logback. "+ "This is probably due to it being corrupt."+ " Attepting to restore...")) self.con.simple_sudo("cp {0}.bak {0}".format(self.path)) lap += 1 continue Logger.error("Octo.model: Can't fix logback. aborting") break loading = False self.loaded = True
def recover_connection(self): if self._disconnect_callback: self._disconnect_callback() if self._enable_autodetect.is_set(): Logger.info("RCPAPI: attempting to recover connection") self.run_auto_detect()
def __init__(self, device, args): super(HIDInputMotionEventProvider, self).__init__(device, args) global Window, Keyboard if Window is None: from kivy.core.window import Window if Keyboard is None: from kivy.core.window import Keyboard self.input_fn = None self.default_ranges = dict() # split arguments args = args.split(',') if not args: Logger.error('HIDInput: Filename missing in configuration') Logger.error('HIDInput: Use /dev/input/event0 for example') return None # read filename self.input_fn = args[0] Logger.info('HIDInput: Read event from <%s>' % self.input_fn) # read parameters for arg in args[1:]: if arg == '': continue arg = arg.split('=') # ensure it's a key = value if len(arg) != 2: Logger.error('HIDInput: invalid parameter ' '%s, not in key=value format.' % arg) continue # ensure the key exist key, value = arg if key not in HIDInputMotionEventProvider.options: Logger.error('HIDInput: unknown %s option' % key) continue # ensure the value try: self.default_ranges[key] = int(value) except ValueError: err = 'HIDInput: invalid value "%s" for "%s"' % ( key, value) Logger.error(err) continue # all good! Logger.info('HIDInput: Set custom %s to %d' % ( key, int(value))) if 'rotation' not in self.default_ranges: self.default_ranges['rotation'] = 0 elif self.default_ranges['rotation'] not in (0, 90, 180, 270): Logger.error('HIDInput: invalid rotation value ({})'.format( self.default_ranges['rotation'])) self.default_ranges['rotation'] = 0
def on_write_config_complete(self, result): Logger.info("RaceCaptureApp: Config written") self.showActivity("Writing completed") self.rc_config.stale = False self.dataBusPump.meta_is_stale() for listener in self.config_listeners: Clock.schedule_once(lambda dt, inner_listener=listener: inner_listener.dispatch('on_config_written', self.rc_config))
def update(self, dispatch_fn): if len(self.play_data) == 0: Logger.info('Recorder: Playing finished.') self.play = False dt = time() - self.play_time while len(self.play_data): event = self.play_data[0] assert(len(event) == 4) if event[0] > dt: return etype, uid, args = event[1:] if etype == 'begin': me = RecorderMotionEvent('recorder', uid, args) self.play_me[uid] = me elif etype == 'update': me = self.play_me[uid] me.depack(args) elif etype == 'end': me = self.play_me.pop(uid) me.depack(args) dispatch_fn(etype, me) self.play_data.pop(0)
def on_start(self): """ This is the start point of the kivy ui """ Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded)) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) # Register fonts without this you won't be able to use bold/italic... # inside markup. from kivy.core.text import Label Label.register( "Roboto", "data/fonts/Roboto.ttf", "data/fonts/Roboto.ttf", "data/fonts/Roboto-Bold.ttf", "data/fonts/Roboto-Bold.ttf", ) if platform == "android": # bind to keyboard height so we can get the window contents to # behave the way we want when the keyboard appears. win.bind(keyboard_height=self.on_keyboard_height) self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path())
def onPictureTaken(self, data, camera): s = data.tostring() with open(self.filename, 'wb') as f: f.write(s) Logger.info('xcamera: picture saved to %s', self.filename) camera.startPreview() self.on_success(self.filename)
def reset_game(self, instance=None, value=None): Logger.info("reset: game") if self.board: self.playing_area.remove_widget(self.board) self.board = GameBoard() self.playing_area.add_widget(self.board) self.start_time = Clock.get_time()
def on_quotes(self, d): Logger.info("on_quotes") self._trigger_update_history()
self.card_detected(uid) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description="Grisebank") parser.add_argument('configfile', default='config.ini') parser.add_argument('cardsfile', default='cards.yaml') args = parser.parse_args() c = configparser.RawConfigParser() c.optionxform = lambda option: option # make configparser case aware c.read(args.configfile) cards = yaml.safe_load(open(args.cardsfile)) Logger.info('%i rfid card definitions loaded', len(cards)) sbank = bank.GriseBank(c) from kivy.config import Config Config.set('graphics', 'fullscreen', 'auto') gapp = GriseBankApp() pitft = PiTFT_Screen() gapp.setScreen(pitft) gapp.setBank(sbank) gapp.setCards(cards) gapp.run()
Config.set('graphics', 'rotation', arg) elif opt in ('-d', '--debug'): level = LOG_LEVELS.get('debug') Logger.setLevel(level=level) elif opt == '--dpi': environ['KIVY_DPI'] = arg if need_save and 'KIVY_NO_CONFIG' not in environ: try: with open(kivy_config_fn, 'w') as fd: Config.write(fd) except Exception as e: Logger.exception( 'Core: error while saving default' 'configuration file:', str(e)) Logger.info('Core: Kivy configuration saved.') sys.exit(0) # configure all activated modules from kivy.modules import Modules Modules.configure() # android hooks: force fullscreen and add android touch input provider if platform in ('android', 'ios'): from kivy.config import Config Config.set('graphics', 'fullscreen', 'auto') Config.remove_section('input') Config.add_section('input') if platform == 'android': Config.set('input', 'androidtouch', 'android')
def _thread_run(self, **kwargs): input_fn = kwargs.get('input_fn') queue = self.queue dispatch_queue = self.dispatch_queue device = kwargs.get('device') drs = kwargs.get('default_ranges').get touches = {} touches_sent = [] point = {} l_points = [] # prepare some vars to get limit of some component range_min_position_x = 0 range_max_position_x = 2048 range_min_position_y = 0 range_max_position_y = 2048 range_min_pressure = 0 range_max_pressure = 255 range_min_abs_x = 0 range_max_abs_x = 255 range_min_abs_y = 0 range_max_abs_y = 255 range_min_abs_pressure = 0 range_max_abs_pressure = 255 invert_x = int(bool(drs('invert_x', 0))) invert_y = int(bool(drs('invert_y', 1))) rotation = drs('rotation', 0) def assign_coord(point, value, invert, coords): cx, cy = coords if invert: value = 1. - value if rotation == 0: point[cx] = value elif rotation == 90: point[cy] = value elif rotation == 180: point[cx] = 1. - value elif rotation == 270: point[cy] = 1. - value def assign_rel_coord(point, value, invert, coords): cx, cy = coords if invert: value = -1 * value if rotation == 0: point[cx] += value elif rotation == 90: point[cy] += value elif rotation == 180: point[cx] += -value elif rotation == 270: point[cy] += -value def process_as_multitouch(tv_sec, tv_usec, ev_type, ev_code, ev_value): # sync event if ev_type == EV_SYN: if ev_code == SYN_MT_REPORT: if 'id' not in point: return l_points.append(point.copy()) elif ev_code == SYN_REPORT: process(l_points) del l_points[:] elif ev_type == EV_MSC and ev_code in (MSC_RAW, MSC_SCAN): pass else: # compute multitouch track if ev_code == ABS_MT_TRACKING_ID: point.clear() point['id'] = ev_value elif ev_code == ABS_MT_POSITION_X: val = normalize(ev_value, range_min_position_x, range_max_position_x) assign_coord(point, val, invert_x, 'xy') elif ev_code == ABS_MT_POSITION_Y: val = 1. - normalize(ev_value, range_min_position_y, range_max_position_y) assign_coord(point, val, invert_y, 'yx') elif ev_code == ABS_MT_ORIENTATION: point['orientation'] = ev_value elif ev_code == ABS_MT_BLOB_ID: point['blobid'] = ev_value elif ev_code == ABS_MT_PRESSURE: point['pressure'] = normalize(ev_value, range_min_pressure, range_max_pressure) elif ev_code == ABS_MT_TOUCH_MAJOR: point['size_w'] = ev_value elif ev_code == ABS_MT_TOUCH_MINOR: point['size_h'] = ev_value def process_as_mouse_or_keyboard( tv_sec, tv_usec, ev_type, ev_code, ev_value): if ev_type == EV_SYN: if ev_code == SYN_REPORT: process([point]) elif ev_type == EV_REL: if ev_code == 0: assign_rel_coord(point, min(1., max(-1., ev_value / 1000.)), invert_x, 'xy') elif ev_code == 1: assign_rel_coord(point, min(1., max(-1., ev_value / 1000.)), invert_y, 'yx') elif ev_type != EV_KEY: if ev_code == ABS_X: val = normalize(ev_value, range_min_abs_x, range_max_abs_x) assign_coord(point, val, invert_x, 'xy') elif ev_code == ABS_Y: val = 1. - normalize(ev_value, range_min_abs_y, range_max_abs_y) assign_coord(point, val, invert_y, 'yx') elif ev_code == ABS_PRESSURE: point['pressure'] = normalize(ev_value, range_min_abs_pressure, range_max_abs_pressure) else: buttons = { 272: 'left', 273: 'right', 274: 'middle', 275: 'side', 276: 'extra', 277: 'forward', 278: 'back', 279: 'task', 330: 'touch', 320: 'pen'} if ev_code in buttons.keys(): if ev_value: if 'button' not in point: point['button'] = buttons[ev_code] point['id'] += 1 if '_avoid' in point: del point['_avoid'] elif 'button' in point: if point['button'] == buttons[ev_code]: del point['button'] point['id'] += 1 point['_avoid'] = True else: if ev_value == 1: z = keyboard_keys[ev_code][-1 if 'shift' in Window._modifiers else 0] if z == 'shift' or z == 'alt': Window._modifiers.append(z) dispatch_queue.append(('key_down', ( Keyboard.keycodes[z.lower()], ev_code, keys_str.get(z, z), Window._modifiers))) elif ev_value == 0: z = keyboard_keys[ev_code][-1 if 'shift' in Window._modifiers else 0] dispatch_queue.append(('key_up', ( Keyboard.keycodes[z.lower()], ev_code, keys_str.get(z, z), Window._modifiers))) if z == 'shift': Window._modifiers.remove('shift') def process(points): if not is_multitouch: dispatch_queue.append(('mouse_pos', ( points[0]['x'] * Window.width, points[0]['y'] * Window.height))) actives = [args['id'] for args in points if 'id' in args and '_avoid' not in args] for args in points: tid = args['id'] try: touch = touches[tid] if touch.sx == args['x'] and touch.sy == args['y']: continue touch.move(args) if tid not in touches_sent: queue.append(('begin', touch)) touches_sent.append(tid) queue.append(('update', touch)) except KeyError: if '_avoid' not in args: touch = HIDMotionEvent(device, tid, args) touches[touch.id] = touch if tid not in touches_sent: queue.append(('begin', touch)) touches_sent.append(tid) for tid in list(touches.keys())[:]: if tid not in actives: touch = touches[tid] if tid in touches_sent: touch.update_time_end() queue.append(('end', touch)) touches_sent.remove(tid) del touches[tid] def normalize(value, vmin, vmax): return (value - vmin) / float(vmax - vmin) # open the input fd = open(input_fn, 'rb') # get the controler name (EVIOCGNAME) device_name = str(fcntl.ioctl(fd, EVIOCGNAME + (256 << 16), " " * 256)).split('\x00')[0] Logger.info('HIDMotionEvent: using <%s>' % device_name) # get abs infos bit = fcntl.ioctl(fd, EVIOCGBIT + (EV_MAX << 16), ' ' * sz_l) bit, = struct.unpack('Q', bit) is_multitouch = False for x in range(EV_MAX): # preserve this, we may want other things than EV_ABS if x != EV_ABS: continue # EV_ABS available for this device ? if (bit & (1 << x)) == 0: continue # ask abs info keys to the devices sbit = fcntl.ioctl(fd, EVIOCGBIT + x + (KEY_MAX << 16), ' ' * sz_l) sbit, = struct.unpack('Q', sbit) for y in range(KEY_MAX): if (sbit & (1 << y)) == 0: continue absinfo = fcntl.ioctl(fd, EVIOCGABS + y + (struct_input_absinfo_sz << 16), ' ' * struct_input_absinfo_sz) abs_value, abs_min, abs_max, abs_fuzz, \ abs_flat, abs_res = struct.unpack('iiiiii', absinfo) if y == ABS_MT_POSITION_X: is_multitouch = True range_min_position_x = drs('min_position_x', abs_min) range_max_position_x = drs('max_position_x', abs_max) Logger.info('HIDMotionEvent: ' + '<%s> range position X is %d - %d' % ( device_name, abs_min, abs_max)) elif y == ABS_MT_POSITION_Y: is_multitouch = True range_min_position_y = drs('min_position_y', abs_min) range_max_position_y = drs('max_position_y', abs_max) Logger.info('HIDMotionEvent: ' + '<%s> range position Y is %d - %d' % ( device_name, abs_min, abs_max)) elif y == ABS_MT_PRESSURE: range_min_pressure = drs('min_pressure', abs_min) range_max_pressure = drs('max_pressure', abs_max) Logger.info('HIDMotionEvent: ' + '<%s> range pressure is %d - %d' % ( device_name, abs_min, abs_max)) elif y == ABS_X: range_min_abs_x = drs('min_abs_x', abs_min) range_max_abs_x = drs('max_abs_x', abs_max) Logger.info('HIDMotionEvent: ' + '<%s> range ABS X position is %d - %d' % ( device_name, abs_min, abs_max)) elif y == ABS_Y: range_min_abs_y = drs('min_abs_y', abs_min) range_max_abs_y = drs('max_abs_y', abs_max) Logger.info('HIDMotionEvent: ' + '<%s> range ABS Y position is %d - %d' % ( device_name, abs_min, abs_max)) elif y == ABS_PRESSURE: range_min_abs_pressure = drs( 'min_abs_pressure', abs_min) range_max_abs_pressure = drs( 'max_abs_pressure', abs_max) Logger.info('HIDMotionEvent: ' + '<%s> range ABS pressure is %d - %d' % ( device_name, abs_min, abs_max)) # init the point if not is_multitouch: point = {'x': .5, 'y': .5, 'id': 0, '_avoid': True} # read until the end while fd: data = fd.read(struct_input_event_sz) if len(data) < struct_input_event_sz: break # extract each event for i in range(int(len(data) / struct_input_event_sz)): ev = data[i * struct_input_event_sz:] # extract timeval + event infos infos = struct.unpack('LLHHi', ev[:struct_input_event_sz]) if is_multitouch: process_as_multitouch(*infos) else: process_as_mouse_or_keyboard(*infos)
def _apply(self, command): # Internal use Logger.info(f'CmdTweak: calling {command}') ret = os.system(command) Logger.info(f'CmdTweak: System returned {ret}') return ret
def on_network_error(*largs): print 'Network Error %s' % str(*largs) Logger.info('item_vote: failed voting (network error)') Toast('Voting failed (no network access)')
def on_history(self, d): Logger.info("on_history") self._trigger_update_history()
def search_for_temp_dir(self): if not os.path.exists(TEMP_DIR): os.makedirs(TEMP_DIR) Logger.info("Made temp directory for slicing")
def infill(self): Logger.info("Getting infill") return self._infill
def on_language(self, instance, language): Logger.info('language: {}'.format(language)) _.switch_lang(language)
def layer_height(self): Logger.info("Getting layer_height") return self._layer_height
def infill(self, value): Logger.info("setting infill to: " + str(self._infill)) self._infill = value
def support(self, value): self._support = value Logger.info("setting support to: " + str(self._support))
def layer_height(self, value): Logger.info("setting layer_height to: " + str(self._layer_height)) self._layer_height = value
Thanks for the support to Buchsenhausen, Innsbruck, Austria. ''' from . import OSC import socket, os, time, errno, sys from threading import Lock from kivy.logger import Logger try: # multiprocessing support is not good on window if sys.platform in ('win32', 'cygwin'): raise use_multiprocessing = True from multiprocessing import Process, Queue, Value import multiprocessing.synchronize Logger.info('OSC: using <multiprocessing> for socket') except: use_multiprocessing = False from threading import Thread Logger.info('OSC: using <thread> for socket') # globals outSocket = 0 oscThreads = {} oscLock = Lock() if use_multiprocessing: def _readQueue(thread_id=None): global oscThreads for id in oscThreads: if thread_id is not None:
def platform_adhesion(self): Logger.info("Getting platform_adhesion") return self._platform_adhesion
def Monitor_Screen(self, dt): if roboprinter.robosm.current != 'select_language' and not self.pressed_yes: lang.reload_language(self.old_language) Logger.info("Switched Back to old language LC: " + str(self.old_language)) return False
def support(self): Logger.info("Getting support") return self._support
def onRewardedVideoAdOpened(self): Logger.info("KivMob: onRewardedVideoAdOpened() called.") self._listener.on_rewarded_video_ad_opened()
from ffpyplayer.player import MediaPlayer from ffpyplayer.tools import set_log_callback, get_log_callback except: raise from threading import Thread from kivy.clock import Clock, mainthread from kivy.logger import Logger from kivy.core.video import VideoBase from kivy.graphics import Rectangle, BindTexture from kivy.graphics.texture import Texture from kivy.graphics.fbo import Fbo from kivy.weakmethod import WeakMethod import time Logger.info('VideoFFPy: Using ffpyplayer {}'.format(ffpyplayer.version)) logger_func = { 'quiet': Logger.critical, 'panic': Logger.critical, 'fatal': Logger.critical, 'error': Logger.error, 'warning': Logger.warning, 'info': Logger.info, 'verbose': Logger.debug, 'debug': Logger.debug } def _log_callback(message, level): message = message.strip()
def onRewardedVideoAdLeftApplication(self): Logger.info( "KivMob: onRewardedVideoAdLeftApplicaxtion() called." ) self._listener.on_rewarded_video_ad_left_application()
def onRewardedVideoCompleted(self): Logger.info("KivMob: onRewardedVideoCompleted() called.") self._listener.on_rewarded_video_ad_completed()
def show_rewarded_ad(self): """ Display rewarded video ad. """ Logger.info("KivMob: show_rewarded_ad() called.") self.bridge.show_rewarded_ad()
def onRewardedVideoAdFailedToLoad(self, errorCode): Logger.info("KivMob: onRewardedVideoAdFailedToLoad() called.") # Logger.info('KivMob: ErrorCode ' + str(errorCode)) self._listener.on_rewarded_video_ad_failed_to_load(errorCode)
def destroy_interstitial(self): """ Destroys current interstitial ad. """ Logger.info("KivMob: destroy_interstitial() called.") self.bridge.destroy_interstitial()
def onRewarded(self, reward): Logger.info("KivMob: onRewarded() called.") self._listener.on_rewarded( reward.getType(), reward.getAmount() )
def show_interstitial(self): """ Displays interstitial ad, if it has loaded. """ Logger.info("KivMob: show_interstitial() called.") self.bridge.show_interstitial()
def hide_banner(self): """ Hide current banner ad. """ Logger.info("KivMob: hide_banner() called.") self.bridge.hide_banner()
def show_banner(self): """ Displays banner ad, if it has loaded. """ Logger.info("KivMob: show_banner() called.") self.bridge.show_banner()
def destroy_banner(self): """ Destroys current banner ad. """ Logger.info("KivMob: destroy_banner() called.") self.bridge.destroy_banner()