Ejemplo n.º 1
0
def btm_Go(sender):

    v = sender.superview
    sender.alpha = 0.1
    if location.is_authorized():
        location.start_updates()
        loc = location.get_location()
        homeGPS = [loc['longitude'], loc['latitude']]
    else:
        homeGPS = [float(v['txtHomeLon'].text), float(v['txtHomeLat'].text)]
    #print(f'\n\nSearch Child:{v["txtChild"].text} Adult:{v["txtAdult"].text} within {v["txtDistance"].text}km, search nearest {v["txtMaxCount"].text} pharmacies from [{homeGPS[0]}, {homeGPS[1]}]')
    v['txtResult'].text = ''
    v['txtResult'].text += f'\n\nSearch Child:{v["txtChild"].text} Adult:{v["txtAdult"].text} within {v["txtDistance"].text}km, search nearest {v["txtMaxCount"].text} pharmacies from [{round(homeGPS[0],3)}, {round(homeGPS[1],3)}]'
    sleep(1)
    allData = getPharmaciesData()

    hits = filterOut(allData,
                     homeGPS,
                     distance=float(v['txtDistance'].text),
                     mask_child=int(v['txtChild'].text),
                     mask_adult=int(v['txtAdult'].text),
                     maxCount=int(v['txtMaxCount'].text))

    v['txtResult'].text += resultText(hits, allData)
    sleep(1)
    sender.alpha = 1.0
Ejemplo n.º 2
0
def getGPS():
	if location.is_authorized():
		location.start_updates()
		sleep(1)
		loc=location.get_location()
		dialogs.alert(title='Location updated', message=f'[{loc["longitude"]:.3f},{loc["latitude"]:.3f}]\n or enter manually',button1='Got It', hide_cancel_button=True)
		return [loc['longitude'], loc['latitude']]
	else:
		dialogs.alert(title='Cannot get GPS', message='You have to enable it from setting/privacy or enter manually',button1='Got It', hide_cancel_button=True)
		return HOMEGPS
Ejemplo n.º 3
0
def button_startgps(sender):
    location.start_updates()

    if location.is_authorized():
        location.start_updates()
        dialogs.hud_alert('GPS Started', 'success', 1)
    else:
        dialogs.alert(
            'App not authorized to use GPS. Enable GPS in system preferences.',
            'Plz fix',
            'Oh rats... gonna fix that now',
            hide_cancel_button=True)
Ejemplo n.º 4
0
 async def authorized(self, instance, async_lib):
     location.start_updates()
     try:
         while True:
             timestamp = time.time()
             if not location.is_authorized():
                 await self.authorized.write(value=[0], timestamp=timestamp)
             else:
                 info = location.get_location()
                 await self.authorized.write(value=[1], timestamp=timestamp)
                 latitude = info.get('latitude', 0.)
                 longitude = info.get('longitude', 0.)
                 timestamp = info.get('timestamp', timestamp)
                 await self.coordinates.write(value=[latitude, longitude],
                                              timestamp=timestamp)
                 loc = location.reverse_geocode(
                     dict(latitude=latitude, longitude=longitude))
                 await self.location.write(value=[str(loc)],
                                           timestamp=timestamp)
             await async_lib.library.sleep(5.0)
     finally:
         location.stop_updates()
Ejemplo n.º 5
0
def resolveAddress():
    global user_address
    if loc.is_authorized():
        _ad = loc.reverse_geocode(loc.get_location())
        _street = _ad[0]['Street'].split()
        _city = _ad[0]['City']
        _state = _ad[0]['State']
        _zip = _ad[0]['ZIP']

        _streetNo = _street[0]
        if '–' in _streetNo:
            _streetNo = _streetNo.split('–')[0]
        _street[0] = _streetNo

        user_address = (_street[0] + ' ' + _street[1] + ' ' + _street[2] +
                        ' ' + _street[3] + ', ' + _city + ", " + _state + ' ' +
                        _zip)
        #print(user_address)
        return True
    else:
        user_address = currentAddy()
        return True
Ejemplo n.º 6
0
#qr.add_data('some data')
#qr.make(fit=True)

#img2 = qr.make_image()

#img2.show()

dMessage = qrcode.make("I love you, babe!")
dMessage.show()  # display image over console

print('\n')

import location  # iOS location information library

if location.is_authorized():
    location.start_updates(
    )  # start checking for location information, may speed up response to ‘get_location()’
    print(location.get_location())

    address = {
        'Street': 'Victoria Gardens Blvd',
        'City': 'Port Orange',
        'Country': 'USA'
    }
    result = location.geocode(address)

    print("Port Orange: " + str(result))

    print("Reverse geocode: " +
          str(location.reverse_geocode(location.get_location())))
                      (r.status_code, ))
                self.transmit_failure()
            self.last_successful_try = datetime.datetime.now()

    def transmit_failure(self):
        right_now = datetime.datetime.now()
        if (right_now - self.last_successful_try
            ).total_seconds() > self.reset_retry_counter_duration:
            self.retry_count = 0
        else:
            self.retry_count = self.retry_count + 1
            if self.retry_count > self.max_retries:
                raise Exception('retry counter exceeded')


if not location.is_authorized():
    dialogs.alert(
        'Authorize Location Services For Pythonista Application Before Continuing'
    )
    raise Exception('Location Services Not Enabled')

config = get_config_or_defaults()

if config['use_config_file']:
    print("Starting from config file (%s)\n" % (config['config_file_name'], ))
else:
    config = connection_dialog(config)

if not config:
    print("\n\nNo configuration - exiting.\n\n")
    exit(1)
Ejemplo n.º 8
0
HospView = None
_hospView = None
homeV = None
resultsV = None
hospIdx = -1
pages = [homeV, resultsV]
HospTimes, HospNames, HospStates, HospNamesL, HospAddresses, HospNum, HospIDs, HospPhones = (
    [] for i in range(8))

loadedHospitals = {}
hospitalTable = None

backC = ''
page = 0

print('location access: ' + str(loc.is_authorized()))


def cellTapped(sender):
    global page
    global resultsV
    global hospIdx
    global HospView
    global _hospView
    global homeV
    if HospView is not None:
        HospView.wait_modal()
    currView = None
    if hospIdx is -1:
        _hospView = ui.load_view('hospital-details.pyui')
        hospIdx = getIdxOfName(sender.items[0])