summaryrefslogtreecommitdiffstats
path: root/layman
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-08-09 17:47:00 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-08-09 17:47:00 -0700
commit779c56e34676bcf113dea93c748eeec5f214952f (patch)
treed90d3a1ec4aa73162acc4b9cdc21b3970d68155c /layman
parente9742ba56ea23e9d61505a41e9a5cdda60bbfc99 (diff)
downloadlayman-779c56e34676bcf113dea93c748eeec5f214952f.tar.gz
layman-779c56e34676bcf113dea93c748eeec5f214952f.tar.bz2
layman-779c56e34676bcf113dea93c748eeec5f214952f.zip
revert using "as" in exceptions. enable using the "with" statement in py-2.5.
fix run_command( ,*arg, )
Diffstat (limited to 'layman')
-rwxr-xr-xlayman/api.py12
-rw-r--r--layman/argsparser.py1
-rw-r--r--layman/cli.py2
-rw-r--r--layman/db.py12
-rw-r--r--layman/dbbase.py8
-rw-r--r--layman/makeconf.py4
-rwxr-xr-xlayman/overlays/overlay.py2
-rw-r--r--layman/overlays/source.py4
-rw-r--r--layman/overlays/tar.py10
-rw-r--r--layman/utils.py2
10 files changed, 29 insertions, 28 deletions
diff --git a/layman/api.py b/layman/api.py
index 80b927f..f48e11f 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -117,7 +117,7 @@ class LaymanAPI(object):
try:
self._get_installed_db().delete(
self._get_installed_db().select(ovl))
- except Exception as e:
+ except Exception, e:
self._error(
"Exception caught disabling repository '"+ovl+
"':\n"+str(e))
@@ -151,7 +151,7 @@ class LaymanAPI(object):
try:
success = self._get_installed_db().add(
self._get_remote_db().select(ovl), quiet=True)
- except Exception as e:
+ except Exception, e:
self._error("Exception caught enabling repository '"+ovl+
"' : "+str(e))
results.append(success)
@@ -202,7 +202,7 @@ class LaymanAPI(object):
continue
try:
overlay = db.select(ovl)
- except UnknownOverlayException as error:
+ except UnknownOverlayException, error:
self._error(error)
result[ovl] = ('', False, False)
else:
@@ -310,7 +310,7 @@ class LaymanAPI(object):
#self.output.debug("API.sync(); selecting %s, db = %s" % (ovl, str(db)), 5)
odb = db.select(ovl)
self.output.debug("API.sync(); %s now selected" %ovl, 5)
- except UnknownOverlayException as error:
+ except UnknownOverlayException, error:
#self.output.debug("API.sync(); UnknownOverlayException selecting %s" %ovl, 5)
#self._error(str(error))
fatals.append((ovl,
@@ -363,7 +363,7 @@ class LaymanAPI(object):
self.output.debug("API.sync(); starting db.sync(ovl)", 5)
db.sync(ovl, self.config['quiet'])
success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))
- except Exception as error:
+ except Exception, error:
fatals.append((ovl,
'Failed to sync overlay "' + ovl + '".\nError was: '
+ str(error)))
@@ -449,7 +449,7 @@ class LaymanAPI(object):
self.output.debug(
'LaymanAPI.fetch_remote_list(); cache updated = %s'
% str(dbreload),8)
- except Exception as error:
+ except Exception, error:
self.output.error('Failed to fetch overlay list!\n Original Error was: '
+ str(error))
return False
diff --git a/layman/argsparser.py b/layman/argsparser.py
index af95901..8f0b45b 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -20,7 +20,6 @@
#
'''Defines the configuration options and provides parsing functionality.'''
-from __future__ import print_function
__version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
diff --git a/layman/cli.py b/layman/cli.py
index 53d81c6..95ec858 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -166,7 +166,7 @@ class Main(object):
try:
new_umask = int(umask, 8)
old_umask = os.umask(new_umask)
- except Exception as error:
+ except Exception, error:
self.output.die('Failed setting to umask "' + umask +
'"!\nError was: ' + str(error))
diff --git a/layman/db.py b/layman/db.py
index 05da83d..d9a558e 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -16,6 +16,8 @@
#
'''Handles different storage files.'''
+from __future__ import with_statement
+
__version__ = "$Id: db.py 309 2007-04-09 16:23:38Z wrobel $"
#===============================================================================
@@ -326,7 +328,7 @@ class RemoteDB(DbBase):
timestamp = connection.headers['date']
else:
timestamp = None
- except urllib2.HTTPError as e:
+ except urllib2.HTTPError, e:
if e.getcode() == 304:
self.output.info('Remote list already up to date: %s'
% url, 4)
@@ -335,7 +337,7 @@ class RemoteDB(DbBase):
self.output.info('RemoteDB.cache(); HTTPError was:\n %s'
% str(e))
continue
- except IOError as error:
+ except IOError, error:
self.output.warn('RemoteDB.cache(); Failed to update the overlay list from: '
+ url + '\nIOError was:\n' + str(error))
else:
@@ -353,7 +355,7 @@ class RemoteDB(DbBase):
if not os.path.exists(os.path.dirname(mpath)):
try:
os.makedirs(os.path.dirname(mpath))
- except OSError as error:
+ except OSError, error:
raise OSError('Failed to create layman storage direct'
+ 'ory ' + os.path.dirname(mpath) + '\n'
+ 'Error was:' + str(error))
@@ -362,7 +364,7 @@ class RemoteDB(DbBase):
# file is intact and can be parsed
try:
self.read(olist, origin=url)
- except Exception as error:
+ except Exception, error:
raise IOError('Failed to parse the overlays list fetched fr'
'om ' + url + '\nThis means that the download'
'ed file is somehow corrupt or there was a pr'
@@ -382,7 +384,7 @@ class RemoteDB(DbBase):
has_updates = True
- except Exception as error:
+ except Exception, error:
raise IOError('Failed to temporarily cache overlays list in'
' ' + mpath + '\nError was:\n' + str(error))
return has_updates
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 8eafbf7..45be724 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -116,7 +116,7 @@ class DbBase(object):
try:
document = open(path, 'r').read()
- except Exception as error:
+ except Exception, error:
if not ignore_init_read_errors:
self.output.error('Failed to read the overlay list at ("'
+ path + '")')
@@ -148,14 +148,14 @@ class DbBase(object):
'''
try:
document = ET.fromstring(text)
- except xml.parsers.expat.ExpatError as error:
+ except xml.parsers.expat.ExpatError, error:
raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint())
overlays = document.findall('overlay') + \
document.findall('repo')
for overlay in overlays:
- self.output.debug('Parsing overlay entry', 8)
+ self.output.debug('Parsing overlay: %s' % overlay, 9)
ovl = Overlay(config=self.config, xml=overlay,
ignore=self.ignore, quiet=self.quiet)
self.overlays[ovl.name] = ovl
@@ -220,7 +220,7 @@ class DbBase(object):
""")
tree.write(f, encoding='utf-8')
f.close()
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to write to local overlays file: '
+ path + '\nError was:\n' + str(error))
diff --git a/layman/makeconf.py b/layman/makeconf.py
index 1dd2b56..b6f5d90 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -257,7 +257,7 @@ class MakeConf:
make_conf.close()
- except Exception as error:
+ except Exception, error:
self.output.error('MakeConf: write(); Failed to write "'
+ self.path + '".\nError was:\n' + str(error))
return False
@@ -274,7 +274,7 @@ class MakeConf:
make_conf.close()
- except Exception as error:
+ except Exception, error:
self.output.error('MakeConf: content(); Failed to read "' +
self.path + '".\nError was:\n' + str(error))
raise error
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 2e900e8..a14aa99 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -413,7 +413,7 @@ class Overlay(object):
# Worked, throw other sources away
self.sources = [s]
break
- except Exception as error:
+ except Exception, error:
self.output.warn(str(error), 4)
first_s = False
return res
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 71e75fc..3e685e2 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -177,7 +177,7 @@ class OverlaySource(object):
self.output.warn("Checking for cleanup actions to perform", 4)
self.cleanup()
result = 1
- except Exception as err:
+ except Exception, err:
self.output.error(
'Unknown exception running command: %s' % command_repr, 2)
self.output.error('Original error was: %s' % str(err), 2)
@@ -205,7 +205,7 @@ class OverlaySource(object):
kwargs.get('cwd', '')).split()
command = _opt[0]
args = _opt[1:]
- return self.run_command(command, *args,
+ return self.run_command(command, args,
cmd='%s_postsync' % self.__class__.type_key)
return failed_sync
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 7be2ed2..f061ad6 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -111,7 +111,7 @@ class TarOverlay(OverlaySource):
try:
tar = urllib2.urlopen(tar_url).read()
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to fetch the tar package from: '
+ self.src + '\nError was:' + str(error))
@@ -121,7 +121,7 @@ class TarOverlay(OverlaySource):
out_file = open(pkg, 'w')
out_file.write(tar)
out_file.close()
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to store tar package in '
+ pkg + '\nError was:' + str(error))
@@ -140,7 +140,7 @@ class TarOverlay(OverlaySource):
try:
self.output.info('Deleting directory "%s"' % folder, 2)
shutil.rmtree(folder)
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to remove unnecessary tar structure "'
+ folder + '"\nError was:' + str(error))
@@ -149,7 +149,7 @@ class TarOverlay(OverlaySource):
try:
result = self._extract(base=base, tar_url=self.src,
dest_dir=temp_path)
- except Exception as error:
+ except Exception, error:
try_to_wipe(temp_path)
raise error
@@ -165,7 +165,7 @@ class TarOverlay(OverlaySource):
try:
os.rename(source, final_path)
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to rename tar subdirectory ' +
source + ' to ' + final_path +
'\nError was:' + str(error))
diff --git a/layman/utils.py b/layman/utils.py
index e38ea7c..eedc5d7 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -167,7 +167,7 @@ def delete_empty_directory(mdir, output=OUT):
output.info('Deleting _empty_ directory "%s"' % mdir, 2)
try:
os.rmdir(mdir)
- except OSError as error:
+ except OSError, error:
output.warn(str(error))
else:
output.warn('Insufficient permissions to delete _empty_ folder "%s".' % mdir)