build: Handle the exception raises when archive type is unknown

This commit is contained in:
Fatih Aşıcı
2010-06-15 08:44:58 +00:00
parent c4df178d6a
commit 5d57c0a991
2 changed files with 12 additions and 3 deletions
+5 -1
View File
@@ -557,7 +557,11 @@ class Archive:
'bzip2': ArchiveBzip2,
'binary': ArchiveBinary}
self.archive = handlers.get(arch_type)(file_path, arch_type)
handler = handlers.get(arch_type)
if handler is None:
raise UnknownArchiveType
self.archive = handler(file_path, arch_type)
def unpack(self, target_dir, clean_dir=False):
self.archive.unpack(target_dir, clean_dir)
+7 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005 - 2007, TUBITAK/UEKAE
# Copyright (C) 2005-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -119,6 +119,11 @@ class SourceArchive:
if not util.check_file_hash(self.archiveFile, self.archive.sha1sum):
raise Error, _("unpack: check_file_hash failed")
archive = pisi.archive.Archive(self.archiveFile, self.archive.type)
try:
archive = pisi.archive.Archive(self.archiveFile, self.archive.type)
except pisi.archive.UnknownArchiveType:
raise Error(_("Unknown archive type '%s' is given for '%s'.")
% (self.archive.type, self.url.filename()))
target_dir = os.path.join(self.pkg_work_dir, self.archive.target or "")
archive.unpack(target_dir, clean_dir)