~mvo/software-center/fix-977931

« back to all changes in this revision

Viewing changes to softwarecenter/db/debfile.py

  • Committer: Michael Vogt
  • Date: 2012-05-16 08:03:27 UTC
  • Revision ID: michael.vogt@ubuntu.com-20120516080327-nf2o49lkwxpz58on
add explicit DebFileOpenError and handle this error in app.py with a error dialog

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from softwarecenter.utils import ExecutionTime, utf8
28
28
 
29
29
 
 
30
class DebFileOpenError(Exception):
 
31
    """ Raised if a DebFile fails to open """
 
32
    def __init__(self, msg, path):
 
33
        super(DebFileOpenError, self).__init__(msg)
 
34
        self.path = path
 
35
 
30
36
class DebFileApplication(Application):
31
37
 
32
38
    def __init__(self, debfile):
33
39
        # sanity check
34
40
        if not debfile.endswith(".deb"):
35
 
            raise ValueError("Need a deb file, got '%s'" % debfile)
 
41
            raise DebFileOpenError("Need a deb file, got '%s'" % debfile,
 
42
                                   debfile)
36
43
        # work out debname/appname
37
44
        debname = os.path.splitext(os.path.basename(debfile))[0]
38
45
        pkgname = debname.split('_')[0].lower()
50
57
    def __init__(self, db, doc=None, application=None):
51
58
        super(AppDetailsDebFile, self).__init__(db, doc, application)
52
59
        if doc:
53
 
            raise ValueError("doc must be None for deb files")
 
60
            raise DebFileOpenError("doc must be None for deb files", "")
54
61
 
55
62
        try:
56
63
            with ExecutionTime("create DebPackage"):