Skip to content

Commit

Permalink
[Minor] String Concat & Exception Processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rixxan committed Jul 8, 2022
1 parent a0e5445 commit f37e1e5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
25 changes: 11 additions & 14 deletions halpybot/commands/edsm.py
Expand Up @@ -23,6 +23,7 @@
sys_cleaner,
diversions,
NoResultsEDSM,
NoNearbyEDSM,
)
from ..packages.command import Commands, get_help_text
from ..packages.models import Context
Expand Down Expand Up @@ -173,20 +174,16 @@ async def cmd_landmarklookup(ctx: Context, args: List[str]):
return await ctx.reply(
f"No system and/or commander named {system} was found in the EDSM database."
)
except EDSMLookupError:
if (
str(EDSMLookupError)
== f"No major landmark systems within 10,000 ly of {system}."
):
dssa, distance, direction = await checkdssa(
edsm_sys_name=system, cache_override=cache_override
)
return await ctx.reply(
f"{EDSMLookupError}\nThe closest DSSA Carrier is in {dssa}, {distance} LY "
f"{direction} of {system}."
)
logger.exception("Failed to query EDSM for landmark details.")
return await ctx.reply("Failed to query EDSM for landmark details.")
except NoNearbyEDSM:
dssa, distance, direction = await checkdssa(
edsm_sys_name=system, cache_override=cache_override
)
return await ctx.reply(
f"No major landmark systems within 10,000 LY of {system}.\nThe closest DSSA Carrier is in {dssa}, {distance} LY "
f"{direction} of {system}."
)
logger.exception("Failed to query EDSM for landmark details.")
return await ctx.reply("Failed to query EDSM for landmark details.")


@Commands.command("dssa")
Expand Down
4 changes: 2 additions & 2 deletions halpybot/commands/ping.py
Expand Up @@ -50,7 +50,7 @@ async def cmd_dbping(ctx: Context, args: List[str]):
return await ctx.reply("Unable: No connection.")
if isinstance(latencycheck, float):
final = round(latencycheck - start, 2)
await ctx.reply("Database Latency: " + str(final) + " seconds")
await ctx.reply(f"Database Latency: {str(final)} seconds")
else:
await ctx.reply(latencycheck)

Expand All @@ -72,7 +72,7 @@ async def cmd_edsmping(ctx: Context, args: List[str]):
return await ctx.reply("Failed to query EDSM.")
finish = time.time()
final = round(finish - start, 2)
await ctx.reply("EDSM Latency: " + str(final) + " seconds")
await ctx.reply(f"EDSM Latency: {str(final)} seconds")


@Commands.command("serverstatus")
Expand Down
6 changes: 2 additions & 4 deletions halpybot/commands/time.py
Expand Up @@ -30,9 +30,7 @@ async def cmd_utc(ctx: Context, args: List[str]):
current_monthday = curr_datetime.strftime("%d %B")
year = datetime.now().year
year = str(year + 1286)
await ctx.reply(
"It is currently " + current_utc + " UTC on " + current_monthday + ", " + year
)
await ctx.reply(f"It is currently {current_utc} UTC on {current_monthday}, {year}")


@Commands.command("year")
Expand All @@ -45,4 +43,4 @@ async def cmd_year(ctx: Context, args: List[str]):
"""
year = datetime.now().year
year = str(year + 1286)
await ctx.reply("It is currently the year " + year)
await ctx.reply(f"It is currently the year {year}")
2 changes: 1 addition & 1 deletion halpybot/packages/configmanager/config.py
Expand Up @@ -45,4 +45,4 @@ def config_write(module: str, key: str, value):
with open("config/config.ini", "w", encoding="UTF-8") as conf:
config.write(conf)
except (FileNotFoundError, PermissionError) as ex:
raise ConfigException(str(ex)) from ex
raise ConfigException from ex

0 comments on commit f37e1e5

Please sign in to comment.