replace except with except Exception

This commit is contained in:
Hay1tsme 2023-07-16 16:58:34 -04:00
parent 343fe4357c
commit 14a315a673
14 changed files with 33 additions and 30 deletions

View File

@ -63,7 +63,7 @@ class AimedbProtocol(Protocol):
try: try:
decrypted = cipher.decrypt(data) decrypted = cipher.decrypt(data)
except: except Exception:
self.logger.error(f"Failed to decrypt {data.hex()}") self.logger.error(f"Failed to decrypt {data.hex()}")
return None return None

View File

@ -58,7 +58,7 @@ class BaseData:
self.logger.error(f"UnicodeEncodeError error {e}") self.logger.error(f"UnicodeEncodeError error {e}")
return None return None
except: except Exception:
try: try:
res = self.conn.execute(sql, opts) res = self.conn.execute(sql, opts)
@ -70,7 +70,7 @@ class BaseData:
self.logger.error(f"UnicodeEncodeError error {e}") self.logger.error(f"UnicodeEncodeError error {e}")
return None return None
except: except Exception:
self.logger.error(f"Unknown error") self.logger.error(f"Unknown error")
raise raise

View File

@ -130,7 +130,7 @@ class FE_Gate(FE_Base):
if b"e" in request.args: if b"e" in request.args:
try: try:
err = int(request.args[b"e"][0].decode()) err = int(request.args[b"e"][0].decode())
except: except Exception:
err = 0 err = 0
else: else:

View File

@ -68,10 +68,13 @@ class MuchaServlet:
return b"RESULTS=000" return b"RESULTS=000"
# TODO: Decrypt S/N # TODO: Decrypt S/N
b_key = b""
for x in range(8):
b_key += req.sendDate[(x - 1) & 7].encode()
#cipher = Blowfish.new(req.sendDate.encode(), Blowfish.MODE_ECB) cipher = Blowfish.new(b_key, Blowfish.MODE_ECB)
#sn_decrypt = cipher.decrypt(bytes.fromhex(req.serialNum)) sn_decrypt = cipher.decrypt(bytes.fromhex(req.serialNum))
#self.logger.debug(f"Decrypt SN to {sn_decrypt.hex()}") self.logger.debug(f"Decrypt SN to {sn_decrypt.hex()}")
resp = MuchaAuthResponse( resp = MuchaAuthResponse(
f"{self.config.mucha.hostname}{':' + str(self.config.allnet.port) if self.config.server.is_develop else ''}" f"{self.config.mucha.hostname}{':' + str(self.config.allnet.port) if self.config.server.is_develop else ''}"
@ -131,7 +134,7 @@ class MuchaServlet:
return ret return ret
except: except Exception:
self.logger.error(f"Error processing mucha request {data}") self.logger.error(f"Error processing mucha request {data}")
return None return None
@ -143,7 +146,7 @@ class MuchaServlet:
return urlencode.encode() return urlencode.encode()
except: except Exception:
self.logger.error("Error processing mucha response") self.logger.error("Error processing mucha response")
return None return None

View File

@ -644,7 +644,7 @@ class ChuniBase:
upsert["userData"][0]["userName"] = self.read_wtf8( upsert["userData"][0]["userName"] = self.read_wtf8(
upsert["userData"][0]["userName"] upsert["userData"][0]["userName"]
) )
except: except Exception:
pass pass
self.data.profile.put_profile_data( self.data.profile.put_profile_data(

View File

@ -197,7 +197,7 @@ class CxbBase:
v_profile = self.data.profile.get_profile_index(0, uid, self.version) v_profile = self.data.profile.get_profile_index(0, uid, self.version)
v_profile_data = v_profile["data"] v_profile_data = v_profile["data"]
versionindex.append(int(v_profile_data["appVersion"])) versionindex.append(int(v_profile_data["appVersion"]))
except: except Exception:
versionindex.append("10400") versionindex.append("10400")
def handle_action_loadrange_request(self, data: Dict) -> Dict: def handle_action_loadrange_request(self, data: Dict) -> Dict:
@ -286,7 +286,7 @@ class CxbBase:
# REV Omnimix Version Fetcher # REV Omnimix Version Fetcher
gameversion = data["saveindex"]["data"][0][2] gameversion = data["saveindex"]["data"][0][2]
self.logger.warning(f"Game Version is {gameversion}") self.logger.warning(f"Game Version is {gameversion}")
except: except Exception:
pass pass
if "10205" in gameversion: if "10205" in gameversion:
@ -348,7 +348,7 @@ class CxbBase:
# Sunrise # Sunrise
try: try:
profileIndex = save_data["index"].index("0") profileIndex = save_data["index"].index("0")
except: except Exception:
return {"data": ""} # Maybe return {"data": ""} # Maybe
profile = json.loads(save_data["data"][profileIndex]) profile = json.loads(save_data["data"][profileIndex])
@ -496,7 +496,7 @@ class CxbBase:
score=int(rid["sc"][0]), score=int(rid["sc"][0]),
clear=rid["clear"], clear=rid["clear"],
) )
except: except Exception:
self.data.score.put_ranking( self.data.score.put_ranking(
user_id=uid, user_id=uid,
rev_id=int(rid["rid"]), rev_id=int(rid["rid"]),
@ -514,7 +514,7 @@ class CxbBase:
score=int(rid["sc"][0]), score=int(rid["sc"][0]),
clear=0, clear=0,
) )
except: except Exception:
self.data.score.put_ranking( self.data.score.put_ranking(
user_id=uid, user_id=uid,
rev_id=int(rid["rid"]), rev_id=int(rid["rid"]),

View File

@ -123,5 +123,5 @@ class CxbReader(BaseReader):
genre, genre,
int(row["easy"].replace("Easy ", "").replace("N/A", "0")), int(row["easy"].replace("Easy ", "").replace("N/A", "0")),
) )
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")

View File

@ -113,13 +113,13 @@ class Mai2Servlet:
if self.game_cfg.uploads.photos and self.game_cfg.uploads.photos_dir and not path.exists(self.game_cfg.uploads.photos_dir): if self.game_cfg.uploads.photos and self.game_cfg.uploads.photos_dir and not path.exists(self.game_cfg.uploads.photos_dir):
try: try:
mkdir(self.game_cfg.uploads.photos_dir) mkdir(self.game_cfg.uploads.photos_dir)
except: except Exception:
self.logger.error(f"Failed to make photo upload directory at {self.game_cfg.uploads.photos_dir}") self.logger.error(f"Failed to make photo upload directory at {self.game_cfg.uploads.photos_dir}")
if self.game_cfg.uploads.movies and self.game_cfg.uploads.movies_dir and not path.exists(self.game_cfg.uploads.movies_dir): if self.game_cfg.uploads.movies and self.game_cfg.uploads.movies_dir and not path.exists(self.game_cfg.uploads.movies_dir):
try: try:
mkdir(self.game_cfg.uploads.movies_dir) mkdir(self.game_cfg.uploads.movies_dir)
except: except Exception:
self.logger.error(f"Failed to make movie upload directory at {self.game_cfg.uploads.movies_dir}") self.logger.error(f"Failed to make movie upload directory at {self.game_cfg.uploads.movies_dir}")
def render_POST(self, request: Request, version: int, url_path: str) -> bytes: def render_POST(self, request: Request, version: int, url_path: str) -> bytes:

View File

@ -65,7 +65,7 @@ class SaoReader(BaseReader):
) )
except Exception as err: except Exception as err:
print(err) print(err)
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")
self.logger.info("Now reading HeroLog.csv") self.logger.info("Now reading HeroLog.csv")
@ -99,7 +99,7 @@ class SaoReader(BaseReader):
) )
except Exception as err: except Exception as err:
print(err) print(err)
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")
self.logger.info("Now reading Equipment.csv") self.logger.info("Now reading Equipment.csv")
@ -131,7 +131,7 @@ class SaoReader(BaseReader):
) )
except Exception as err: except Exception as err:
print(err) print(err)
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")
self.logger.info("Now reading Item.csv") self.logger.info("Now reading Item.csv")
@ -161,7 +161,7 @@ class SaoReader(BaseReader):
) )
except Exception as err: except Exception as err:
print(err) print(err)
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")
self.logger.info("Now reading SupportLog.csv") self.logger.info("Now reading SupportLog.csv")
@ -193,7 +193,7 @@ class SaoReader(BaseReader):
) )
except Exception as err: except Exception as err:
print(err) print(err)
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")
self.logger.info("Now reading Title.csv") self.logger.info("Now reading Title.csv")
@ -226,7 +226,7 @@ class SaoReader(BaseReader):
print(err) print(err)
elif len(titleId) < 6: # current server code cannot have multiple lengths for the id elif len(titleId) < 6: # current server code cannot have multiple lengths for the id
continue continue
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")
self.logger.info("Now reading RareDropTable.csv") self.logger.info("Now reading RareDropTable.csv")
@ -250,5 +250,5 @@ class SaoReader(BaseReader):
) )
except Exception as err: except Exception as err:
print(err) print(err)
except: except Exception:
self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping")

