Mageia Bugzilla – Attachment 6901 Details for
Bug 16524
Adapting msec to python 3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
the other modifications
0001-Other-modifications-for-pyhton-adapting-to-Python3.patch (text/plain), 4.89 KB, created by
papoteur
on 2015-08-04 20:32:58 CEST
(
hide
)
Description:
the other modifications
Filename:
MIME Type:
Creator:
papoteur
Created:
2015-08-04 20:32:58 CEST
Size:
4.89 KB
patch
obsolete
>From 8e442057cf0506783fd5cf1adf8f130148927b15 Mon Sep 17 00:00:00 2001 >From: Papoteur <papoteur@mageialinux-online.org> >Date: Tue, 4 Aug 2015 20:27:02 +0200 >Subject: [PATCH] Other modifications for pyhton adapting to Python3 > >--- > src/msec/compile.py | 2 +- > src/msec/config.py | 16 ++++------------ > src/msec/libmsec.py | 8 ++++---- > src/msec/man.py | 2 +- > src/msec/msecgui.py | 4 +--- > src/msec/version.py | 2 +- > 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' >-- >2.3.8 >
From 8e442057cf0506783fd5cf1adf8f130148927b15 Mon Sep 17 00:00:00 2001 From: Papoteur <papoteur@mageialinux-online.org> Date: Tue, 4 Aug 2015 20:27:02 +0200 Subject: [PATCH] Other modifications for pyhton adapting to Python3 --- src/msec/compile.py | 2 +- src/msec/config.py | 16 ++++------------ src/msec/libmsec.py | 8 ++++---- src/msec/man.py | 2 +- src/msec/msecgui.py | 4 +--- src/msec/version.py | 2 +- 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' -- 2.3.8
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 16524
:
6881
|
6883
|
6884
|
6885
|
6886
|
6898
|
6899
|
6900
| 6901 |
6913
|
6922
|
6928