summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-04-26 20:07:47 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-04-26 20:07:47 -0500
commit7f68ebb4ce4cb65850a63660f2f1cec06100064a (patch)
treefb8fb3af8f11c5489315022924cd9d7146a666c0 /src
parentcca5e6a474adf1453408909979143233d54ed2be (diff)
downloadbcfg2-7f68ebb4ce4cb65850a63660f2f1cec06100064a.tar.gz
bcfg2-7f68ebb4ce4cb65850a63660f2f1cec06100064a.tar.bz2
bcfg2-7f68ebb4ce4cb65850a63660f2f1cec06100064a.zip
Admin: Add full PY3K compatibility
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Admin/Init.py6
-rw-r--r--src/lib/Server/Admin/Query.py3
-rw-r--r--src/lib/Server/Admin/Reports.py13
-rw-r--r--src/lib/Server/Admin/Snapshots.py8
-rw-r--r--src/lib/Server/Admin/Viz.py3
-rw-r--r--src/lib/Server/Admin/Xcmd.py7
-rw-r--r--src/lib/Server/Admin/__init__.py6
7 files changed, 31 insertions, 15 deletions
diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py
index 9771fd10b..9fd408585 100644
--- a/src/lib/Server/Admin/Init.py
+++ b/src/lib/Server/Admin/Init.py
@@ -157,7 +157,8 @@ def create_conf(confpath, confdata):
try:
open(confpath, "w").write(confdata)
os.chmod(keypath, stat.S_IRUSR|stat.S_IWUSR) # 0600
- except Exception, e:
+ except Exception:
+ e = sys.exc_info()[1]
print("Error %s occured while trying to write configuration "
"file to '%s'.\n" %
(e, confpath))
@@ -381,7 +382,8 @@ class Init(Bcfg2.Server.Admin.Mode):
'', ["Bcfg2.Server.Plugins"])
cls = getattr(module, plugin)
cls.init_repo(self.repopath)
- except Exception, e:
+ except Exception:
+ e = sys.exc_info()[1]
print("Plugin setup for %s failed: %s\n"
"Check that dependencies are installed?" % (plugin, e))
diff --git a/src/lib/Server/Admin/Query.py b/src/lib/Server/Admin/Query.py
index 207b65035..9e1d7cc88 100644
--- a/src/lib/Server/Admin/Query.py
+++ b/src/lib/Server/Admin/Query.py
@@ -26,7 +26,8 @@ class Query(Bcfg2.Server.Admin.Mode):
self.bcore = Bcfg2.Server.Core.Core(self.get_repo_path(),
['Metadata', 'Probes'],
'foo', False, 'UTF-8')
- except Bcfg2.Server.Core.CoreInitError, msg:
+ except Bcfg2.Server.Core.CoreInitError:
+ msg = sys.exc_info()[1]
self.errExit("Core load failed because %s" % msg)
self.bcore.fam.handle_events_in_interval(1)
self.meta = self.bcore.metadata
diff --git a/src/lib/Server/Admin/Reports.py b/src/lib/Server/Admin/Reports.py
index ee3a4473f..942477a49 100644
--- a/src/lib/Server/Admin/Reports.py
+++ b/src/lib/Server/Admin/Reports.py
@@ -1,7 +1,6 @@
'''Admin interface for dynamic reports'''
import Bcfg2.Logger
import Bcfg2.Server.Admin
-import ConfigParser
import datetime
import os
import logging
@@ -14,6 +13,9 @@ from Bcfg2.Server.Reports.updatefix import update_database
from Bcfg2.Server.Reports.utils import *
from lxml.etree import XML, XMLSyntaxError
+# Compatibility import
+from Bcfg2.Bcfg2Py3k import ConfigParser
+
# FIXME: Remove when server python dep is 2.5 or greater
if sys.version_info >= (2, 5):
from hashlib import md5
@@ -26,7 +28,8 @@ import django.core.management
# FIXME - settings file uses a hardcoded path for /etc/bcfg2.conf
try:
import Bcfg2.Server.Reports.settings
-except Exception, e:
+except Exception:
+ e = sys.exc_info()[1]
sys.stderr.write("Failed to load configuration settings. %s\n" % e)
sys.exit(1)
@@ -185,7 +188,8 @@ class Reports(Bcfg2.Server.Admin.Mode):
# Currently only reasons are a problem
try:
start_count = Reason.objects.count()
- except Exception, e:
+ except Exception:
+ e = sys.exc_info()[1]
self.log.error("Failed to load reason objects: %s" % e)
return
dup_reasons = []
@@ -216,7 +220,8 @@ class Reports(Bcfg2.Server.Admin.Mode):
cursor.executemany('update reports_entries_interactions set reason_id=%s where reason_id=%s', batch_update)
cursor.executemany('delete from reports_reason where id = %s', dup_reasons)
transaction.set_dirty()
- except Exception, ex:
+ except Exception:
+ ex = sys.exc_info()[1]
self.log.error("Failed to delete reasons: %s" % ex)
raise
diff --git a/src/lib/Server/Admin/Snapshots.py b/src/lib/Server/Admin/Snapshots.py
index d58873174..052545b61 100644
--- a/src/lib/Server/Admin/Snapshots.py
+++ b/src/lib/Server/Admin/Snapshots.py
@@ -8,6 +8,8 @@ import Bcfg2.Server.Snapshots
import Bcfg2.Server.Snapshots.model
from Bcfg2.Server.Snapshots.model import Snapshot, Client, Metadata, Base, \
File, Group, Package, Service
+# Compatibility import
+from Bcfg2.Bcfg2Py3k import u_str
class Snapshots(Bcfg2.Server.Admin.Mode):
__shorthelp__ = "Interact with the Snapshots system"
@@ -71,7 +73,7 @@ class Snapshots(Bcfg2.Server.Admin.Mode):
session.commit()
elif args[0] == 'dump':
client = args[1]
- snap = Snapshot.get_current(self.session, unicode(client))
+ snap = Snapshot.get_current(self.session, u_str(client))
if not snap:
print("Current snapshot for %s not found" % client)
sys.exit(1)
@@ -105,7 +107,7 @@ class Snapshots(Bcfg2.Server.Admin.Mode):
print("Usage: bcfg2-admin snapshots -b <client>")
return
client = args[2]
- snap = Snapshot.get_current(self.session, unicode(client))
+ snap = Snapshot.get_current(self.session, u_str(client))
if not snap:
print("Current snapshot for %s not found" % client)
sys.exit(1)
@@ -128,7 +130,7 @@ class Snapshots(Bcfg2.Server.Admin.Mode):
elif '-e' in args[1:]:
# Query a single host for extra entries
client = args[2]
- snap = Snapshot.get_current(self.session, unicode(client))
+ snap = Snapshot.get_current(self.session, u_str(client))
if not snap:
print("Current snapshot for %s not found" % client)
sys.exit(1)
diff --git a/src/lib/Server/Admin/Viz.py b/src/lib/Server/Admin/Viz.py
index a77502b5d..f39e6d7a8 100644
--- a/src/lib/Server/Admin/Viz.py
+++ b/src/lib/Server/Admin/Viz.py
@@ -45,7 +45,8 @@ class Viz(Bcfg2.Server.Admin.MetadataCore):
opts, args = getopt.getopt(args, 'Hbko:',
['includehosts', 'includebundles',
'includekey', 'outfile='])
- except getopt.GetoptError, msg:
+ except getopt.GetoptError:
+ msg = sys.exc_info()[1]
print(msg)
#FIXME: is this for --raw?
diff --git a/src/lib/Server/Admin/Xcmd.py b/src/lib/Server/Admin/Xcmd.py
index e761a5e3d..fd5794f88 100644
--- a/src/lib/Server/Admin/Xcmd.py
+++ b/src/lib/Server/Admin/Xcmd.py
@@ -1,10 +1,12 @@
import sys
-import xmlrpclib
import Bcfg2.Options
import Bcfg2.Proxy
import Bcfg2.Server.Admin
+# Compatibility import
+from Bcfg2.Bcfg2Py3k import xmlrpclib
+
class Xcmd(Bcfg2.Server.Admin.Mode):
__shorthelp__ = ("XML-RPC Command Interface")
@@ -39,7 +41,8 @@ class Xcmd(Bcfg2.Server.Admin.Mode):
args = tuple(setup['args'][1:])
try:
data = getattr(proxy, cmd)(*args)
- except xmlrpclib.Fault, flt:
+ except xmlrpclib.Fault:
+ flt = sys.exc_info()[1]
if flt.faultCode == 7:
print("Unknown method %s" % cmd)
return
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index 411f909ee..8915492a3 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -19,13 +19,14 @@ __all__ = [
'Xcmd'
]
-import ConfigParser
import logging
import lxml.etree
import sys
import Bcfg2.Server.Core
import Bcfg2.Options
+# Compatibility import
+from Bcfg2.Bcfg2Py3k import ConfigParser
class ModeOperationError(Exception):
@@ -126,7 +127,8 @@ class MetadataCore(Mode):
self.bcore = Bcfg2.Server.Core.Core(self.get_repo_path(),
setup['plugins'],
'foo', 'UTF-8')
- except Bcfg2.Server.Core.CoreInitError, msg:
+ except Bcfg2.Server.Core.CoreInitError:
+ msg = sys.exc_info()[1]
self.errExit("Core load failed because %s" % msg)
self.bcore.fam.handle_events_in_interval(5)
self.metadata = self.bcore.metadata