pre-commit: run black with string normalization

This commit is contained in:
Erik Sundell
2021-11-03 23:55:34 +01:00
parent 2ba942ba76
commit e0aaa4f995
31 changed files with 700 additions and 692 deletions

View File

@@ -13,43 +13,43 @@ def reload_daemon():
Makes systemd discover new units.
"""
subprocess.run(['systemctl', 'daemon-reload'], check=True)
subprocess.run(["systemctl", "daemon-reload"], check=True)
def install_unit(name, unit, path='/etc/systemd/system'):
def install_unit(name, unit, path="/etc/systemd/system"):
"""
Install unit with given name
"""
with open(os.path.join(path, name), 'w') as f:
with open(os.path.join(path, name), "w") as f:
f.write(unit)
def uninstall_unit(name, path='/etc/systemd/system'):
def uninstall_unit(name, path="/etc/systemd/system"):
"""
Uninstall unit with given name
"""
subprocess.run(['rm', os.path.join(path, name)], check=True)
subprocess.run(["rm", os.path.join(path, name)], check=True)
def start_service(name):
"""
Start service with given name.
"""
subprocess.run(['systemctl', 'start', name], check=True)
subprocess.run(["systemctl", "start", name], check=True)
def stop_service(name):
"""
Start service with given name.
"""
subprocess.run(['systemctl', 'stop', name], check=True)
subprocess.run(["systemctl", "stop", name], check=True)
def restart_service(name):
"""
Restart service with given name.
"""
subprocess.run(['systemctl', 'restart', name], check=True)
subprocess.run(["systemctl", "restart", name], check=True)
def enable_service(name):
@@ -58,7 +58,7 @@ def enable_service(name):
This most likely makes the service start on bootup
"""
subprocess.run(['systemctl', 'enable', name], check=True)
subprocess.run(["systemctl", "enable", name], check=True)
def disable_service(name):
@@ -67,7 +67,7 @@ def disable_service(name):
This most likely makes the service start on bootup
"""
subprocess.run(['systemctl', 'disable', name], check=True)
subprocess.run(["systemctl", "disable", name], check=True)
def check_service_active(name):
@@ -75,7 +75,7 @@ def check_service_active(name):
Check if a service is currently active (running)
"""
try:
subprocess.run(['systemctl', 'is-active', name], check=True)
subprocess.run(["systemctl", "is-active", name], check=True)
return True
except subprocess.CalledProcessError:
return False
@@ -86,7 +86,7 @@ def check_service_enabled(name):
Check if a service is enabled
"""
try:
subprocess.run(['systemctl', 'is-enabled', name], check=True)
subprocess.run(["systemctl", "is-enabled", name], check=True)
return True
except subprocess.CalledProcessError:
return False