def api_init(account): api = PGoApi() try: api.set_position(360,360,0) api.set_authentication(provider = account.auth_service, username = account.username, password = account.password) api.activate_signature(get_encryption_lib_path()); time.sleep(1); api.get_player() except AuthException: log.error('Login for %s:%s failed - wrong credentials?' % (account.username, account.password)) return None else: time.sleep(1); response = api.get_inventory() if response: if 'status_code' in response: if response['status_code'] == 1 or response['status_code'] == 2: return api elif response['status_code'] == 3: # try to accept ToS time.sleep(5); response = api.mark_tutorial_complete(tutorials_completed = 0, send_marketing_emails = False, send_push_notifications = False) if response['status_code'] == 1 or response['status_code'] == 2: print('Accepted TOS for %s' % account.username) return api elif response['status_code'] == 3: print('Account %s BANNED!' % account.username) raise AccountBannedException return None
def set_position(self, lat, lng, alt=None): self.actual_lat = lat self.actual_lng = lng if None != alt: self.actual_alt = alt else: alt = self.actual_alt if self.config.replicate_gps_xy_noise: lat_noise = gps_noise_rng(self.config.gps_xy_noise_range) lng_noise = gps_noise_rng(self.config.gps_xy_noise_range) lat = lat + lat_noise lng = lng + lng_noise if self.config.replicate_gps_z_noise: alt_noise = gps_noise_rng(self.config.gps_z_noise_range) alt = alt + alt_noise self.noised_lat, self.noised_lng, self.noised_alt = lat, lng, alt PGoApi.set_position(self, lat, lng, alt)