diff options
author | SARL ENR 68 <david@david.david> | 2015-08-28 19:58:30 +0200 |
---|---|---|
committer | SARL ENR 68 <david@david.david> | 2015-08-28 19:58:30 +0200 |
commit | 73a2738eba0625fa9befcaeed690e035b12ab91e (patch) | |
tree | dc3d89fc33da63e2e4e354a74f8c219092f32f07 /src/msec/msecgui.py | |
parent | 935d128177eac9d72b19c68bab8d7682a89c11d5 (diff) | |
download | msec-73a2738eba0625fa9befcaeed690e035b12ab91e.tar msec-73a2738eba0625fa9befcaeed690e035b12ab91e.tar.gz msec-73a2738eba0625fa9befcaeed690e035b12ab91e.tar.bz2 msec-73a2738eba0625fa9befcaeed690e035b12ab91e.tar.xz msec-73a2738eba0625fa9befcaeed690e035b12ab91e.zip |
Adaptation to python3 using 2to3-3.4 (mga#16524)
- by papoteur: https://bugs.mageia.org/attachment.cgi?id=6898
Diffstat (limited to 'src/msec/msecgui.py')
-rwxr-xr-x | src/msec/msecgui.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/msec/msecgui.py b/src/msec/msecgui.py index d468b15..765681d 100755 --- a/src/msec/msecgui.py +++ b/src/msec/msecgui.py @@ -9,7 +9,7 @@ import string import getopt import signal import traceback -import Queue +import queue from textwrap import wrap from threading import Thread import time @@ -26,9 +26,9 @@ try: import gi from gi.repository import GObject from gi.repository import Pango -except Warning, e: - print "ERROR: %s" % e - print "Exiting.." +except Warning as e: + print("ERROR: %s" % e) + print("Exiting..") sys.exit(1) warnings.resetwarnings() @@ -51,7 +51,7 @@ import logging # localization import gettext try: - gettext.install("msec", unicode=1) + gettext.install("msec", str=1) except IOError: _ = str @@ -120,21 +120,21 @@ class BackgroundRunner(Thread): def run(self): """Installs tomoyo policy""" - print "Running %s" % self.program + print("Running %s" % self.program) try: res = os.system(self.program) self.finish.put(res) except: - print "Aborted: %s" % sys.exc_value + print("Aborted: %s" % sys.exc_info()[1]) self.finish.put(-1) class MsecGui: """Msec GUI""" # common columns - (COLUMN_LEVEL, COLUMN_LEVEL_DESCR, COLUMN_LEVEL_CURRENT) = range(3) - (COLUMN_OPTION, COLUMN_DESCR, COLUMN_VALUE, COLUMN_CUSTOM) = range(4) - (COLUMN_PATH, COLUMN_USER, COLUMN_GROUP, COLUMN_PERM, COLUMN_FORCE, COLUMN_ACL) = range(6) - (COLUMN_EXCEPTION, COLUMN_EXCEPTION_VALUE, COLUMN_POS) = range(3) + (COLUMN_LEVEL, COLUMN_LEVEL_DESCR, COLUMN_LEVEL_CURRENT) = list(range(3)) + (COLUMN_OPTION, COLUMN_DESCR, COLUMN_VALUE, COLUMN_CUSTOM) = list(range(4)) + (COLUMN_PATH, COLUMN_USER, COLUMN_GROUP, COLUMN_PERM, COLUMN_FORCE, COLUMN_ACL) = list(range(6)) + (COLUMN_EXCEPTION, COLUMN_EXCEPTION_VALUE, COLUMN_POS) = list(range(3)) def __init__(self, log, msec, perms, msecconfig, permconfig, exceptions, embed=None): """Initializes gui""" @@ -239,7 +239,7 @@ class MsecGui: banner.pack_start(label, False, False, 0) main_vbox.pack_start(banner, False, False, 0) except: - print "Banner %s Not found" % ("%s/%s" % (config.MSEC_DIR, BANNER)) + print("Banner %s Not found" % ("%s/%s" % (config.MSEC_DIR, BANNER))) # creating main UI self.main_notebook = Gtk.Notebook() @@ -271,7 +271,7 @@ class MsecGui: self.toggle_level(self.base_level) # pending signals - self.signals = Queue.Queue() + self.signals = queue.Queue() GLib.timeout_add(500, self.check_signals) self.window.show_all() @@ -280,7 +280,7 @@ class MsecGui: """Switches to a new security level""" iter = model.get_iter(path) level = model.get_value(iter, self.COLUMN_LEVEL) - print "Switching to %s" % level + print("Switching to %s" % level) self.toggle_level(level, force=True) def check_signals(self): @@ -524,7 +524,7 @@ class MsecGui: for option in options: # retreiving option description - if not config.SETTINGS.has_key(option): + if option not in config.SETTINGS: # invalid option self.log.error(_("Invalid option '%s'!") % option) continue @@ -585,7 +585,7 @@ class MsecGui: banner.pack_start(image, False, False, 0) table.attach(banner, 0, 1, row, row+1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 0, 0, 0) except: - print "Unable to load icon %s: %s" % (icon, sys.exc_value) + print("Unable to load icon %s: %s" % (icon, sys.exc_info()[1])) label = Gtk.Label(label=text) label.set_property("xalign", 0.0) label.modify_font(Pango.FontDescription("12")) @@ -693,7 +693,7 @@ class MsecGui: with open(logfile, "r") as fd: data = fd.readlines() except: - data = [_("Unable to read log file: %s") % Narg(sys.exc_value)] + data = [_("Unable to read log file: %s") % Narg(sys.exc_info()[1])] dialog = Gtk.Dialog(_("Periodic check results"), self.window, 0, @@ -753,7 +753,7 @@ class MsecGui: self.process_events() # queue to signal that job is finished - q = Queue.Queue() + q = queue.Queue() if check == "manual": program = "/usr/share/msec/security.sh" @@ -1741,13 +1741,13 @@ class MsecGui: # {{{ usage def usage(): """Prints help message""" - print """Msec: Mandriva Security Center (%s). + print("""Msec: Mandriva Security Center (%s). Arguments to msecgui: -h, --help displays this helpful message. -d enable debugging messages. -e, --embedded <XID> embed in MCC. -""" % version +""" % version) # }}} if __name__ == "__main__": @@ -1770,9 +1770,9 @@ if __name__ == "__main__": log_level = logging.DEBUG elif o[0] == '-e' or o[0] == '--embedded': try: - PlugWindowID = long(o[1]) + PlugWindowID = int(o[1]) except: - print >>sys.stderr, "Error: bad master window XID (%s)!" % o[1] + print("Error: bad master window XID (%s)!" % o[1], file=sys.stderr) sys.exit(1) # configuring logging |