View File

@ -426,7 +426,7 @@ class WaccaBase:
elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]: elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]:
resp.userItems.noteSounds.append(itm_send) resp.userItems.noteSounds.append(itm_send)
except: except Exception:
self.logger.error( self.logger.error(
f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}" f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}"
) )

View File

@ -221,5 +221,5 @@ class WaccaConstants:
cls.Region.YAMANASHI, cls.Region.YAMANASHI,
cls.Region.WAKAYAMA, cls.Region.WAKAYAMA,
][region] ][region]
except: except Exception:
return None return None

View File

@ -93,7 +93,7 @@ class WaccaServlet:
try: try:
req_json = json.loads(request.content.getvalue()) req_json = json.loads(request.content.getvalue())
version_full = Version(req_json["appVersion"]) version_full = Version(req_json["appVersion"])
except: except Exception:
self.logger.error( self.logger.error(
f"Failed to parse request to {url_path} -> {request.content.getvalue()}" f"Failed to parse request to {url_path} -> {request.content.getvalue()}"
) )

View File

@ -424,7 +424,7 @@ class WaccaLily(WaccaS):
elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]: elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]:
resp.userItems.noteSounds.append(itm_send) resp.userItems.noteSounds.append(itm_send)
except: except Exception:
self.logger.error( self.logger.error(
f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}" f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}"
) )

View File

@ -289,7 +289,7 @@ class WaccaReverse(WaccaLilyR):
elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]: elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]:
resp.userItems.noteSounds.append(itm_send) resp.userItems.noteSounds.append(itm_send)
except: except Exception:
self.logger.error( self.logger.error(
f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}" f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}"
) )