AttributeError: 'Entry' object has no attribute 'bug_tasks'

Bug #791644 reported by Ricardo Salveti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Svammel (UNMAINTAINED)
Fix Released
Undecided
Ricardo Salveti

Bug Description

INFO:Svammel:Checking for successful builds for package kdeutils version >= 4:4.6.3-1ubuntu1
DEBUG:Svammel:Getting 'Successfully built' builds for source 'kdeutils' from archive 'oneiric'
DEBUG:Svammel:Done getting 'Successfully built' builds for source 'kdeutils'
Traceback (most recent call last):
  File "file-failures.py", line 176, in <module>
    for bug_task in bug.bug_tasks:
  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 673, in __getattr__
    return super(Entry, self).__getattr__(name)
  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 319, in __getattr__
    % (self.__class__.__name__, attr))
AttributeError: 'Entry' object has no attribute 'bug_tasks'

When running svammel with a proper log file, and running with --dryrun it'll raise this exception when trying go to over the bug tasks:
            bug = get_launchpad().load(log_entry.bugtask_url)
            for bug_task in bug.bug_tasks:
                logger.info("Had reason to close the bugtask %s but " \
                                "didn't since dryrun is specified." % \
                                bug_task.web_link)

As the log already points a bug task (e.g. https://api.launchpad.net/1.0/ubuntu/+source/emacs23/+bug/791297), the object will in the end also be a bug task instead of a bug (where you can then iterate over the bug_tasks).

While writing the log:
bug_log.write_entry(LogEntry(spph.package_name, spph.version, fail_platform, bug.bug_tasks[0].self_link).to_string())

So a simple patch should fix this issue, like:
$ bzr diff
=== modified file 'file-failures.py'
--- file-failures.py 2011-04-26 12:57:19 +0000
+++ file-failures.py 2011-06-02 01:55:37 +0000
@@ -172,8 +172,7 @@
             close_bug_by_url(log_entry.bugtask_url, new_status,
                              get_launchpad())
         else:
- bug = get_launchpad().load(log_entry.bugtask_url)
- for bug_task in bug.bug_tasks:
- logger.info("Had reason to close the bugtask %s but " \
+ bug_task = get_launchpad().load(log_entry.bugtask_url)
+ logger.info("Had reason to close the bugtask %s but " \
                                 "didn't since dryrun is specified." % \
                                 bug_task.web_link)

Revision history for this message
Mattias Backman (mabac) wrote : Re: [Bug 791644] [NEW] AttributeError: 'Entry' object has no attribute 'bug_tasks'

On Thu, Jun 2, 2011 at 3:55 AM, Ricardo Salveti <email address hidden> wrote:
> Public bug reported:
>
> INFO:Svammel:Checking for successful builds for package kdeutils version >= 4:4.6.3-1ubuntu1
> DEBUG:Svammel:Getting 'Successfully built' builds for source 'kdeutils' from archive 'oneiric'
> DEBUG:Svammel:Done getting 'Successfully built' builds for source 'kdeutils'
> Traceback (most recent call last):
>  File "file-failures.py", line 176, in <module>
>    for bug_task in bug.bug_tasks:
>  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 673, in __getattr__
>    return super(Entry, self).__getattr__(name)
>  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 319, in __getattr__
>    % (self.__class__.__name__, attr))
> AttributeError: 'Entry' object has no attribute 'bug_tasks'
>
> When running svammel with a proper log file, and running with --dryrun it'll raise this exception when trying go to over the bug tasks:
>            bug = get_launchpad().load(log_entry.bugtask_url)
>            for bug_task in bug.bug_tasks:
>                logger.info("Had reason to close the bugtask %s but " \
>                                "didn't since dryrun is specified." % \
>                                bug_task.web_link)
>
> As the log already points a bug task (e.g.
> https://api.launchpad.net/1.0/ubuntu/+source/emacs23/+bug/791297), the
> object will in the end also be a bug task instead of a bug (where you
> can then iterate over the bug_tasks).

Yes, that's some code that I forgot to change when switching to
logging the bug tasks instead of the bug url:s.

>
> While writing the log:
> bug_log.write_entry(LogEntry(spph.package_name, spph.version, fail_platform, bug.bug_tasks[0].self_link).to_string())
>
> So a simple patch should fix this issue, like:
> $ bzr diff
> === modified file 'file-failures.py'
> --- file-failures.py    2011-04-26 12:57:19 +0000
> +++ file-failures.py    2011-06-02 01:55:37 +0000
> @@ -172,8 +172,7 @@
>             close_bug_by_url(log_entry.bugtask_url, new_status,
>                              get_launchpad())
>         else:
> -            bug = get_launchpad().load(log_entry.bugtask_url)
> -            for bug_task in bug.bug_tasks:
> -                logger.info("Had reason to close the bugtask %s but " \
> +            bug_task = get_launchpad().load(log_entry.bugtask_url)
> +            logger.info("Had reason to close the bugtask %s but " \
>                                 "didn't since dryrun is specified." % \
>                                 bug_task.web_link)

Thanks! That should do the trick. I couldn't run the script against
the qastaging environment atm due to time-outs. If you can verify with
your production bug logs, I'd be happy.
lp:~mabac/svammel/two-small-fixes

Thanks,

Mattias

Mattias Backman (mabac)
Changed in svammel:
assignee: nobody → Ricardo Salveti (rsalveti)
milestone: none → 0.1.2
status: New → Fix Committed
Mattias Backman (mabac)
Changed in svammel:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.