aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSARL ENR 68 <david@david.david>2015-08-28 20:06:30 +0200
committerSARL ENR 68 <david@david.david>2015-08-28 20:06:30 +0200
commita3a185fdf46f25d4c8321b478427cc14987d62db (patch)
tree24befc5ae5eac62f0b6878f0c768f4a073d34bea
parent790687cc86370e6f672654b3ab76d5a1fad41bf1 (diff)
downloadmsec-a3a185fdf46f25d4c8321b478427cc14987d62db.tar
msec-a3a185fdf46f25d4c8321b478427cc14987d62db.tar.gz
msec-a3a185fdf46f25d4c8321b478427cc14987d62db.tar.bz2
msec-a3a185fdf46f25d4c8321b478427cc14987d62db.tar.xz
msec-a3a185fdf46f25d4c8321b478427cc14987d62db.zip
Other modifications for pyhton adapting to Python3 (mga#16524)
- by papoteur: https://bugs.mageia.org/attachment.cgi?id=6901
-rwxr-xr-xsrc/msec/compile.py2
-rwxr-xr-xsrc/msec/config.py16
-rwxr-xr-xsrc/msec/libmsec.py8
-rwxr-xr-xsrc/msec/man.py2
-rwxr-xr-xsrc/msec/msecgui.py4
-rwxr-xr-xsrc/msec/version.py2
6 files changed, 12 insertions, 22 deletions
diff --git a/src/msec/compile.py b/src/msec/compile.py
index 2983271..ad7fdca 100755
--- a/src/msec/compile.py
+++ b/src/msec/compile.py
@@ -15,7 +15,7 @@ for f in sys.argv[2:]:
try:
py_compile.compile(f, f+"o", sys.argv[1] + f)
except:
- print(("Cannot compile", f))
+ print("Cannot compile", f)
pass
# compile.py ends here
diff --git a/src/msec/config.py b/src/msec/config.py
index b4466ed..8bbcf86 100755
--- a/src/msec/config.py
+++ b/src/msec/config.py
@@ -180,16 +180,8 @@ def to_utf8(s):
return str(s).decode("utf-8")
def Narg(s):
- """ Returs string after decoding if needed """
- try:
- s.decode()
- return s
- except:
- try:
- t=str(s)
- except:
- return s
- return t.decode(SYS_ENC)
+ """ Returns string after decoding if needed. It seems to be no more need in Python 3 """
+ return s
# {{{ MsecConfig
class MsecConfig:
@@ -231,7 +223,7 @@ class MsecConfig:
try:
fd = open(self.config)
except:
- self.log.error(_("Unable to load configuration file %s: %s") % (self.config, Narg(sys.exc_value[1])))
+ 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()
@@ -339,7 +331,7 @@ class ExceptionConfig:
fd = open(self.config)
except:
# this file is optional, so if it is not found that's not fatal
- self.log.info(_("loading exceptions file %s: %s") % (self.config, Narg(sys.exc_value[1])))
+ self.log.info(_("loading exceptions file %s: %s") % (self.config, Narg(sys.exc_info()[1])))
self.log.info(_("No exceptions loaded"))
return False
for line in fd.readlines():
diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py
index f8a296a..bf6a242 100755
--- a/src/msec/libmsec.py
+++ b/src/msec/libmsec.py
@@ -123,7 +123,7 @@ class Log:
self.syslog_h.setFormatter(formatter)
self.logger.addHandler(self.syslog_h)
except:
- print("Logging to syslog not available: %s" % (sys.exc_value[1]), file=sys.stderr)
+ print("Logging to syslog not available: %s" % (sys.exc_info()[1]), file=sys.stderr)
interactive = True
# log to file
@@ -134,7 +134,7 @@ class Log:
self.file_h.setFormatter(formatter)
self.logger.addHandler(self.file_h)
except:
- print("Logging to '%s' not available: %s" % (self.log_path, sys.exc_value[1]), file=sys.stderr)
+ print("Logging to '%s' not available: %s" % (self.log_path, sys.exc_info()[1]), file=sys.stderr)
interactive = True
# interactive logging
@@ -312,7 +312,7 @@ class ConfigFile:
else:
self.lines = []
if file:
- self.lines = string.split(file.read(), "\n")
+ self.lines = file.read().split("\n")
file.close()
return self.lines
@@ -848,7 +848,7 @@ class PERMS:
regexp = None
for line in file.readlines():
- fields = string.split(line)
+ fields = line.split()
if fields[2] in non_localfs:
if regexp:
regexp = regexp + '|' + fields[1]
diff --git a/src/msec/man.py b/src/msec/man.py
index d3983b5..62d5fe6 100755
--- a/src/msec/man.py
+++ b/src/msec/man.py
@@ -21,7 +21,7 @@ try:
except:
version = "(development version)"
-header = '''.ds q \N'34'
+header = r'''.ds q \N'34'
.TH msec 8 msec "Mandriva Linux"
.SH NAME
msec \- Mandriva Linux security tools
diff --git a/src/msec/msecgui.py b/src/msec/msecgui.py
index 2a7142f..198b536 100755
--- a/src/msec/msecgui.py
+++ b/src/msec/msecgui.py
@@ -1646,9 +1646,7 @@ class MsecGui:
val_def = conf_def.get(param)
for i in [param, descr, value]:
- i = Narg(i)
- # if not (type(i) == unicode) and not config.try_decode(i):
- # i = i.decode(config.SYS_ENC)
+ i = Narg(i)
# asks for new parameter value
dialog = Gtk.Dialog(_("Select new value for %s") % (param),
diff --git a/src/msec/version.py b/src/msec/version.py
index dbc02ca..43fc33b 100755
--- a/src/msec/version.py
+++ b/src/msec/version.py
@@ -1 +1 @@
-version='1.5'
+version='1.13'