Esempio n. 1
0
 def current_location(self):
     try:
         gps.configure(on_location=self.on_location)
         gps.start()
     except NotImplementedError:
         ErrorPopup().error_occured('GPS Error',
                                  'GPS support is not implemented on your platform')
Esempio n. 2
0
 def start_updating(self, blinker):
     self.blinker = blinker
     if platform == 'android':
         from plyer import gps
         gps.configure(on_location=self.update_gps_position,
                       on_status=self.on_auth_status)
         gps.start(minTime=1000, minDistance=0)
Esempio n. 3
0
 def on_connect(self, nxt):
     self.motor_a = Motor(nxt, PORT_A)
     self.motor_b = Motor(nxt, PORT_B)
     self.color_sensor = Light(nxt, PORT_1, True)
     self.push_sensor = Touch(nxt, PORT_2)
     gps.start(10e3, 0)
     print("Waiting for GPS")
Esempio n. 4
0
    def __init__(self, address="", radius=10, in_days=2):
        super().__init__()
        self.address = address
        self.crime_radius = radius
        self.crime_days_filter = in_days
        self.crime_count = 0

        self.crime_api = GetCrime()

        # GPS functionality if applicable - mobile only (should support both iPhone and android)
        print("TEST TEST TEST")
        try:
            gps.configure(
                on_location=self._update_loc
            )  # Configs gps object to use update_loc function as a callback
            gps.start(minTime=10000, minDistance=1)  # Poll every 10 seconds
            self.use_gps = True
        except:
            self.use_gps = False
            print("No GPS configured, disabling GPS queries")

        # Get latitude and longitude of passed-in address
        self.my_loc = get_lat_lng(self.address)
        if self.my_loc == None:
            self.my_loc = {}
            if not self.use_gps:
                # If no GPS, default location to CSUF
                self.my_loc["lat"] = CSUF_LAT
                self.my_loc["lng"] = CSUF_LNG
                print("Not using GPS, default location set to " +
                      str(self.my_loc))
Esempio n. 5
0
    def start(self):
        Clock.schedule_interval(self.update,2)
        try:
            gps.start(1000,0)

        except:
            print("failed")
Esempio n. 6
0
    def run(self):

        #get a reference to GpsBlinker,then call blink()
        gps_blinker=App.get_running_app().root.ids.mapview.ids.blinker
        #start blinking the GpsBlinker
        gps_blinker.blink()
        pass

        #Request permission on Android
        if platform == "android":
            from android.permissions import Permission,request_permissions
            def callback(permission,results):
                if all([res for res in results]):
                    print("Got all permissions")
                    from plyer import gps
                    gps.configure(on_location=self.update_blinker_position,
                                  on_status=self.on_auth_status)
                    gps.start(minTime=1000,minDistance=0)

                else:
                    print("Did not get all permissions")

            #we put these two parameter inside of buildozer.spec file
            request_permissions([Permission.ACCESS_COARSE_LOCATION,
                                  Permission.ACCESS_FINE_LOCATION],callback)


        #configure GPS
        if platform == "ios":
            from plyer import gps
            gps.configure(on_location=self.update_blinker_position,
                          on_status=self.on_auth_status)
            gps.start(minTime=1000,minDistance=0)
Esempio n. 7
0
    def run(self):
        # Get a reference to GpsBlinker, then call blink()
        gps_blinker = App.get_running_app().root.ids.mapview.ids.blinker
        # Start blinking the GpsBlinker
        gps_blinker.blink()

        # Request permissions on Android
        if platform == 'android':
            from android.permissions import Permission, request_permissions

            def callback(permission, results):
                if all([res for res in results]):
                    print("Got all permissions")
                else:
                    print("Did not get all permissions")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        # Configure GPS
        if platform == 'android' or platform == 'ios':
            from plyer import gps
            gps.configure(on_location=self.update_blinker_position,
                          on_status=self.on_auth_status)
            gps.start(minTime=1000, minDistance=0)
Esempio n. 8
0
 def gps_start(self, mt, md):
     print("gps_start")
     if self.gpsD.androidServiceStatus:
         print("skipp ! it's running allrady")
     else:
         self.gpsD.androidServiceStatus = True
         gps.start(mt,md)
