Improve error handling

This commit is contained in:
Stefano Rivera 2011-01-01 19:51:03 +02:00
parent d9a9b4cab4
commit 3ef8324ff7
4 changed files with 26 additions and 7 deletions

View File

@ -28,7 +28,7 @@ import tempfile
from launchpadlib.launchpad import Launchpad
import lsb_release
from ubuntutools.archive import UbuntuSourcePackage
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
from ubuntutools.config import UDTConfig, ubu_email
from ubuntutools.builder import get_builder
from ubuntutools.logger import Logger
@ -298,6 +298,8 @@ def main(args):
opts.update,
opts.upload,
opts.prompt)
except DownloadError, e:
error(str(e))
finally:
if not opts.workdir:
shutil.rmtree(workdir)

View File

@ -25,7 +25,7 @@ import sys
import debian.debian_support
import debian.changelog
from ubuntutools.archive import DebianSourcePackage
from ubuntutools.archive import DebianSourcePackage, DownloadError
from ubuntutools.config import UDTConfig
from ubuntutools.logger import Logger
@ -81,9 +81,12 @@ def main():
Logger.normal('Downloading %s %s', package, version)
#TODO: Proper snapshot and security support
newpkg = DebianSourcePackage(package, version, mirrors=mirrors)
newpkg.pull()
try:
newpkg.pull()
except DownloadError, e:
Logger.error(str(e))
sys.exit(1)
newpkg.unpack()
if opts.fetch_only:
@ -96,7 +99,11 @@ def main():
Logger.normal('Downloading %s %s', package, oldversion)
oldpkg = DebianSourcePackage(package, oldversion, mirrors=mirrors)
oldpkg.pull()
try:
oldpkg.pull()
except DownloadError, e:
Logger.error(str(e))
sys.exit(1)
oldpkg.unpack()
cmd = ['debdiff', oldpkg.dsc_name, newpkg.dsc_name]

View File

@ -269,7 +269,12 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
version = Version(version)
if version is None or component is None:
debian_srcpkg = getDebianSrcPkg(package, dist)
try:
debian_srcpkg = getDebianSrcPkg(package, dist)
except (udtexceptions.PackageNotFoundException,
udtexceptions.SeriesNotFoundException), e:
Logger.error(str(e))
sys.exit(1)
if version is None:
version = Version(debian_srcpkg.getVersion())
try:
@ -277,6 +282,9 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
ubuntu_version = Version(ubuntu_srcpkg.getVersion())
except udtexceptions.PackageNotFoundException:
ubuntu_version = Version('~')
except udtexceptions.SeriesNotFoundException, e:
Logger.error(str(e))
sys.exit(1)
if ubuntu_version >= version:
# The LP importer is maybe out of date
debian_srcpkg = requestsync_mail_getDebianSrcPkg(package, dist)

View File

@ -389,7 +389,9 @@ class DebianSourcePackage(SourcePackage):
import simplejson as json
except ImportError:
Logger.error("Please install python-simplejson.")
sys.exit(1)
raise DownloadError("Unable to dowload from "
"snapshot.debian.org without "
"python-simplejson")
try:
srcfiles = json.load(urllib2.urlopen(