Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:43:57+00:00 2026-06-13T22:43:57+00:00

I have a project that is GUI based. I want to distant it into

  • 0

I have a project that is GUI based. I want to distant it into the code itself and the GUI part.

This is my code:
Main.py:

class NewerVersionWarning(Exception):
    def __init__(self, newest, current=__version__):
        self.newest = newest
        self.current = current
    def __str__(self):
        return "Version v%s is the latest version. You have v%s." % (self.newest, self.current)

class NoResultsException(Exception):
    pass

# ... and so on
def sanity_check():
    "Sanity Check for script."
    try:
        newest_version = WebParser.WebServices.get_newestversion()
        if newest_version > float(__version__):
            raise NewerVersionWarning(newest_version)
    except IOError as e:
        log.error("Could not check for the newest version (%s)" % str(e))

    if utils.get_free_space(config.temp_dir) < 200*1024**2: # 200 MB
        drive = os.path.splitdrive(config.temp_dir)[0]
        raise NoSpaceWarning(drive, utils.get_free_space(config.temp_dir))

# ... and so on

Now, at the GUI part, I just call the function within a try-except block:

    try:
        Main.sanity_check()
    except NoSpaceWarning, e:
        s = tr("There are less than 200MB available in drive %s (%.2fMB left). Application may not function properly.") % (e.drive, e.space/1024.0**2)
        log.warning(s)
        QtGui.QMessageBox.warning(self, tr("Warning"), s, QtGui.QMessageBox.Ok)
    except NewerVersionWarning, e:
        log.warning("A new version of iQuality is available (%s)." % e.newest)
        QtGui.QMessageBox.information(self, tr("Information"), tr("A new version of iQuality is available (%s). Updates includes performance enhancements, bug fixes, new features and fixed parsers.<br /><br />You can grab it from the bottom box of the main window, or from the <a href=\"%s\">iQuality website</a>.") % (e.newest, config.website), QtGui.QMessageBox.Ok)

In the current design, the checks stop at the first warning/exception. Of course, an exception should stop the code, but a warning should only show a message to the user and continue afterwards. How can I design it that way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:43:59+00:00Added an answer on June 13, 2026 at 10:43 pm

    Even though python offers a warning mechanism, I find it easier to do it that way:

    1. Subclass warnings with the Warning class.
    2. Use a _warnings list and append all warnings to it.
    3. return _warnings and handle it at the external code:

      try:
          _warnings = Main.sanity_check()
      except CustomException1, e:
          # handle exception
      except CustomException2, e:
          # handle exception
      
      for w in _warnings:
          if isinstance(w, NoSpaceWarning):
              pass # handle warning
          if isinstance(w, NewerVersionWarning):
              pass # handle warning
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have RCP, and 2 products, based on fetures. I have my.project.gui plugin, that
I have a project that has a GUI (written in QT) and a command-line
Say I have a GUI Java project of something that simulates an ATM machine,
I have a project that I have divided quite aggressively into different layers. I
I'm working on a project that requires GUI, but I have no experience with
Hello I am working on my swing based gui part of my project and
I have a project that may be started on local machine with ./manage.py runserver
I have a project that using some third-party libraries. My questions is how to
I have a project that is displaying 16px text font at 0.5ems links on
I have a project that's been changed and modified in bits and pieces over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.