aboutsummaryrefslogtreecommitdiffstats
path: root/src/msec/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/msec/config.py')
-rwxr-xr-xsrc/msec/config.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/msec/config.py b/src/msec/config.py
index 9f41998..8caacfc 100755
--- a/src/msec/config.py
+++ b/src/msec/config.py
@@ -38,7 +38,7 @@ SECURITYLOG = '/var/log/msec.log'
# localization
try:
- gettext.install('msec', unicode=1)
+ gettext.install('msec', str=1)
except IOError:
_ = str
@@ -267,7 +267,7 @@ class MsecConfig:
def list_options(self):
"""Sorts and returns configuration parameters"""
- sortedparams = self.options.keys()
+ sortedparams = list(self.options.keys())
if sortedparams:
sortedparams.sort()
return sortedparams
@@ -280,10 +280,10 @@ class MsecConfig:
try:
fd = open(self.config, "w")
except:
- self.log.error(_("Unable to save %s: %s") % (self.config, Narg(sys.exc_value)))
+ self.log.error(_("Unable to save %s: %s") % (self.config, Narg(sys.exc_info()[1])))
return False
for comment in self.comments:
- print >>fd, comment
+ print(comment, file=fd)
# sorting keys
for option in self.list_options():
value = self.options[option]
@@ -310,7 +310,7 @@ class MsecConfig:
pass
else:
value = '"%s"' % value
- print >>fd, "%s=%s" % (option, value)
+ print("%s=%s" % (option, value), file=fd)
return True
# }}}
@@ -373,7 +373,7 @@ class ExceptionConfig:
def set(self, pos, value):
"""Sets a configuration option"""
if pos > 0:
- print "Pos: %d" % pos
+ print("Pos: %d" % pos)
self.options[pos] = value
else:
self.options.append(value)
@@ -393,17 +393,17 @@ class ExceptionConfig:
try:
fd = open(self.config, "w")
except:
- self.log.error(_("Unable to save %s: %s") % (self.config, Narg(sys.exc_value)))
+ self.log.error(_("Unable to save %s: %s") % (self.config, Narg(sys.exc_info()[1])))
return False
for comment in self.comments:
- print >>fd, comment
+ print(comment, file=fd)
# sorting keys
for option,value in self.options:
# TODO: integrate with remove()
if value == None or value == OPTION_DISABLED:
self.log.debug("Skipping %s" % option)
else:
- print >>fd, "%s %s" % (option, value)
+ print("%s %s" % (option, value), file=fd)
return True
# }}}
@@ -443,7 +443,7 @@ class PermConfig(MsecConfig):
try:
fd = open(self.config)
except:
- self.log.error(_("Unable to load configuration file %s: %s") % (self.config, Narg(sys.exc_value)))
+ self.log.error(_("Unable to load configuration file %s: %s") % (self.config, Narg(sys.exc_info()[1])))
return False
for line in fd.readlines():
line = line.strip()
@@ -488,10 +488,10 @@ class PermConfig(MsecConfig):
try:
fd = open(self.config, "w")
except:
- self.log.error(_("Unable to save %s: %s") % (self.config, Narg(sys.exc_value)))
+ self.log.error(_("Unable to save %s: %s") % (self.config, Narg(sys.exc_info()[1])))
return False
for comment in self.comments:
- print >>fd, comment
+ print(comment, file=fd)
# sorting keys
for file in self.options_order:
value = self.options[file]
@@ -509,6 +509,6 @@ class PermConfig(MsecConfig):
force = "\tforce"
else:
force = ""
- print >>fd, "%s\t%s.%s\t%s%s\t%s" % (file, user, group, perm, force, acl)
+ print("%s\t%s.%s\t%s%s\t%s" % (file, user, group, perm, force, acl), file=fd)
return True
# }}}