MCPcopy Index your code
hub / github.com/PokemonGoF/PokemonGo-Bot / login

Method login

pokemongo_bot/__init__.py:994–1116  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

992 #self.api.set_hash_lib(self.get_hash_lib())
993
994 def login(self):
995 status = {}
996 retry = 0
997 quit_login = False
998
999 self.event_manager.emit(
1000 'login_started',
1001 sender=self,
1002 level='info',
1003 formatted="Login procedure started."
1004 )
1005 lat, lng = self.position[0:2]
1006 self.api.set_position(lat, lng, self.alt) # or should the alt kept to zero?
1007
1008 while not quit_login:
1009 try:
1010 self.api.login(
1011 self.config.auth_service,
1012 str(self.config.username),
1013 str(self.config.password))
1014 # No exception, set quit_login = true
1015 quit_login = True
1016 except AuthException as e:
1017 self.event_manager.emit(
1018 'login_failed',
1019 sender=self,
1020 level='info',
1021 formatted='Login process failed: {}'.format(e)
1022 )
1023 # Exception encountered. Retry 3 times, everytime increase wait time 5 secs
1024 retry += 1
1025 sleeptime = retry*5
1026
1027 self.event_manager.emit(
1028 'login_failed',
1029 sender=self,
1030 level='info',
1031 formatted="Retry {} time(s) for {} secs".format(retry,sleeptime)
1032 )
1033 sleep(retry*5)
1034 # Quit after 3rd tries
1035 if retry == 3:
1036 sys.exit()
1037
1038 with self.database as conn:
1039 c = conn.cursor()
1040 c.execute("SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name='login'")
1041
1042 result = c.fetchone()
1043
1044 if result[0] == 1:
1045 conn.execute('''INSERT INTO login (timestamp, message) VALUES (?, ?)''', (time.time(), 'LOGIN_SUCCESS'))
1046 else:
1047 self.event_manager.emit(
1048 'login_failed',
1049 sender=self,
1050 level='info',
1051 formatted="Login table not founded, skipping log"

Callers 6

check_sessionMethod · 0.95
_setup_apiMethod · 0.95
workMethod · 0.45
workMethod · 0.45
start_restMethod · 0.45
endLapsMethod · 0.45

Calls 5

heartbeatMethod · 0.95
sleepFunction · 0.85
emitMethod · 0.80
set_positionMethod · 0.80
readMethod · 0.80

Tested by

no test coverage detected