Esempio n. 9
0
 def start(self, minTime, minDistance):
     if platform == 'android' and self.permit:
         self.turn_on_gps('start')
         gps.start(minTime, minDistance)
         self.show_banner()
     elif platform == 'android' and not self.permit:
         self.request_android_permissions()
Esempio n. 10
0
    def run(self):

        #Blinking on map
        #Get a reference to GpsBlinker, then call blink
        gps_blinker = App.get_running_app().root.ids.mapview.ids.blinker
        gps_blinker.blink()
        #запросить разрешение на получение местоположения
        if platform == 'android':
            from android.permissions import Permission, request_permissions

            def callback(permission, results):
                if all([res for res in results]):
                    print("Получены все разрешения")
                else:
                    print("Получены не все разрешения")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        #конфигурация gps
        if platform == 'android' or platform == 'ios':
            from plyer import gps
            gps.configure(on_location=self.update_blinker_position,
                          on_status=self.on_auth_status)
            gps.start(minTime=1000, minDistance=0)
Esempio n. 11
0
    def run(self):
        """This function is called when the class is called, GpsHandler.run()"""
        # Request permissions on Android
        if platform == 'android':
            from android.permissions import Permission, request_permissions

            def callback(permission, results):
                """Check for any errors, with permissions"""
                if all([res for res in results]):
                    print("Got all permissions")
                else:
                    print("Did not get all permissions")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        # Configure GPS
        if platform == 'android' or platform == 'ios':
            self.androidBool = True
            from plyer import gps
            gps.configure(on_location=self.updateGpsLatLon,
                          on_status=self.onAuthStatus)
            gps.start(minTime=1000, minDistance=0)

        else:
            self.androidBool = False
Esempio n. 12
0
 def start(self, minTime, minDistance):
     self.available_providers = gps.get_available_providers()
     excluded_providers = [
         button.text for button in self.root.provider_buttons
         if button.state == 'normal'
     ]
     gps.start(minTime, minDistance, excluded_providers)
     self.gps_running = True
Esempio n. 13
0
 def callback(permission, results):
     if all([res for res in results]):
         print("Got all permissions")
         from plyer import gps
         gps.configure(on_location=self.update_blinker_position, on_status=self.on_auth_status)
         gps.start(minTime=1000, minDistance=1)
     else:
         print("Did not get all permissions")
Esempio n. 14
0
 def callback(permissions, results):
     if all([res for res in results]):
         print("callback. All permissions granted.")
         gps.configure(on_location=self.on_location,
                       on_status=self.on_auth_status)
         gps.start(10, 0)
     else:
         print("callback. Some permissions refused.")
Esempio n. 15
0
    def current_location(self):
        try:
            gps.configure(on_location=self.on_location)
            gps.start()

        except NotImplementedError:
            self.errorPopup("GPS support is not implemented on your device")
            Clock.schedule_once(lambda d: self.error_pop.dismiss(), 3)
Esempio n. 16
0
 def start_gps_localize(self):
     mapview_screen = self.mapview_screen_property
     mapview_screen.update_status_message("Waiting for GPS location...", 10)
     try:
         gps.configure(
             on_location=self.on_location, on_status=self.on_status)
         gps.start()
     except NotImplementedError:
         self.gps_not_found_message()
Esempio n. 17
0
 def current_location(self):
     try:
         gps.configure(on_location=self.on_location)
         gps.start()
     except NotImplementedError:
         popup = Popup(title="GPS Error",
             content=Label(text="GPS support is not implemented on your platform")
             ).open()
         Clock.schedule_once(lambda d: popup.dismiss(), 3)
Esempio n. 18
0
 def start_gps_localize(self):
     mapview_screen = self.mapview_screen_property
     mapview_screen.update_status_message("Waiting for GPS location...", 10)
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
         gps.start()
     except NotImplementedError:
         self.gps_not_found_message()
Esempio n. 19
0
 def locate_with_gps(self, perm_names, perms):
     '''Select a location with gps'''
     if perms[0]:
         gps.start(1000, 1)
         self.timeout_event = Clock.schedule_once(
             lambda _: self.gps_timeout(), 60)
         self.loading_popup.open()
     else:
         notify(title="Location Permission",
                message="Permission is needed to get location")
