Skip to content

Commit

Permalink
Fix #E501s
Browse files Browse the repository at this point in the history
  • Loading branch information
th3-z committed Sep 28, 2019
1 parent 448f387 commit 68280fb
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 43 deletions.
15 changes: 10 additions & 5 deletions admin_patches/checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
# "current_players.html": "48848e49df8169cc6676a564a2895a2e",
# "current_players_row_action.inc": "dcc591344e3b32d1be9c31fa6178e74c",
# "current_players_row.inc": "764a48d8b4432590078b543ff1c24a9d",
# "current_rules_kfgameinfo_survival.inc": "d6aa00c399d931dcf779675dc254248d",
# "current_rules_kfgameinfo_survival.inc":
# "d6aa00c399d931dcf779675dc254248d",
# "current_spectators.inc": "7718da7b0511ee4ccfad4b121ddc48eb",
# "current_team.inc": "3fcd59406c7aa8de84a44a5c1cafc0e4",
# "current_teams.inc": "f5b3aa0467f707b6403c83a90443781c",
# "default_maplist_additional_cycle.inc": "6386dace1fd22a6cbff8e3eac4399c96",
# "default_maplist_additional_edit.inc": "bd99f835e37a019c599145dddbd96de8",
# "default_maplist_additional_cycle.inc":
# "6386dace1fd22a6cbff8e3eac4399c96",
# "default_maplist_additional_edit.inc":
# "bd99f835e37a019c599145dddbd96de8",
# "default_maplist_additional.html": "65054dbba0f9378786e87ecacf7078dc",
# "default_maplist_editor.inc": "5a9639f8b0e8d0d1c69e28c6c5057965",
# "default_maplist_editor.js": "a05e7705d7f91d33fd35d1e096672aaf",
Expand All @@ -51,14 +54,16 @@
# "default_settings_general.html": "396c0a06a827502ad4f9d21f4be6bd61",
# "default_settings_mutators.html": "6e202f2f4c8c4339ee32ae9fed020841",
# "default_settings_mutators.inc": "39a575248d33be12a957d61f18a9e0be",
# "default_settings_mutators_select.inc": "486212f1d398bb956335e78bebdfa5c4",
# "default_settings_mutators_select.inc":
# "486212f1d398bb956335e78bebdfa5c4",
# "default_settings_password.html": "1e402364ec8db2ced6fd4349c2fac3b0",
# "default_settings_welcome.html": "97bc67c1adb95825b0d5f905f0ef0aff",
# "footer_base.inc": "91c52188cc249642954061d1c1619f73",
# "footer.inc": "65f63d4deb9c28ea43adf1bab6d509e0",
# "gamesummary_base.inc": "3319af6efb70753866b2bafce634e258",
# "gamesummary.js": "3723867be22e71f8f655b3ac1815c119",
# "gamesummary_kfgameinfo_survival.inc": "86f11c0d38193fd39ab6b966a8ade24a",
# "gamesummary_kfgameinfo_survival.inc":
# "86f11c0d38193fd39ab6b966a8ade24a",
# "header.inc": "562ac9fa12fb6f1dbfc0352bf99ea76a",
# "login.html": "08bfb87514ab579bd89e470fc50bd245",
# "message_error.inc": "9c3885f94344bf53cf90effa965e255a",
Expand Down
9 changes: 6 additions & 3 deletions admin_patches/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@


includefiles = [
(os.path.join(SRC_PATH, 'patches/current_rules.inc.patch'), 'patches/current_rules.inc.patch'),
(os.path.join(SRC_PATH, 'patches/gamesummary.inc.patch'), 'patches/gamesummary.inc.patch'),
(os.path.join(SRC_PATH, 'patches/header_base.inc.patch'), 'patches/header_base.inc.patch'),
(os.path.join(SRC_PATH, 'patches/current_rules.inc.patch'),
'patches/current_rules.inc.patch'),
(os.path.join(SRC_PATH, 'patches/gamesummary.inc.patch'),
'patches/gamesummary.inc.patch'),
(os.path.join(SRC_PATH, 'patches/header_base.inc.patch'),
'patches/header_base.inc.patch'),
]

target_name = "admin_patches"
Expand Down
5 changes: 3 additions & 2 deletions magicked_admin/chatbot/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def __init__(self, server, admin_only=True, requires_patch=False):

not_supported_message = "This action isn't supported without Killing" \
" Floor 2 Magicked Administrator's server" \
" side patch! Please review the documentation" \
" at '{}' for guidance.".format(BANNER_URL)
" side patch! Please review the " \
"documentation at '{}' for guidance."\
.format(BANNER_URL)
self.not_supported_message = pad_output(not_supported_message)

