build: Handle the exception raises when archive type is unknown
This commit is contained in:
+5
-1
@@ -557,7 +557,11 @@ class Archive:
|
|||||||
'bzip2': ArchiveBzip2,
|
'bzip2': ArchiveBzip2,
|
||||||
'binary': ArchiveBinary}
|
'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):
|
def unpack(self, target_dir, clean_dir=False):
|
||||||
self.archive.unpack(target_dir, clean_dir)
|
self.archive.unpack(target_dir, clean_dir)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- 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
|
# 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
|
# 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):
|
if not util.check_file_hash(self.archiveFile, self.archive.sha1sum):
|
||||||
raise Error, _("unpack: check_file_hash failed")
|
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 "")
|
target_dir = os.path.join(self.pkg_work_dir, self.archive.target or "")
|
||||||
archive.unpack(target_dir, clean_dir)
|
archive.unpack(target_dir, clean_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user