Esempio n. 20
0
    def on_enter(self) -> None:
        if platform == "android":
            request_android_permissions()

        try:
            gps.configure(on_location=self.on_location)
        except NotImplementedError:
            return

        gps.start(5000, 0)
Esempio n. 21
0
 def alarm(instance):
     if instance.count == 5:
         gps.start()
         final_sound = SoundLoader.load(os.path.join("Audio", "contacting_help.mp3"))
         if final_sound:
             final_sound.play()
     elif instance.count % 5 == 0:
         alarm_sound = SoundLoader.load(os.path.join("Audio", "alarm.mp3"))
         if alarm_sound:
             alarm_sound.play()
Esempio n. 22
0
 def start(self):
     super().start()
     if gps_is_implemented:
         gps.start(
             minTime=self._interval_s * 1000,  # In milliseconds (float)
             minDistance=1,
         )  # In meters (float)
     else:
         # Simulate a single push of GPS data
         self._on_location(altitude=2.2)
         self._on_status("some_message_type", "some_status_value")
Esempio n. 23
0
 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)
Esempio n. 24
0
 def alarm(self):
     if self.count == 5:
         gps.start()
         final_sound = SoundLoader.load(
             os.path.join("Audio", "contacting_help.wav"))
         if final_sound:
             final_sound.play()
     elif self.count % 5 == 0:
         alarm_sound = SoundLoader.load(os.path.join("Audio", "alarm.wav"))
         if alarm_sound:
             alarm_sound.play()
Esempio n. 25
0
    def start_service(self, foo=None):

        try:
            self.service.stop()
            self.service = None
        except:
            logging.exception("Likely no need to stop nonexistent service")

        try:
            self.getPermission('location')
            from plyer import gps
            gps.configure(on_location=self.on_location)

            gps.start()
        except:
            logging.exception("Could not start location service")

        if platform == 'android':
            from android import AndroidService
            logging.info("About to start Android service")
            service = AndroidService('HardlineP2P Service', 'running')
            service.start('service started')
            self.service = service
            # On android the service that will actually be handling these databases is in the background in a totally separate
            # process.  So we open an SECOND drayer database object for each, with the same physical storage, using the first as the server.
            # just for use in the foreground app.

            # Because of this, two connections to the same DB file is a completetely supported use case that drayerDB has optimizations for.
            daemonconfig.loadUserDatabases(
                None,
                forceProxy='localhost:7004',
                callbackFunction=self.onDrayerRecordChange)
        else:

            def f():
                # Ensure stopped
                hardline.stop()

                loadedServices = daemonconfig.loadUserServices(None)

                daemonconfig.loadDrayerServerConfig()
                self.currentPageNewRecordHandler = None
                db = daemonconfig.loadUserDatabases(
                    None, callbackFunction=self.onDrayerRecordChange)
                hardline.start(7009)
                # Unload them at exit because we will be loading them again on restart
                for i in loadedServices:
                    loadedServices[i].close()

            t = threading.Thread(target=f, daemon=True)
            t.start()
Esempio n. 26
0
 def get_location(self):
     self.clear_map_from_markers()
     gps.start()
     time.sleep(3)
     if self.lat and self.lon:
         marker = MapMarker(source=os.path.join(ASSETS_FOLDER, 'map_marker64x64.png'), lat=self.lat, lon=self.lon)
         self.map.add_marker(marker)
         time.sleep(0.5)
         self.map.center_on(self.lat, self.lon)
         time.sleep(0.25)
         if self.map.zoom < 10:
             self.map.zoom = 10
     else:
         Snackbar(text='Something went wrong, try again...').show()
Esempio n. 27
0
 def __init__(self, **kwargs):
     super(tela2, self).__init__(**kwargs)
     self.orientation = "vertical"
     gps.configure(on_location=self.on_location)
     gps.start()
     self.map = MapView(zoom=90, lat=self.lat, lon=self.lon)
     MapMarker(lon=self.lon,
               lat=self.lat,
               source="pessoa.png",
               on_press=self.on_press)
     self.add_widget(self.map)
     self.map.add_widget(self.layer)
     self.bind(lon=partial(self.tracking))
     time.sleep(1)