self.help_text = "The help text for this command hasn't been written!"
Expand Down
4 changes: 2 additions & 2 deletions magicked_admin/chatbot/commands/server_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ def execute(self, username, args, user_flags):
return self.format_response(self.help_text, args)

if not args.difficulty:
message = "Difficulty not recognised, options are: normal, hard, " \
"suicidal, or hell"
message = "Difficulty not recognised, options are: normal, " \
"hard, suicidal, or hell"
return self.format_response(message, args)

if args.difficulty in ["normal", "0"]:
Expand Down
3 changes: 2 additions & 1 deletion magicked_admin/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def rank_kd(self, steam_id):
FROM
players as player2
WHERE
(player2.kills/player2.deaths) >= (player1.kills/player1.deaths)
(player2.kills/player2.deaths)
>= (player1.kills/player1.deaths)
) AS kd_rank
FROM
players AS player1
Expand Down
8 changes: 5 additions & 3 deletions magicked_admin/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ def event_player_join(self, player):
message = "Player {} joined {} from {}" \
.format(new_player.username, self.name, new_player.country)
print(colored(message, 'cyan'))
self.web_admin.chat.handle_message("internal_command",
"!player_join " + new_player.username,
USER_TYPE_INTERNAL)
self.web_admin.chat.handle_message(
"internal_command",
"!player_join " + new_player.username,
USER_TYPE_INTERNAL
)

def event_player_quit(self, player):
self.players.remove(player)
Expand Down
28 changes: 13 additions & 15 deletions magicked_admin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
'scoreboard_type', 'dosh_threshold',
'max_players', 'enable_greeter']

CONFIG_DIE_MESG = "Please correct this manually or delete '{}' to create a clean config next run.".format(
CONFIG_PATH)
CONFIG_DIE_MESG = "Please correct this manually or delete '{}' to create " \
"a clean config next run.".format(CONFIG_PATH)


class Settings:
Expand All @@ -43,21 +43,18 @@ def __init__(self, skip_setup=False):
config.write(config_file)

if skip_setup:
info("Guided setup was skipped, a template has been generated.")
die(
"Setup is not complete yet, please amend '{}' with your "
"server details.".format(CONFIG_PATH_DISPLAY)
)
info("Guided setup was skipped, a template has been "
"generated.")
die("Setup is not complete yet, please amend '{}' with your "
"server details.".format(CONFIG_PATH_DISPLAY))

try:
self.config = configparser.ConfigParser()
self.config.read(CONFIG_PATH)

except configparser.DuplicateOptionError as e:
fatal(
"Configuration error(s) found!\nSection '{}' has a duplicate setting: '{}'."
.format(e.section, e.option)
)
fatal("Configuration error(s) found!\nSection '{}' has a duplicate"
" setting: '{}'.".format(e.section, e.option))
die(CONFIG_DIE_MESG, pause=True)

config_errors = self.validate_config(self.config)
Expand Down Expand Up @@ -94,8 +91,8 @@ def construct_config_interactive():
if resolved_address:
break
else:
print(
"Address not responding!\nAccepted formats are: 'ip:port', 'domain', or 'domain:port'")
print("Address not responding!\nAccepted formats are: "
"'ip:port', 'domain', or 'domain:port'")

username = input("Username [default - Admin]: ") or "Admin"
password = getpass(
Expand Down Expand Up @@ -142,7 +139,8 @@ def validate_config(config):
config.get(section, setting)
except configparser.NoOptionError:
errors.append(
"Section '{}' is missing a required setting: '{}'.".format(
section, setting))
"Section '{}' is missing a required setting: "
"'{}'.".format(section, setting)
)

return errors
28 changes: 19 additions & 9 deletions magicked_admin/web_admin/web_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def get_game_players(self):
@staticmethod
def __get_players(info_tree):
players = []
theads_path = "//table[@id=\"players\"]/thead//th[position()>1]//text()"
theads_path = "//table[@id=\"players\"]/thead//th[position()>1]" \
"//text()"
theads_result = info_tree.xpath(theads_path)

if len(theads_result):
Expand Down Expand Up @@ -261,23 +262,27 @@ def __get_game(info_tree):
zeds_dead, zeds_total = None, None
trader_open = False

players_path = "//dl[@id=\"currentRules\"]/dt[text()=\"Players\"]/following-sibling::dd[1]/text()"
players_path = "//dl[@id=\"currentRules\"]/dt[text()=\"Players\"]" \
"/following-sibling::dd[1]/text()"
players_result = info_tree.xpath(players_path)

