Skip to content

Commit

Permalink
Fix Pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb committed Sep 25, 2024
1 parent dc40667 commit 91673dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
11 changes: 6 additions & 5 deletions src/saltext/apache/modules/apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ def _detect_os():
os_family = __grains__["os_family"]
if os_family == "RedHat":
return "apachectl"
elif os_family == "Debian" or os_family == "Suse":
if os_family in ("Debian", "Suse"):
return "apache2ctl"
else:
return "apachectl"
return "apachectl"


def version():
Expand Down Expand Up @@ -204,6 +203,7 @@ def vhosts():
return ret


# pylint: disable=redefined-outer-name
def signal(signal=None):
"""
Signals httpd to start, restart, or stop.
Expand All @@ -218,7 +218,7 @@ def signal(signal=None):
valid_signals = ("start", "stop", "restart", "graceful", "graceful-stop")

if signal not in valid_signals and signal not in no_extra_args:
return
return None
# Make sure you use the right arguments
if signal in valid_signals:
arguments = f" -k {signal}"
Expand Down Expand Up @@ -344,7 +344,8 @@ def server_status(profile="default"):
# get http data
url += "?auto"
try:
response = urllib.request.urlopen(url, timeout=timeout).read().splitlines()
with urllib.request.urlopen(url, timeout=timeout) as http_response:
response = http_response.read().splitlines()
except urllib.error.URLError:
return "error"

Expand Down
10 changes: 4 additions & 6 deletions src/saltext/apache/modules/deb_apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ def _detect_os():
# TODO: Add pillar support for the apachectl location
if __grains__["os_family"] == "RedHat":
return "apachectl"
elif __grains__["os_family"] == "Debian":
if __grains__["os_family"] == "Debian":
return "apache2ctl"
else:
return "apachectl"
return "apachectl"


def check_site_enabled(site):
Expand All @@ -62,10 +61,9 @@ def check_site_enabled(site):
site_file = f"{site}.conf"
if os.path.islink(f"{SITE_ENABLED_DIR}/{site_file}"):
return True
elif site == "default" and os.path.islink(f"{SITE_ENABLED_DIR}/000-{site_file}"):
if site == "default" and os.path.islink(f"{SITE_ENABLED_DIR}/000-{site_file}"):
return True
else:
return False
return False


def a2ensite(site):
Expand Down
4 changes: 2 additions & 2 deletions src/saltext/apache/states/apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def configfile(name, config):
ret["result"] = True
ret["comment"] = "Configuration is up to date."
return ret
elif __opts__["test"]:
if __opts__["test"]:
ret["comment"] = "Configuration will update."
ret["changes"] = {"old": current_configs, "new": configs}
ret["result"] = None
Expand All @@ -121,7 +121,7 @@ def configfile(name, config):
ret["changes"] = {"old": current_configs, "new": configs}
ret["result"] = True
ret["comment"] = "Successfully created configuration."
except Exception as exc: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
ret["result"] = False
ret["comment"] = "Failed to create apache configuration."

Expand Down

0 comments on commit 91673dc

Please sign in to comment.