aboutsummaryrefslogtreecommitdiff
path: root/munin-libvirt-plugins-detect.in
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2020-03-30 09:49:11 +0200
committerGuido Günther <agx@sigxcpu.org>2020-03-30 09:52:40 +0200
commitacae25af33bbc7f397bd979d4944bcfb568e522d (patch)
tree6121796effd26e1357b1724b35c04dde2e409e59 /munin-libvirt-plugins-detect.in
parentdac37a8697332f88f8387c377fab8a303b091f10 (diff)
Run python3-futurize
Diffstat (limited to 'munin-libvirt-plugins-detect.in')
-rw-r--r--munin-libvirt-plugins-detect.in23
1 files changed, 12 insertions, 11 deletions
diff --git a/munin-libvirt-plugins-detect.in b/munin-libvirt-plugins-detect.in
index 275c987..57eeff1 100644
--- a/munin-libvirt-plugins-detect.in
+++ b/munin-libvirt-plugins-detect.in
@@ -9,6 +9,7 @@
#
# Detect connection uri and enable plugins
+from __future__ import print_function
import os
import sys
from optparse import OptionParser
@@ -33,27 +34,27 @@ def check_uris(uris, force=False):
libvirt.openReadOnly(uri)
detected = uri
break
- except libvirt.libvirtError, err:
+ except libvirt.libvirtError as err:
pass
if detected:
- print "Hypervisor at %s detected." % detected
+ print("Hypervisor at %s detected." % detected)
if not os.path.exists(PLUGIN_CONF) or force:
try:
conf = file(PLUGIN_CONF, "w+")
- print >>conf, "[libvirt-*]"
- print >>conf, "env.uri %s""" % detected
+ print("[libvirt-*]", file=conf)
+ print("env.uri %s""" % detected, file=conf)
conf.close()
- except IOError, err:
- print >>sys.stderr, err
+ except IOError as err:
+ print(err, file=sys.stderr)
return 1
else:
- print >>sys.stderr, "Plugin configuration '%s' already exists - doing nothing" % PLUGIN_CONF
+ print("Plugin configuration '%s' already exists - doing nothing" % PLUGIN_CONF, file=sys.stderr)
return 0
def enable_plugins(force=False):
- for plugin in map(lambda x: "libvirt-" + x, PLUGINS):
+ for plugin in ["libvirt-" + x for x in PLUGINS]:
src = os.path.join(PLUGIN_SRC, plugin)
dst = os.path.join(PLUGIN_DST, plugin)
if force:
@@ -62,9 +63,9 @@ def enable_plugins(force=False):
except OSError:
pass
if os.path.exists(dst):
- print >>sys.stderr, "Plugin '%s' already enabled - doing nothing" % plugin
+ print("Plugin '%s' already enabled - doing nothing" % plugin, file=sys.stderr)
else:
- print >>sys.stderr, "Enabling plugin '%s'" % plugin
+ print("Enabling plugin '%s'" % plugin, file=sys.stderr)
os.symlink(src, dst)
return 0
@@ -99,7 +100,7 @@ def main(args):
uris = URIS
if not has_libvirt:
- print >>sys.stderr, "Libvirt not available."
+ print("Libvirt not available.", file=sys.stderr)
return 1
ret = check_uris(uris, options.force)