if len(players_result):
players, players_max = map(int, players_result[0].split("/"))
else:
players_max = None

wave_path = "//dl[@id=\"currentRules\"]/dt[text()=\"Wave\"]/following-sibling::dd[1]/text()"
wave_path = "//dl[@id=\"currentRules\"]/dt[text()=\"Wave\"]" \
"/following-sibling::dd[1]/text()"
wave_result = info_tree.xpath(wave_path)

if len(wave_result):
wave, length = map(int, wave_result[0].split("/"))
else:
wave, length = None, LEN_UNKNOWN

difficulty_path = "//dl[@id=\"currentRules\"]/dt[text()=\"Difficulty\"]/following-sibling::dd[1]/text()"
difficulty_path = "//dl[@id=\"currentRules\"]" \
"/dt[text()=\"Difficulty\"]" \
"/following-sibling::dd[1]/text()"
difficulty_result = info_tree.xpath(difficulty_path)

if len(difficulty_result):
Expand All @@ -295,17 +300,20 @@ def __get_game(info_tree):
else:
difficulty = DIFF_UNKNOWN

game_type_path = "//dl[@id=\"currentGame\"]/dt[text()=\"Game type\"]/following-sibling::dd[1]/@title"
game_type_path = "//dl[@id=\"currentGame\"]/dt[text()=\"Game type\"]" \
"/following-sibling::dd[1]/@title"
game_type_result = info_tree.xpath(game_type_path)

if len(game_type_result):
game_type = game_type_result[0]
else:
game_type = GAME_TYPE_UNKNOWN

map_title_path = "//dl[@id=\"currentGame\"]/dt[text()=\"Map\"]/following-sibling::dd[1]/@title"
map_title_path = "//dl[@id=\"currentGame\"]/dt[text()=\"Map\"]" \
"/following-sibling::dd[1]/@title"
map_title_result = info_tree.xpath(map_title_path)
map_name_path = "//dl[@id=\"currentGame\"]/dt[text()=\"Map\"]/following-sibling::dd[1]/text()"
map_name_path = "//dl[@id=\"currentGame\"]/dt[text()=\"Map\"]" \
"/following-sibling::dd[1]/text()"
map_name_result = info_tree.xpath(map_name_path)

if len(map_title_result) and len(map_name_result):
Expand All @@ -321,7 +329,8 @@ def get_player_identity(self, username):
response = self.__web_interface.get_players()
player_tree = html.fromstring(response.content)

theads_path = "//table[@id=\"players\"]/thead//th[position()>1]//text()"
theads_path = "//table[@id=\"players\"]/thead//th[position()>1]" \
"//text()"
theads_result = player_tree.xpath(theads_path)

name_col = theads_result.index("Player name")
Expand All @@ -337,7 +346,8 @@ def get_player_identity(self, username):
trows_result = [list(group) for k, group in
groupby(trows_result, lambda x: x == "\xa0") if not k]

player_keys_path = "//table[@id=\"players\"]/tbody//input[@name=\"playerkey\"]//@value"
player_keys_path = "//table[@id=\"players\"]/tbody" \
"//input[@name=\"playerkey\"]//@value"
player_keys_result = player_tree.xpath(player_keys_path)
for i in range(0, len(player_keys_result)):
trows_result[i][player_key_col] = player_keys_result[i]
Expand Down
6 changes: 4 additions & 2 deletions magicked_admin/web_admin/web_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ def __new_session(self):
response = self.__post(session, self.__urls['login'], login_payload,
login=True)

if "hashAlg" in response.text or "Exceeded login attempts" in response.text:
if "hashAlg" in response.text \
or "Exceeded login attempts" in response.text:
# TODO Expand on handling here, should gracefully terminate
die("Login failure, bad credentials or login attempts exceeded.", pause=True)
die("Login failure, bad credentials or login attempts exceeded.",
pause=True)

if "<!-- KF2-MA-INSTALLED-FLAG -->" in response.text:
self.ma_installed = True
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pytest:

lint:
@echo "$(YELLOW_COLOR)Checking lints...$(NO_COLOR)\n"
@flake8 --ignore F405,E501,F403,E722,W503,F401 --exclude=admin_patches/utils/patch.py && \
@flake8 --ignore F405,F403,E722,W503,F401 --exclude=admin_patches/utils/patch.py && \
echo "$(GREEN_COLOR)success!$(NO_COLOR)" \
|| { echo "$(RED_COLOR)failure!$(NO_COLOR)\n"; exit 1; }

Expand Down

0 comments on commit 68280fb

Please sign in to comment.