Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Henjuro committed Nov 23, 2020
1 parent 9e05fcb commit 85c6693
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 38 deletions.
3 changes: 2 additions & 1 deletion waitlist/sso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def repeated_verify(security: EsiSecurity, count: int=0,
security.signal_token_updated.send(
token_identifier=security.token_identifier,
**resp)
if e.status_code == 420:
if (e.status_code == 420 or
'SSO response does not contain a character ID' in e.response.decode('utf-8')):
raise e

if count >= max_count:
Expand Down
61 changes: 25 additions & 36 deletions waitlist/ts3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,25 @@ def func_wrapper(*argsw, **kwargsw):
except TS3QueryError as error:
logger.error("TS3 Query Error: %s", str(error))
except Exception:
ncon = TS3Connector.__make_connection()
if ncon is None:
sleep(2)
ncon = TS3Connector.__make_connection()
if ncon is not None:
argsw[0].conn = ncon
ncon = TS3Connector._make_connection()
if ncon is None:
sleep(2)
ncon = TS3Connector._make_connection()
if ncon is not None:
argsw[0].conn = ncon
else:
argsw[0].conn = ncon
func(*argsw, **kwargs)
else:
argsw[0].conn = TS3Connector.__make_connection()
func(*argsw, **kwargs)
else:
argsw[0].conn = TS3Connector._make_connection()
func(*argsw, **kwargs)

return func_wrapper

def __init__(self):
super().__init__()
self.access_lock = Lock()
self.conn = TS3Connector.__make_connection()
self.conn = TS3Connector._make_connection()
self.timer_lock = Lock()
self.timer = Timer(300, self.__do_keep_alive)
self.timer.start()
Expand All @@ -74,7 +75,7 @@ def __get_datum() -> Optional[TeamspeakDatum]:
return db.session.query(TeamspeakDatum).get(teamspeak_id)

@staticmethod
def __make_connection():
def _make_connection():
if config.disable_teamspeak:
return None

Expand Down Expand Up @@ -115,7 +116,7 @@ def change_connection(self):
return
if self.conn is not None:
self.conn.close()
self.conn = TS3Connector.make_connection()
self.conn = TS3Connector._make_connection()
with self.timer_lock:
self.timer = Timer(300, self.__do_keep_alive)
self.timer.start()
Expand All @@ -130,22 +131,18 @@ def send_notification(self, name: str, msg: str) -> None:
response = self.conn.exec_('clientfind', pattern=name)
except TS3QueryError as er:
logger.info("TS3 ClientFind failed on %s with %s", name, str(er))
response = []
found = False
return

for resp in response:
if resp['client_nickname'] == name:
self.conn.exec_('clientpoke', clid=resp['clid'], msg=msg)
found = True
# deaf people put a * in front
if not found:
try:
response = self.conn.clientfind(pattern="*"+name)
except TS3QueryError as er:
logger.info("TS3 ClientFind failed on %s with %s", "*"+name, str(er))
return
break
else:
# deaf people put a * in front
for resp in response:
if resp['client_nickname'] == "*"+name:
self.conn.exec_('clientpoke', msg=msg, clid=resp['clid'])
break


@Decorators.handle_dc
Expand All @@ -164,26 +161,18 @@ def move_to_safety(self, names: List[str]) -> None:
response = self.conn.exec_('clientfind', pattern=name)
except TS3QueryError as er:
logger.info("TS3 ClientFind failed on %s with %s", name, str(er))
response = []
client = None
continue

for resp in response:
if resp['client_nickname'] == name:
client = resp
self.conn.exec_('clientmove', clid=client['clid'], cid=ts_datum.safetyChannelID)
break

if client is None:
try:
response = self.conn.exec_('clientfind', pattern="*"+name)
except TS3QueryError as er:
logger.info("TS3 ClientFind failed on %s with %s", "*"+name, str(er))
return
else:
for resp in response:
if resp['client_nickname'] == "*"+name:
client = resp
self.conn.exec_('clientmove', clid=client['clid'], cid=ts_datum.safetyChannelID)
break
if client is None: # we didn't find a user
return
self.conn.exec_('clientmove', clid=client['clid'], cid=ts_datum.safetyChannelID)


def register_user(self, name: str, password: str, acc_id: int) -> str:
return name
Expand Down
2 changes: 1 addition & 1 deletion waitlist/utility/swagger/eve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_monolith_error(self):
if ', details: {' in self.__error:
monolith_error = {}
monolith_error['error_label'] = self.__error.split(',', 1)[0]
monolith_error['error_dict'] = ast.literal_eval(self.__error[self._error.index(', details: {')+12:])
monolith_error['error_dict'] = ast.literal_eval(self.__error[self.__error.index(', details: {')+12:])
return monolith_error
'''
If none of these work, return this fallback
Expand Down

0 comments on commit 85c6693

Please # to comment.