mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
run: fix flake8 violations
Two blank lines are needed either side of functions. Comments must have a single space character immediately after the "#". The unused exception variable can be removed. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
457f4e6e1e
commit
4e83722a60
15
run.in
15
run.in
@ -16,7 +16,7 @@
|
||||
# License along with this library; If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
#
|
||||
# With this script you can run libvirt programs without needing to
|
||||
# install them first. You just have to do for example:
|
||||
@ -38,7 +38,7 @@
|
||||
#
|
||||
# sudo ./run virsh list --all
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import os.path
|
||||
@ -46,6 +46,7 @@ import random
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
# Function to intelligently prepend a path to an environment variable.
|
||||
# See https://stackoverflow.com/a/9631350
|
||||
def prepend(env, varname, extradir):
|
||||
@ -54,6 +55,7 @@ def prepend(env, varname, extradir):
|
||||
else:
|
||||
env[varname] = extradir
|
||||
|
||||
|
||||
here = "@abs_builddir@"
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
@ -93,29 +95,36 @@ modular_daemons = [
|
||||
"virtxend",
|
||||
]
|
||||
|
||||
|
||||
def is_modular_daemon(name):
|
||||
return name in modular_daemons
|
||||
|
||||
|
||||
def is_monolithic_daemon(name):
|
||||
return name == "libvirtd"
|
||||
|
||||
|
||||
def is_systemd_host():
|
||||
if os.getuid() != 0:
|
||||
return False
|
||||
return os.path.exists("/run/systemd/system")
|
||||
|
||||
|
||||
def daemon_units(name):
|
||||
return [name + suffix for suffix in [
|
||||
".service", ".socket", "-ro.socket", "-admin.socket"]]
|
||||
|
||||
|
||||
def is_unit_active(name):
|
||||
ret = subprocess.call(["systemctl", "is-active", "-q", name])
|
||||
return ret == 0
|
||||
|
||||
|
||||
def change_unit(name, action):
|
||||
ret = subprocess.call(["systemctl", action, "-q", name])
|
||||
return ret == 0
|
||||
|
||||
|
||||
try_stop_units = []
|
||||
if is_systemd_host():
|
||||
name = os.path.basename(prog)
|
||||
@ -152,7 +161,7 @@ else:
|
||||
|
||||
print("Running %s..." % prog)
|
||||
ret = subprocess.call([prog] + args, env=env)
|
||||
except KeyboardInterrupt as ex:
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
print("Re-starting original systemd units...")
|
||||
|
Loading…
Reference in New Issue
Block a user