@@ -188,7 +188,7 @@ class booleansPage:
if rc != 0:
return self.error(out)
self.load(self.filter)
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def filter_changed(self, *arg):
@@ -132,7 +132,7 @@ class domainsPage(semanagePage):
domain = store.set_value(iter, 1, "")
self.itemSelected(selection)
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def propertiesDialog(self):
@@ -157,5 +157,5 @@ class domainsPage(semanagePage):
domain = store.set_value(iter, 1, _("Permissive"))
self.itemSelected(selection)
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
@@ -131,9 +131,7 @@ class fcontextPage(semanagePage):
self.fcontext = seobject.fcontextRecords()
self.store.clear()
fcon_dict = self.fcontext.get_all(self.local)
- keys = fcon_dict.keys()
- keys.sort()
- for k in keys:
+ for k in sorted(fcon_dict.keys()):
if not self.match(fcon_dict, k, filter):
continue
iter = self.store.append()
@@ -188,7 +186,7 @@ class fcontextPage(semanagePage):
return self.error(out)
store.remove(iter)
self.view.get_selection().select_path((0,))
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def add(self):
@@ -135,7 +135,7 @@ def html_to_text(html, maxcol=80):
text = buffer.getvalue()
buffer.close()
return text
- except Exception, e:
+ except Exception as e:
log_program.error('cannot convert html to text: %s' % e)
return None
@@ -75,10 +75,8 @@ class loginsPage(semanagePage):
self.filter = filter
self.login = seobject.loginRecords()
dict = self.login.get_all(0)
- keys = dict.keys()
- keys.sort()
self.store.clear()
- for k in keys:
+ for k in sorted(dict.keys()):
range = seobject.translate(dict[k][1])
if not (self.match(k, filter) or self.match(dict[k][0], filter) or self.match(range, filter)):
continue
@@ -99,9 +97,7 @@ class loginsPage(semanagePage):
self.loginsSelinuxUserCombo.add_attribute(cell, 'text', 0)
selusers = seobject.seluserRecords().get_all(0)
- keys = selusers.keys()
- keys.sort()
- for k in keys:
+ for k in sorted(selusers.keys()):
if k != "system_u":
self.loginsSelinuxUserCombo.append_text(k)
@@ -146,7 +142,7 @@ class loginsPage(semanagePage):
return False
store.remove(iter)
self.view.get_selection().select_path((0,))
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def add(self):
@@ -56,7 +56,5 @@ class loginsPage:
self.view.set_model(self.store)
self.login = loginRecords()
dict = self.login.get_all(0)
- keys = dict.keys()
- keys.sort()
- for k in keys:
- print "%-25s %-25s %-25s" % (k, dict[k][0], translate(dict[k][1]))
+ for k in sorted(dict.keys()):
+ print("%-25s %-25s %-25s" % (k, dict[k][0], translate(dict[k][1])))
@@ -113,7 +113,7 @@ class modulesPage(semanagePage):
def new_module(self, args):
try:
Popen(["/usr/share/system-config-selinux/polgengui.py"])
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def delete(self):
@@ -129,7 +129,7 @@ class modulesPage(semanagePage):
store.remove(iter)
self.view.get_selection().select_path((0,))
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def enable_audit(self, button):
@@ -147,7 +147,7 @@ class modulesPage(semanagePage):
if status != 0:
self.error(output)
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def disable_audit(self, button):
@@ -158,7 +158,7 @@ class modulesPage(semanagePage):
if status != 0:
self.error(output)
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def propertiesDialog(self):
@@ -193,5 +193,5 @@ class modulesPage(semanagePage):
else:
self.load()
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
@@ -30,7 +30,7 @@ import gnome
import sys
try:
import sepolicy
-except ValueError, e:
+except ValueError as e:
sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e)))
sys.exit(1)
@@ -202,7 +202,7 @@ class childWindow:
self.all_modules = get_all_modules()
self.all_roles = sepolicy.generate.get_all_roles()
self.all_users = sepolicy.generate.get_all_users()
- except RuntimeError, e:
+ except RuntimeError as e:
self.all_types = []
self.all_modules = []
self.all_roles = []
@@ -340,7 +340,7 @@ class childWindow:
for a in sepolicy.interface.get_admin():
iter = self.admin_store.append()
self.admin_store.set_value(iter, 0, a)
- except ValueError, e:
+ except ValueError as e:
self.error(e.message)
def confine_application(self):
@@ -526,7 +526,7 @@ class childWindow:
self.info(my_policy.generate(outputdir))
return False
- except ValueError, e:
+ except ValueError as e:
self.error(e.message)
def delete(self, args):
@@ -694,7 +694,7 @@ class childWindow:
try:
generate.verify_ports(self.in_tcp_entry.get_text())
generate.verify_ports(self.in_udp_entry.get_text())
- except ValueError, e:
+ except ValueError as e:
self.error(e.message)
return True
@@ -702,7 +702,7 @@ class childWindow:
try:
generate.verify_ports(self.out_tcp_entry.get_text())
generate.verify_ports(self.out_udp_entry.get_text())
- except ValueError, e:
+ except ValueError as e:
self.error(e.message)
return True
@@ -123,10 +123,8 @@ class portsPage(semanagePage):
self.filter = filter
self.port = seobject.portRecords()
dict = self.port.get_all(self.local)
- keys = dict.keys()
- keys.sort()
self.store.clear()
- for k in keys:
+ for k in sorted(dict.keys()):
if not (self.match(str(k[0]), filter) or self.match(dict[k][0], filter) or self.match(k[2], filter) or self.match(dict[k][1], filter) or self.match(dict[k][1], filter)):
continue
iter = self.store.append()
@@ -144,10 +142,8 @@ class portsPage(semanagePage):
self.filter = filter
self.port = seobject.portRecords()
dict = self.port.get_all_by_type(self.local)
- keys = dict.keys()
- keys.sort()
self.store.clear()
- for k in keys:
+ for k in sorted(dict.keys()):
ports_string = ", ".join(dict[k])
if not (self.match(ports_string, filter) or self.match(k[0], filter) or self.match(k[1], filter)):
continue
@@ -196,7 +192,7 @@ class portsPage(semanagePage):
return self.error(out)
store.remove(iter)
self.view.get_selection().select_path((0,))
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
def add(self):
@@ -147,7 +147,7 @@ class semanagePage:
if self.add() == False:
continue
break
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
self.dialog.hide()
@@ -160,7 +160,7 @@ class semanagePage:
if self.modify() == False:
continue
break
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])
self.dialog.hide()
@@ -25,9 +25,9 @@ import string
import sys
try:
import gtk
-except RuntimeError, e:
- print "system-config-selinux:", e
- print "This is a graphical application and requires DISPLAY to be set."
+except RuntimeError as e:
+ print("system-config-selinux:", e)
+ print("This is a graphical application and requires DISPLAY to be set.")
sys.exit(1)
import gtk.glade
@@ -100,7 +100,7 @@ class childWindow:
self.add_page(portsPage.portsPage(xml))
self.add_page(modulesPage.modulesPage(xml)) # modules
self.add_page(domainsPage.domainsPage(xml)) # domains
- except ValueError, e:
+ except ValueError as e:
self.error(e.message)
xml.signal_connect("on_quit_activate", self.destroy)
@@ -79,10 +79,8 @@ class usersPage(semanagePage):
self.filter = filter
self.user = seobject.seluserRecords()
dict = self.user.get_all()
- keys = dict.keys()
- keys.sort()
self.store.clear()
- for k in keys:
+ for k in sorted(dict.keys()):
range = seobject.translate(dict[k][2])
if not (self.match(k, filter) or self.match(dict[k][0], filter) or self.match(range, filter) or self.match(dict[k][3], filter)):
continue
@@ -155,5 +153,5 @@ class usersPage(semanagePage):
return False
store.remove(iter)
self.view.get_selection().select_path((0,))
- except ValueError, e:
+ except ValueError as e:
self.error(e.args[0])