def gps_stop(self): print("gps_stop") if self.gpsD.androidServiceStatus: self.gpsD.androidServiceStatus = False gps.stop() else: print("skipp ! it's not running")
def envia_posicao(self, **kwargs): # função feita para envio dos dados de posição e user para o server_side que irá persistir as posições global url #global filename #print "teste" #last=subprocess.check_output("w",shell=True) #ls=Popup(title="LOGIN",content=Label(text="logged in \n" + last)) #ls.open() headers = {'content-type': 'application/json'} payload = { "method": "atualiza_geojson_file", #"params": {'motor': False}, "params": kwargs, "jsonrpc": "2.0", "id": 2, } headers = {'content-type': 'application/json'} #print "filename dentro da func envia_posição ",filename #popup = Popup(title="GPS Error", # content=Label(text=" Até antes do request a func envia_posicao funcionou") # ).open() r = requests.post(url, json.dumps(payload), headers=headers).json() #with open(filename, 'rb') as f: # r = requests.post(url,json.dumps(payload),headers=headers,files={'image': f}).json() #manda_dados = requests.post(url,json.dumps(payload),headers=headers).json() gps.stop() popup = Popup(title="enviando imagem", content=Label(text="enviando imagem")).open()
def storeLocation(self, **kwargs): locationData = kwargs print("WEEEE") print(locationData) gps.stop() self.mapview.center_on(locationData["lat"], locationData["lon"]) return locationData
def stop_gps_localize(self): mapview = self.mapview_property try: gps.stop() except NotImplementedError: self.gps_not_found_message() return if self.gps_marker is not None: mapview.remove_marker(self.gps_marker) self.gps_marker = None
def change_interval(self): try: gps.stop() gps.start(minTime=self.interval_slider * 1000) except NotImplementedError: self.gps_status = 'GPS is not implemented for your platform' print('exception interval -> {}'.format(self.interval_slider.value)) self.interval_callback.cancel() Clock.schedule_once(self.my_callback, 0) self.interval_callback = Clock.schedule_interval(self.my_callback, self.interval_slider.value)
def on_stop(self, *_): try: gps.stop() except Exception: Logger.info('On_pause: %s', exc_info=1) files = glob.glob('/cache/*.png') for f in files: try: os.remove(f) except OSError as e: Logger.info('Chache not removed: ' + str(e))
def timer(self, dt): if isTimerScreen: if self.count == 0: self.ids.countdown.font_size = 48 self.ids.countdown.text = self.get_map_location() gps.stop() Clock.unschedule(self.timer) # call.makecall("+36306241796") else: self.alarm() self.count -= 1 self.ids.countdown.text = str(self.count)
def update_location(self, *args, **kwargs): lat = kwargs['lat'] lon = kwargs['lon'] if lat > 49.994698 and lat < 50.249160 and lon > 5.274382 and lon < 5.849791: gps_tracker = App.get_running_app().root.get_screen( "routemap").ids.gps_tracker gps_tracker.lat = lat gps_tracker.lon = lon else: print("gps not on map") from plyer import gps gps.stop()
def gps_location(self, lat=0.0, lon=0.0, speed=0.0, bearing=0.0, altitude=0.0, accuracy=0.0): '''Gps on location callback to get location from latitude and longitude''' if not self.located: self.located = True gps.stop() self.timeout_event.cancel() thread = threading.Thread(target=self.get_location_from_coords, args=(lat, lon, altitude)) thread.start()
def on_receive(self, context, intent): self.context = context name = '' action = intent.getAction() parcable = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) device = cast(BluetoothDevice, parcable) name = device.getName() if action == BluetoothDevice.ACTION_ACL_DISCONNECTED: # print('started') if name == self.device: print('disconected') self.unregister_broadcast_receiver() gps.stop() self.stop_service()
def timer(self, dt): if isTimerScreen: if self.count == 0: Clock.unschedule(self.timer) self.ids.countdown.font_size = 48 self.ids.countdown.text = self.get_map_location() gps.stop() with open('phone_numbers.csv', mode='r') as phone_numbers: student_reader = csv.reader(phone_numbers, delimiter=',') for phone_number in student_reader: if phone_number and phone_number[ 0] is not "Please enter a phone number": sms.send(phone_number[0], self.get_map_location()) call.makecall(phone_number[0]) else: self.alarm() self.count -= 1 self.ids.countdown.text = str(self.count)
def on_pause(self): gps.stop() return True
def stop(self): gps.stop() db = Database(url, auth_key) db.delete(self.code)
def stop(self): gps.stop()
def stop(self): gps.stop() self.gps_running = False
def stop(self): self.gps_status = 'Click Start to Start GPS location updates' gps.stop()
def stop(self): try: gps.stop() except NotImplementedError: self.gps_status = 'GPS is not implemented for your platform'
def stop_tracking(): gps.stop()
def gps_stop(self): if self.gps_status: gps.stop()
def disable(self): ''' ''' gps.stop()
def receive_gps(self, **kwargs): if kwargs is not {}: self.current_location = kwargs gps.stop() Clock.schedule_once(self.start_gps, self.gps_loc_interval)
__version__ = "0.1"
def on_leave(self) -> None: gps.stop()
def stop(): if use_gps: gps.stop() gps_on = False
def stop(self): super().stop() if gps_is_implemented: gps.stop()
def deactivate(self): gps.stop()
def publish_terminal(self, terminal, _data_queue): terminal.insert_text("\n") if (platform == 'android') or (platform == 'ios'): try: vibrator.vibrate(1) except: pass #Accelerometer if self._data_object.get("sensor") == "Accelerometer": try: accelerometer.enable() except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return previous_payload_hash = None while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": try: accelerometer.disable() except: pass break if None in accelerometer.acceleration: pass else: payload_hash = hashlib.md5(str(accelerometer.acceleration).encode('utf-8')).hexdigest() if (previous_payload_hash is not None): if (previous_payload_hash == payload_hash): pass else: previous_payload_hash = payload_hash payload = "(x, y, z): " + str(accelerometer.acceleration) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) else: payload = "(x, y, z): " + str(accelerometer.acceleration) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) #Compass elif self._data_object.get("sensor") == "Compass": try: compass.enable() except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return previous_payload_hash = None while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": try: compass.disable() except: pass break if None in compass.field: pass else: payload_hash = hashlib.md5(str(compass.field).encode('utf-8')).hexdigest() if (previous_payload_hash is not None): if (previous_payload_hash == payload_hash): pass else: previous_payload_hash = payload_hash payload = "(x, y, z): " + str(compass.field) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) else: payload = "(x, y, z): " + str(compass.field) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) #GPS elif self._data_object.get("sensor") == "GPS": try: gps.configure(on_location=self.on_location, on_status=self.on_status) gps.start(1000, 0) except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return previous_payload_hash = None while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": try: gps.stop() except: pass break if self.gps_location is None: pass else: payload_hash = hashlib.md5(str(self.gps_location).encode('utf-8')).hexdigest() if (previous_payload_hash is not None): if (previous_payload_hash == payload_hash): pass else: previous_payload_hash = payload_hash payload = str(self.gps_location) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(3) else: payload = str(self.gps_location) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.5) #Barometer elif self._data_object.get("sensor") == "Barometer": try: barometer.enable() except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return previous_payload_hash = None while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": try: barometer.disable() except: pass break if barometer.pressure is None: pass else: payload_hash = hashlib.md5(str(barometer.pressure).encode('utf-8')).hexdigest() if (previous_payload_hash is not None): if (previous_payload_hash == payload_hash): pass else: previous_payload_hash = payload_hash payload = "hPa: " + str(barometer.pressure) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) else: payload = "hPa: " + str(barometer.pressure) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return #Gravity elif self._data_object.get("sensor") == "Gravity": try: gravity.enable() except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return previous_payload_hash = None while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": try: gravity.disable() except: pass break if None in gravity.gravity: pass else: payload_hash = hashlib.md5(str(gravity.gravity).encode('utf-8')).hexdigest() if (previous_payload_hash is not None): if (previous_payload_hash == payload_hash): pass else: previous_payload_hash = payload_hash payload = "(x, y, z): " + str(gravity.gravity) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) else: payload = "(x, y, z): " + str(gravity.gravity) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return #Gyroscope elif self._data_object.get("sensor") == "Gyroscope": try: gyroscope.enable() except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return previous_payload_hash = None while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": try: gyroscope.disable() except: pass break if None in gyroscope.rotation: pass else: payload_hash = hashlib.md5(str(gyroscope.rotation).encode('utf-8')).hexdigest() if (previous_payload_hash is not None): if (previous_payload_hash == payload_hash): pass else: previous_payload_hash = payload_hash payload = "(x, y, z): " + str(gyroscope.rotation) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(0.1) else: payload = "(x, y, z): " + str(gyroscope.rotation) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return else: pass else: while True: if _data_queue.empty() is False: qdata = _data_queue.get() if qdata == "exit": break payload = "time: " + str(time.strftime("%c", time.gmtime())) terminal.insert_text(payload + "\n") if (self._data_object.get("protocol") != "terminal"): try: terminal.insert_text("xmit status: " + self.xmit_payload(payload) + "\n") except Exception as _exp: terminal.insert_text("Exception: " + str(_exp) + "\n") return time.sleep(2)
def on_stop(self): self.delete_cache() gps.stop() super().on_stop()
def stop_gps(self): gps.stop()
def on_pause(self): gps.stop() return super().on_pause()
def on_gps(self, **kwargs): gps.stop() return Button(text=kwargs)
def posicao(self,**kwargs): #print kwargs self.lon = str(kwargs['lon']) print self.lon gps.stop()
def on_pause(self): gps.stop() #when the app open the camera, it will need to pause this script. So we need to enable the pause mode with this method return True
def gps_stop(self): print("gps_stop") gps.stop()