def _setupApis(self): """Sets up all the APIs and the loading bar.""" loc = GeoLocate(self.path + "/rc/GeoLiteCity.dat", self.preferences.configs.value('gnames', None)) zoom = self.webView.getZoomLevel() object_count = 0 for api in self.apis: object_count += len(api.locations) pg = ProgressBar([x.api_name for x in self.apis], object_count, self.path) self.increment.connect(pg.increment) self.updateApi.connect(pg.updateApi) pg.run() for api in self.apis: self.updateApi.emit() for entry in api.locations: location = loc.coordsFromAddr(api.locations[entry][0], entry) no, index = loc.lookForDup(self.locations, location, self.treshold.setdefault(zoom, 300)) if no: self.webView.addMarker(location) self.locations.append(location) else: self.locations[index].append(location) if pg.canceled: self.webView.warning("Loading the data was " + "interrupted. All data prior " + "to cancellation was plotted.") return else: self.increment.emit() QtWidgets.QApplication.processEvents() self.webView.success("All data points added.")
def locateUser(self, country=None, city=None): """ Locates the user via the GeoLocate class. Keyword arguments: country -- the country name as a string (default None) city -- the city name as a string (default None) """ loc = GeoLocate(self.path + "/rc/GeoLiteCity.dat", self.preferences.configs.value("gnames", None)) if country and city: check = loc.ownCoordsFromAddr(country, city) if not check: self.error("Could not locate provided address.") return else: loc.getOwnAddress() self.location = [loc.country, loc.city, loc.lat, loc.lon] self.addLocationMark()