Esempio n. 28
0
    def ComienzaGPS(self, *args):
        global datosRelativos
        #  datosRelativos=0
        try:

            gps.configure(on_location=self.DatosGPS)
            if True:
                gps.start()
                datosRelativos = self.bufergps()
                return datosRelativos
        except:
            datosRelativos = 0
            print datosRelativos
            pass
        return datosRelativos
Esempio n. 29
0
 def __init__(self, **kwargs):
     super(SWMApp, self).__init__(**kwargs)
     self.center = map_center
     self.get_config()
     try:
         gps.configure(on_location=self.on_location,
                       on_status=self.on_status)
         gps.start(1000, 0)
         self.gps = self.center
     except NotImplementedError:
         import traceback
         traceback.print_exc()
         self.gps_status = 'GPS is not implemented for your platform'
         self.gps = None
     Clock.schedule_once(self.post, 0)
Esempio n. 30
0
            def permissions(permission, results):
                if all([res for res in results]):
                    gps.configure(on_location=self.update_pos_android,
                                  on_status=self.permission_status)
                    gps.start(minTime=2000, minDistance=0)
                else:
                    popup = PopupPersonalizado(
                        "Se necesitan permisos de localizacion para disfrutar de los servicios de esta aplicación"
                    )

                    popupWindow = Popup(title="Error permisos de localizacion",
                                        content=popup,
                                        size_hint=(None, None),
                                        size=(400, 400))

                    popupWindow.open()
Esempio n. 31
0
    def current_location2(self):
        try:
            gps.configure(on_location=self.posicao)

            gps.start()
            #gps.stop()
            #requests.post(DATA_URI, data={'location': self.on_location})
            #popup = Popup(title="sei lah",content=Label(text='teste')).open()
            #Clock.schedule_once(lambda d: popup.dismiss(), 3)
            #print str(self.on_location)
            #self.envia_posicao(self.on_location)
            
        except NotImplementedError:
            popup = Popup(title="GPS Error",
                          content=Label(text="GPS support is not active on your platform")
                          ).open()
            Clock.schedule_once(lambda d: popup.dismiss(), 3)
Esempio n. 32
0
    def __init__(self, **kwargs):
        user_data_dir = PortalApp.get_running_app().user_data_dir
        self.gps_image = join(user_data_dir, gps_image)
        print self.gps_image
        super(SWMApp, self).__init__(**kwargs)
        self.center = map_center
        self.get_config()

        try:
            gps.configure(on_location=self.on_location,
                          on_status=self.on_status)
            gps.start(1000, 0)
            self.gps = self.center
        except NotImplementedError:
            import traceback
            traceback.print_exc()
            self.gps_status = 'GPS is not implemented for your platform'
            self.gps = None

        Clock.schedule_once(self.post, 0)
Esempio n. 33
0
    def run(self):
        #ask permission; android only
        if platform == 'android':
            from android.permissions import request_permissions, Permission

            def callback(permissions, results):
                if all([res for res in results]):
                    print("Got all permissions")
                else:
                    print("Did not get all permissions")

            request_permissions([
                Permission.ACCESS_COARSE_LOCATION,
                Permission.ACCESS_FINE_LOCATION
            ], callback)

        #configure gps
        if platform == 'android' or platform == 'ios':
            from plyer import gps
            gps.configure(on_location=self.update_location
                          )  #, on_status=self.on_auth_status)
            gps.start(minTime=1000, minDistance=0)
Esempio n. 34
0
__version__ = "0.1"
Esempio n. 35
0
 def enable(self):
     '''
     '''
     gps.start()
Esempio n. 36
0
def start():
    out = 'Dummy'  
    if use_gps:       
        out = gps.start(1000, 0)
        gps_on = True
    return out    
Esempio n. 37
0
 def on_resume(self):
     gps.start(1000, 0)
     pass
Esempio n. 38
0
 def start(self, minTime, minDistance):
     gps.start(minTime, minDistance)
Esempio n. 39
0
 def start_gps(self, dt):
     try:
         gps.start()
     except:
         pass
Esempio n. 40
0
def start_tracking():
    gps.start()