~mvo/software-center/fix-977931

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/app.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:
48
48
 
49
49
# db imports
50
50
from softwarecenter.db.application import Application
51
 
from softwarecenter.db import DebFileApplication
 
51
from softwarecenter.db import DebFileApplication, DebFileOpenError
52
52
from softwarecenter.i18n import init_locale
53
53
 
54
54
# misc imports
176
176
            if not request.startswith('/'):
177
177
                # we may have been given a relative path
178
178
                request = os.path.abspath(request)
179
 
            try:
180
 
                app = DebFileApplication(request)
181
 
            except ValueError as e:
182
 
                LOG.error("can not open %s: %s" % (request, e))
183
 
                from softwarecenter.ui.gtk3.dialogs import error
184
 
                error(None,
185
 
                      _("Error"),
186
 
                      _("The file “%s” could not be opened.") % request)
187
 
                app = None
 
179
            app = DebFileApplication(request)
188
180
        else:
189
181
            # package from archive
190
182
            # if there is a "/" in the string consider it as tuple
1333
1325
            If the list of packages is only one element long show that,
1334
1326
            otherwise turn it into a comma seperated search
1335
1327
        """
1336
 
        search_text, app = parse_packages_args(packages)
 
1328
        try:
 
1329
            search_text, app = parse_packages_args(packages)
 
1330
        except DebFileOpenError as e:
 
1331
            LOG.error("can not open %s: %s" % (packages, e))
 
1332
            dialogs.error(None,
 
1333
                          _("Error"),
 
1334
                          _("The file “%s” could not be opened.") % e.path)
 
1335
            search_text = app = None
 
1336
 
1337
1337
        LOG.info('show_available_packages: search_text is %r, app is %r.',
1338
1338
                 search_text, app)
1339
1339