Closed Bug 568726 Opened 15 years ago Closed 13 years ago

Rework exception handling for automation scripts

Categories

(Mozilla QA Graveyard :: Mozmill Automation, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: whimboo, Assigned: whimboo)

References

()

Details

Attachments

(2 files, 2 obsolete files)

We should rework the handling of exceptions in all of the automation scripts.
Component: Mozmill → Mozmill Tests
QA Contact: mozmill → mozmilltests
Summary: [mozmill] Rework exception handling for automation scripts → Rework exception handling for automation scripts
Blocks: 589003
No longer blocks: 589003
Move of Mozmill related project bugs to newly created components. You can filter out those emails by using "Mozmill-Tests-to-MozillaQA" as criteria.
Component: Mozmill Tests → Mozmill Automation
Product: Testing → Mozilla QA
QA Contact: mozmill-tests → mozmill-automation
Whiteboard: [mozmill-automation]
Version: Trunk → unspecified
Depends on: 566314
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Attached patch Fix for BaseException deprecation messages (obsolete) (deleted) — Splinter Review
For the first step let us fix the BaseException deprecation messages, so we can see the real exception messages if something fails.
Attachment #562764 - Flags: review?(dave.hunt)
Comment on attachment 562764 [details] [diff] [review] Fix for BaseException deprecation messages ># HG changeset patch ># Parent 1f4177ac557bd4a95c8a4e87140c1240eaf4fe5b ># User Henrik Skupin <hskupin@mozilla.com> >Bug 568726 - Fix BaseException deprecation messages. r=dhunt > >diff --git a/libs/install.py b/libs/install.py >--- a/libs/install.py >+++ b/libs/install.py >@@ -123,17 +123,17 @@ class Installer(object): > targetFolder = destination + os.path.basename(bundle) > > # If there is an existing installation remove it now > self.uninstall(targetFolder) > print "*** Copying %s to %s" % (bundle, targetFolder) > shutil.copytree(bundle, targetFolder) > > destination = targetFolder >- except Exception, e: >+ except Exception: > if not os.path.exists(targetFolder): > print "*** Failure in copying the application files" > raise e Wouldn't this fail as 'e' is not defined?
Attachment #562764 - Flags: review?(dave.hunt) → review-
Attached patch Patch v2 (obsolete) (deleted) — Splinter Review
Thanks for spotting this. Here the updated version.
Attachment #562764 - Attachment is obsolete: true
Attachment #562912 - Flags: review?(dave.hunt)
Comment on attachment 562912 [details] [diff] [review] Patch v2 >- except IOError, e: >+ except IOError as e: > raise e We can simplify this as just raise if we can to bubble it up
it might be worth raising another bug to change print statements to log calls then we can get error calls when something fails, e.g. > print "*** Failure in copying the application files" could be changed to logger.critical('Failure in copying the application files') just a thought
(In reply to David Burns :automatedtester from comment #5) > Comment on attachment 562912 [details] [diff] [review] [diff] [details] [review] > Patch v2 > > >- except IOError, e: > >+ except IOError as e: > > raise e > > > We can simplify this as just raise if we can to bubble it up Can you be specific please? Can I simply drop the except block before the 'else'? (In reply to David Burns :automatedtester from comment #6) > it might be worth raising another bug to change print statements to log > calls then we can get error calls when something fails, e.g. > > > print "*** Failure in copying the application files" > > could be changed to > > logger.critical('Failure in copying the application files') > > just a thought Yeah. Sounds fine. Please do so.
Comment on attachment 562912 [details] [diff] [review] Patch v2 I noticed in scraper.py that we've used the following: try: # Try to download the signed candidate build MozillaScraper.download(self) except NotFoundException as ex: print str(ex) Is it worth bringing this inline with the other try...except blocks, and change 'ex' to 'e'? r+ me with or without that change, as it's a minor nit/question.
Attachment #562912 - Flags: review?(dave.hunt) → review+
(In reply to Henrik Skupin (:whimboo) from comment #7) > (In reply to David Burns :automatedtester from comment #5) > > Comment on attachment 562912 [details] [diff] [review] [diff] [details] [review] [diff] [details] [review] > > Patch v2 > > > > >- except IOError, e: > > >+ except IOError as e: > > > raise e > > > > > > We can simplify this as just raise if we can to bubble it up > What I was meaning was we can do except IOError: raise The error variable e is not needed since we are just raising the exception up the stack.
Updated patch with all comments addressed. Please have a quick look over it.
Attachment #562912 - Attachment is obsolete: true
Attachment #563165 - Flags: review?(dave.hunt)
Attachment #563165 - Flags: review?(dave.hunt) → review+
Comment on attachment 563165 [details] [diff] [review] Fix for BaseException messages v3 [checked-in] I will work on the remaining code next quarter.
Attachment #563165 - Attachment description: Patch v3 → Fix for BaseException messages v3 [checked-in]
We can't make use of 'as' because it's not supported in Python 2.5. As long as we support platforms with Python 2.5 installed, we also have to support it in our scripts.
Attachment #568351 - Flags: review?(dburns)
Comment on attachment 568351 [details] [diff] [review] Don't use 'as' because it's not supported in Python 2.5 [checked-in] Review of attachment 568351 [details] [diff] [review]: ----------------------------------------------------------------- lgtm
Attachment #568351 - Flags: review?(dburns) → review+
Comment on attachment 568351 [details] [diff] [review] Don't use 'as' because it's not supported in Python 2.5 [checked-in] Landed as: http://hg.mozilla.org/qa/mozmill-automation/rev/68b25ecb16c6
Attachment #568351 - Attachment description: Don't use 'as' because it's not supported in Python 2.5 → Don't use 'as' because it's not supported in Python 2.5 [checked-in]
I think that we are good enough here. Lets call it fixed and get a new bug opened if necessary.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: