From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QF2Tx-0003dU-6d for garchives@archives.gentoo.org; Wed, 27 Apr 2011 11:00:33 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5D0781C0B9; Wed, 27 Apr 2011 10:58:46 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 18A771C0BA for ; Wed, 27 Apr 2011 10:58:45 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 174BE2AC005 for ; Wed, 27 Apr 2011 10:58:45 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 7A6498050A for ; Wed, 27 Apr 2011 10:58:44 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/api.py layman/cli.py layman/db.py layman/dbbase.py layman/makeconf.py layman/overlays/overlay.py layman/overlays/tar.py layman/utils.py X-VCS-Directories: layman/overlays/ layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: d0339cb228c16eb491d489a2276e254bacb41c81 Date: Wed, 27 Apr 2011 10:58:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 9e2996bfb6261a27b4cf8ef58d4852fa commit: d0339cb228c16eb491d489a2276e254bacb41c81 Author: Brian Dolbec gmail com> AuthorDate: Sun Mar 27 03:39:37 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sun Mar 27 03:39:37 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3Dd0339cb2 migrate except ... as=20 --- layman/api.py | 14 +++++++------- layman/cli.py | 4 ++-- layman/db.py | 8 ++++---- layman/dbbase.py | 6 +++--- layman/makeconf.py | 4 ++-- layman/overlays/overlay.py | 2 +- layman/overlays/tar.py | 10 +++++----- layman/utils.py | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/layman/api.py b/layman/api.py index 9dfb1a3..9178dbe 100644 --- a/layman/api.py +++ b/layman/api.py @@ -116,7 +116,7 @@ class LaymanAPI(object): try: self._get_installed_db().delete(self._get_installed_db()= .select(ovl)) results.append(True) - except Exception, e: + except Exception as e: self._error(ERROR_INTERNAL_ERROR, "Failed to disable repository '"+ovl+"':\n"+str(= e)) results.append(False) @@ -147,7 +147,7 @@ class LaymanAPI(object): try: self._get_installed_db().add(self._get_remote_db().selec= t(ovl), quiet=3DTrue) results.append(True) - except Exception, e: + except Exception as e: self._error(ERROR_INTERNAL_ERROR, "Failed to enable repository '"+ovl+"' : "+str(e= )) results.append(False) @@ -198,7 +198,7 @@ class LaymanAPI(object): continue try: overlay =3D db.select(ovl) - except UnknownOverlayException, error: + except UnknownOverlayException as error: self._error(error) result[ovl] =3D ('', False, False) else: @@ -252,7 +252,7 @@ class LaymanAPI(object): overlay =3D db.select(ovl) #print("overlay =3D ", ovl) #print("!!!", overlay) - except UnknownOverlayException, error: + except UnknownOverlayException as error: #print("ERRORS", str(error)) self._error(error) result[ovl] =3D ('', False, False) @@ -301,7 +301,7 @@ class LaymanAPI(object): for ovl in repos: try: odb =3D db.select(ovl) - except UnknownOverlayException, error: + except UnknownOverlayException as error: self._error(UnknownOverlayException(error)) continue =20 @@ -344,7 +344,7 @@ class LaymanAPI(object): try: db.sync(ovl, self.config['quiet']) success.append((ovl,'Successfully synchronized overlay "= ' + ovl + '".')) - except Exception, error: + except Exception as error: fatals.append((ovl, 'Failed to sync overlay "' + ovl + '".\nError was: ' + str(error))) @@ -374,7 +374,7 @@ class LaymanAPI(object): """Fetches the latest remote overlay list""" try: self._get_remote_db().cache() - except Exception, error: + except Exception as error: self._error('Failed to fetch overlay list!\n Original Error = was: ' + str(error)) return False diff --git a/layman/cli.py b/layman/cli.py index 1187ef2..d58c4ff 100644 --- a/layman/cli.py +++ b/layman/cli.py @@ -162,7 +162,7 @@ class Main(object): try: new_umask =3D int(umask, 8) old_umask =3D os.umask(new_umask) - except Exception, error: + except Exception as error: self.output.die('Failed setting to umask "' + umask + '"!\nError was: ' + str(error)) =20 @@ -173,7 +173,7 @@ class Main(object): if action[0] in self.config.keys(): try: result +=3D getattr(self, action[1])() - except Exception, error: + except Exception as error: for _error in self.api.get_errors(): self.output.error(_error) result =3D -1 # So it cannot remain 0, i.e. success diff --git a/layman/db.py b/layman/db.py index ed2bb2e..6e3cba4 100644 --- a/layman/db.py +++ b/layman/db.py @@ -303,7 +303,7 @@ class RemoteDB(DbBase): if not os.path.exists(os.path.dirname(mpath)): try: os.makedirs(os.path.dirname(mpath)) - except OSError, error: + except OSError as error: raise OSError('Failed to create layman storage d= irect' + 'ory ' + os.path.dirname(mpath) = + '\n' + 'Error was:' + str(error)) @@ -312,7 +312,7 @@ class RemoteDB(DbBase): # file is intact and can be parsed try: self.read(olist, origin=3Durl) - except Exception, error: + except Exception as error: raise IOError('Failed to parse the overlays list fet= ched fr' 'om ' + url + '\nThis means that the d= ownload' 'ed file is somehow corrupt or there w= as a pr' @@ -325,12 +325,12 @@ class RemoteDB(DbBase): out_file.write(olist) out_file.close() =20 - except Exception, error: + except Exception as error: raise IOError('Failed to temporarily cache overlays = list in' ' ' + mpath + '\nError was:\n' + str(e= rror)) =20 =20 - except IOError, error: + except IOError as error: self.output.warn('Failed to update the overlay list from= : ' + url + '\nError was:\n' + str(error)) =20 diff --git a/layman/dbbase.py b/layman/dbbase.py index 02aeb9d..5c45cb1 100644 --- a/layman/dbbase.py +++ b/layman/dbbase.py @@ -116,7 +116,7 @@ class DbBase: try: document =3D open(path, 'r').read() =20 - except Exception, error: + except Exception as error: if not ignore_init_read_errors: self.output.error('Failed to read the overlay list at ("= ' + path + '")') @@ -146,7 +146,7 @@ class DbBase: ''' try: document =3D ET.fromstring(text) - except xml.parsers.expat.ExpatError, error: + except xml.parsers.expat.ExpatError as error: raise BrokenOverlayCatalog(origin, error, self._broken_catal= og_hint()) =20 overlays =3D document.findall('overlay') + \ @@ -216,7 +216,7 @@ class DbBase: """) tree.write(f, encoding=3D'utf-8') f.close() - except Exception, error: + except Exception as error: raise Exception('Failed to write to local overlays file: ' + path + '\nError was:\n' + str(error)) =20 diff --git a/layman/makeconf.py b/layman/makeconf.py index b6f5d90..1dd2b56 100644 --- a/layman/makeconf.py +++ b/layman/makeconf.py @@ -257,7 +257,7 @@ class MakeConf: =20 make_conf.close() =20 - except Exception, error: + except Exception as error: self.output.error('MakeConf: write(); Failed to write "' + self.path + '".\nError was:\n' + str(error)) return False @@ -274,7 +274,7 @@ class MakeConf: =20 make_conf.close() =20 - except Exception, error: + except Exception as 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 aada4a2..b99c052 100644 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -405,7 +405,7 @@ class Overlay(object): # Worked, throw other sources away self.sources =3D [s] break - except Exception, error: + except Exception as error: self.output.warn(str(error), 4) first_s =3D False return res diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py index 9d59b71..204a626 100644 --- a/layman/overlays/tar.py +++ b/layman/overlays/tar.py @@ -107,7 +107,7 @@ class TarOverlay(OverlaySource): =20 try: tar =3D urllib2.urlopen(tar_url).read() - except Exception, error: + except Exception as error: raise Exception('Failed to fetch the tar package from: ' + self.src + '\nError was:' + str(error)) =20 @@ -117,7 +117,7 @@ class TarOverlay(OverlaySource): out_file =3D open(pkg, 'w') out_file.write(tar) out_file.close() - except Exception, error: + except Exception as error: raise Exception('Failed to store tar package in ' + pkg + '\nError was:' + str(error)) =20 @@ -136,7 +136,7 @@ class TarOverlay(OverlaySource): try: self.output.info('Deleting directory "%s"' % folder, 2) shutil.rmtree(folder) - except Exception, error: + except Exception as error: raise Exception('Failed to remove unnecessary tar struct= ure "' + folder + '"\nError was:' + str(error)) =20 @@ -145,7 +145,7 @@ class TarOverlay(OverlaySource): try: result =3D self._extract(base=3Dbase, tar_url=3Dself.src, dest_dir=3Dtemp_path) - except Exception, error: + except Exception as error: try_to_wipe(temp_path) raise error =20 @@ -161,7 +161,7 @@ class TarOverlay(OverlaySource): =20 try: os.rename(source, final_path) - except Exception, error: + except Exception as 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 86524ef..03ddb45 100644 --- a/layman/utils.py +++ b/layman/utils.py @@ -167,7 +167,7 @@ def delete_empty_directory(mdir, output=3DOUT): output.info('Deleting _empty_ directory "%s"' % mdir, 2) try: os.rmdir(mdir) - except OSError, error: + except OSError as error: output.warn(str(error)) else: output.warn('Insufficient permissions to delete _empty_ fold= er "%s".' % mdir)