Skip to contentSkip to conversation

upgradehelper.py: Change policy for send emails and fix error passing

PATCH Superseded Aníbal Limón 2 participants 3 messages Jun 12, 2015 – Jun 16, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 9/11 upgradehelper.py: Change policy for send emails and fix error passing

Now send emails almost in all cases this give the maintainer patches and diff to continue work also if the build isn't succesful.

[YOCTO #7489]

---
 upgradehelper.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
upgradehelper.py +10 -9
index b1f075d..d065fba 100755
@@ -346,8 +346,6 @@ class Updater(object):
                 self.git.clean_untracked()
                 return
 
-        status = type(err).__name__
-
         # drop last upgrade from git. It's safer this way if the upgrade has
         # problems and other recipes depend on it. Give the other recipes a
         # chance...
@@ -381,8 +379,14 @@ class Updater(object):
                 "Attached are the patch, license diff (if change) and bitbake log.\n\n" \
                 "Regards,\nThe Upgrade Helper"
 
-            # don't bother maintainer with mail if the recipe is already up to date
-            if status == "UpgradeNotNeededError":
+            # if error only send email when useful infomration for maintainers exist
+            if err and not (isinstance(err, PatchError) or \
+               isinstance(err, ConfigureError) or \
+               isinstance(err, CompilationError) or \
+               isinstance(err, LicenseError)):
+                D( "%s: Don't send email to maintainer because the error was " \
+                   "%s and the information isn't useful, please review it." \
+                    % (self.pn, type(err).__name__))
                 return
 
             if self.maintainer in maintainer_override:
@@ -478,6 +482,7 @@ class Updater(object):
 
         attempted_pkgs = 0
         for self.pn, self.new_ver, self.maintainer in pkgs_to_upgrade:
+            error = None
             self.recipe = None
             attempted_pkgs += 1
             I(" ATTEMPT PACKAGE %d/%d" % (attempted_pkgs, total_pkgs))
@@ -489,10 +494,6 @@ class Updater(object):
                     step()
 
                 I(" %s: Upgrade SUCCESSFUL! Please test!" % self.pn)
-                error = None
-            except UpgradeNotNeededError as e:
-                I(" %s: %s" % (self.pn, e.message))
-                error = e
             except Error as e:
                 E(" %s: %s" % (self.pn, e.message))
                 E(" %s: Upgrade FAILED! Logs and/or file diffs are available in %s" % (self.pn, self.workdir))
@@ -667,7 +668,7 @@ class UniverseUpdater(Updater):
 
     # overriding the base method
     def pkg_upgrade_handler(self, err):
-        super(UniverseUpdater, self).pkg_upgrade_handler(self)
+        super(UniverseUpdater, self).pkg_upgrade_handler(err)
         self.update_history(self.pn, self.new_ver, self.maintainer,
                 self._get_status_msg(err))
 
Signature · 1 line
1.8.4.5
#1 lore raw

Hi Aníbal,

Quoted 37 lines · On Friday 12 June 2015 20:10:45 Aníbal Limón wrote:

Now send emails almost in all cases this give the maintainer patches and diff to continue work also if the build isn't succesful.

[YOCTO #7489]

---
 upgradehelper.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
upgradehelper.py +0 -2
index b1f075d..d065fba 100755
@@ -346,8 +346,6 @@ class Updater(object):
                 self.git.clean_untracked()
                 return
 
-        status = type(err).__name__
-
         # drop last upgrade from git. It's safer this way if the upgrade

has # problems and other recipes depend on it. Give the other recipes a # chance...

upgradehelper.py +0 -0
@@ -381,8 +379,14 @@ class Updater(object):
                 "Attached are the patch, license diff (if change) and

bitbake log.\n\n" \ "Regards,\nThe Upgrade Helper"

- # don't bother maintainer with mail if the recipe is already up
to date - if status == "UpgradeNotNeededError":
+ # if error only send email when useful infomration for
maintainers exist + if err and not (isinstance(err, PatchError)
or \

upgradehelper.py +4 -0
+               isinstance(err, ConfigureError) or \
+               isinstance(err, CompilationError) or \
+               isinstance(err, LicenseError)):
+                D( "%s: Don't send email to maintainer because the error
Quoted 3 lines

was " \ + "%s and the information isn't useful, please
review it." \ + % (self.pn, type(err).__name__))
return

I think a better approach here would be to have the classes of error that are likely to be fixable by the maintainer as inheriting from a particular class (e.g. MaintainerError) and then we can just check for that rather than having to extend this code every time we add a new type of error.

Quoted 10 lines

if self.maintainer in maintainer_override:

upgradehelper.py +1 -0
@@ -478,6 +482,7 @@ class Updater(object):
 
         attempted_pkgs = 0
         for self.pn, self.new_ver, self.maintainer in pkgs_to_upgrade:
+            error = None
             self.recipe = None
             attempted_pkgs += 1
             I(" ATTEMPT PACKAGE %d/%d" % (attempted_pkgs, total_pkgs))

upgradehelper.py class Updater(object): · line 495

Quoted 7 lines
upgradehelper.py +0 -4
@@ -489,10 +494,6 @@ class Updater(object):
                     step()
 
                 I(" %s: Upgrade SUCCESSFUL! Please test!" % self.pn)
-                error = None
-            except UpgradeNotNeededError as e:
-                I(" %s: %s" % (self.pn, e.message))
-                error = e

I'm confused by this. Won't this change result in UpgradeNotNeededError being treated as an actual error? Surely we don't actually want that?

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#2 lore raw

Hi Paul,

Quoted 31 lines · Paul Eggleton

Hi Aníbal,

Quoted 28 lines · On Friday 12 June 2015 20:10:45 Aníbal Limón wrote:

Now send emails almost in all cases this give the maintainer patches and diff to continue work also if the build isn't succesful.

[YOCTO #7489]

---
  upgradehelper.py | 19 ++++++++++---------
  1 file changed, 10 insertions(+), 9 deletions(-)
upgradehelper.py +0 -2
index b1f075d..d065fba 100755
@@ -346,8 +346,6 @@ class Updater(object):
                  self.git.clean_untracked()
                  return
 
-        status = type(err).__name__
-
          # drop last upgrade from git. It's safer this way if the upgrade

has # problems and other recipes depend on it. Give the other recipes a # chance...

upgradehelper.py +0 -0
@@ -381,8 +379,14 @@ class Updater(object):
                  "Attached are the patch, license diff (if change) and

bitbake log.\n\n" \ "Regards,\nThe Upgrade Helper"

Quoted 16 lines
Quoted 9 lines

- # don't bother maintainer with mail if the recipe is already up
to date - if status == "UpgradeNotNeededError":
+ # if error only send email when useful infomration for
maintainers exist + if err and not (isinstance(err, PatchError)
or \

upgradehelper.py +4 -0
+               isinstance(err, ConfigureError) or \
+               isinstance(err, CompilationError) or \
+               isinstance(err, LicenseError)):
+                D( "%s: Don't send email to maintainer because the error
Quoted 3 lines

was " \ + "%s and the information isn't useful, please
review it." \ + % (self.pn, type(err).__name__))
return

I think a better approach here would be to have the classes of error that are likely to be fixable by the maintainer as inheriting from a particular class (e.g. MaintainerError) and then we can just check for that rather than having to extend this code every time we add a new type of error.

I agree, i'll add new class MaintainerError and make Configure/Compilation/Patch/License to extend it.

Quoted 13 lines
Quoted 13 lines

if self.maintainer in maintainer_override:

upgradehelper.py +1 -0
@@ -478,6 +482,7 @@ class Updater(object):
 
          attempted_pkgs = 0
          for self.pn, self.new_ver, self.maintainer in pkgs_to_upgrade:
+            error = None
              self.recipe = None
              attempted_pkgs += 1
              I(" ATTEMPT PACKAGE %d/%d" % (attempted_pkgs, total_pkgs))
@@ -489,10 +494,6 @@ class Updater(object):
                      step()
 
Quoted 7 lines

upgradehelper.py class Updater(object): · line 495

Quoted 5 lines
upgradehelper.py +0 -4
                  I(" %s: Upgrade SUCCESSFUL! Please test!" % self.pn)
-                error = None
-            except UpgradeNotNeededError as e:
-                I(" %s: %s" % (self.pn, e.message))
-                error = e

I'm confused by this. Won't this change result in UpgradeNotNeededError being treated as an actual error? Surely we don't actually want that?

Now UpgradeNotNeededError is handled by new upstream mechanism when load recipes to upgrade printing message about it.

Quoted 4 lines

Cheers,
Paul

Regards,
alimon