Modify

Opened 12 years ago

Last modified 5 years ago

#10356 new defect

AttributeError: 'JiraDecoder' object has no attribute 'category'.

Reported by: support@… Owned by:
Priority: high Component: JiraToTracIntegration
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description (last modified by Ryan J Ollos)

Hello thijs,

trying to use JiraToTracIntegration we unfortunately get an error: AttributeError: 'JiraDecoder' object has no attribute 'category'.

We tried the tags and the trunk version.

Do you have any suggestions?

thank you.

Regards

Michael @ support@…

Detailed information:


d:\1\jiratotracintegration\0.11\trunk\bin>d:\opt\python\3.1\python jira2trac
INFO - 2012-09-21 16:20:35,927 - Loading Jira backup file: d:\test\test.xml (0.44 MB)
INFO - 2012-09-21 16:20:35,927 - Processing data...
DEBUG - 2012-09-21 16:20:35,927 - Start element: rss {'version': '0.92'}
DEBUG - 2012-09-21 16:20:35,944 - Character data: '\n'
DEBUG - 2012-09-21 16:20:35,944 - Character data: '    '
DEBUG - 2012-09-21 16:20:35,944 - Start element: channel {}
DEBUG - 2012-09-21 16:20:35,944 - Character data: '\n'
DEBUG - 2012-09-21 16:20:35,944 - Character data: '        '
DEBUG - 2012-09-21 16:20:35,944 - Start element: title {}
DEBUG - 2012-09-21 16:20:35,944 - Character data: 'Systems -- JIRA'
DEBUG - 2012-09-21 16:20:35,944 - Self: <jira2trac.JiraDecoder object at 0x029F15B0>
DEBUG - 2012-09-21 16:20:35,944 - End element: title
Traceback (most recent call last):
  File "jira2trac", line 15, in <module>
    run()
  File "d:\1\jiratotracintegration\0.11\trunk\jira2trac\scripts\__init__.py", line 65, in run
    startup(options)
  File "d:\1\jiratotracintegration\0.11\trunk\jira2trac\scripts\__init__.py", line 84, in startup
    jira.parse_backup_file()
  File "d:\1\jiratotracintegration\0.11\trunk\jira2trac\__init__.py", line 78, in parse_backup_file
    p.Parse(file, 1)
  File "d:\1\jiratotracintegration\0.11\trunk\jira2trac\__init__.py", line 136, in _end_element
    index = len(self.data[self.category]) - 1
AttributeError: 'JiraDecoder' object has no attribute 'category'

Attachments (1)

test.zip (42.5 KB) - added by anonymous 12 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 12 years ago by Ryan J Ollos

Cc: Ryan J Ollos added; anonymous removed

I'm wondering if the replacement self.category -> name would fix the issue.

Do you have a small Jira backup file you could attach to this ticket so that I could experiment with this?

comment:2 Changed 12 years ago by Ryan J Ollos

Description: modified (diff)

Changed 12 years ago by anonymous

Attachment: test.zip added

comment:3 Changed 12 years ago by support@…

Hello rjollos,

thank you for the kind answer. I added a zipped xml-demo file for the jira import. Maybe there is a solution?

thank you again for the help.

Regards

Michael @ support@…

comment:4 Changed 12 years ago by Ryan J Ollos

I haven't forgotten, just give me another day or two and I'll be able to take a look.

comment:5 Changed 12 years ago by Ryan J Ollos

Owner: changed from Thijs Triemstra to Ryan J Ollos
Priority: normalhigh
Status: newassigned

comment:6 Changed 12 years ago by Ryan J Ollos

Status: assignednew

comment:7 Changed 11 years ago by ddt101@…

Hi guys. What is happening with this ticket. We are also getting the same error (using trac from within Bloodhound) and trying to use to the jira2track utility:

$ ./jira2trac
INFO - 2013-07-05 16:29:12,855 - Loading Jira backup file: /c/projects/jira2track/jira_dumps/emodules/eModules.xml (0.03 MB)
INFO - 2013-07-05 16:29:12,855 - Processing data...
DEBUG - 2013-07-05 16:29:12,856 - Start element: rss {'version': '0.92'}
DEBUG - 2013-07-05 16:29:12,856 - Character data: '\n'
DEBUG - 2013-07-05 16:29:12,856 - Character data: '    '
DEBUG - 2013-07-05 16:29:12,856 - Start element: channel {}
DEBUG - 2013-07-05 16:29:12,856 - Character data: '\n'
DEBUG - 2013-07-05 16:29:12,856 - Character data: '        '
DEBUG - 2013-07-05 16:29:12,856 - Start element: title {}
DEBUG - 2013-07-05 16:29:12,857 - Character data: 'Domestic Workstation User Sign-on'
DEBUG - 2013-07-05 16:29:12,857 - End element: title
Traceback (most recent call last):
  File "./jira2trac", line 15, in <module>
    run()
  File "/cygdrive/c/downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/scripts/__init__.py", line 65, in run
    startup(options)
  File "/cygdrive/c/downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/scripts/__init__.py", line 84, in startup
    jira.parse_backup_file()
  File "/cygdrive/c/downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/__init__.py", line 78, in parse_backup_file
    p.Parse(file, 1)
  File "/cygdrive/c/downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/__init__.py", line 135, in _end_element
    index = len(self.data[self.category]) - 1
AttributeError: 'JiraDecoder' object has no attribute 'category'
Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:8 Changed 11 years ago by Jun Omae

It seems that you use RSS xml file. The plugin requires JIRA backup xml files. The files have entity-engine-xml as root node. I confirmed with JIRA v4.3.4.

<?xml version="1.0" encoding="UTF-8"?>
<!--
  (Here is long comments)
-->
<entity-engine-xml>
    <Action id="10000" issue="10100" author="admin" type="comment" body="jjjjjjjjjjjjjjjjjjjjjです。" created="2011-07-08 19:49:05.579" updateauthor="admin" updated="2011-07-08 19:49:05.579"/>
...

comment:9 Changed 11 years ago by anonymous

Yes, we are using the View -> XML file that is produced from Project -> search area. The top tag does say rss as probably JIRA exports same RSS XML for both View -> RSS and View -> XML. We are going this route hoping that would work as we need only few of the project in the entire JIRA instead of all of it. Our JIRA is 5.x, but we'll try the full backup file if the utility only works with that. But I had a brief glance at the python code and there is no 'category' attribute defined in the JiraDecoder object, only 'categories' array. Maybe I'm reading the code wrong, but will it work even if we get the backup file? Also, do we need to have the projects, version and users manually created in Trac/Bloodhound for this utility to work or will it create them automatically when it see a new project id. Unless there is no foreign key constraint in trac to begin with. Thanks again for your help! Much much appreciated!

comment:10 Changed 11 years ago by ddt101@…

Forgot to add my email

comment:11 Changed 11 years ago by ddt101@…

Works better with the backup file as it seem to be indeed quite different but still not working out of the box. 1st fix so far -> line 331 in init.py: From: return datetime.strptime(timestamp[:-2], '%Y-%m-%d %H:%M:%S') To: return datetime.strptime(timestamp[:19], '%Y-%m-%d %H:%M:%S') It was choking since the created time has micro seconds: 'created': '2010-02-04 16:14:26.557', so chomping off the last two, still fails the format string as the %f directive to handle microseconds is missing. Now working on the next problem, will post shortly.

comment:12 Changed 11 years ago by ddt101@…

Another problem seems to be happening for JIRA anonymous users. In this case the Action element does not have the 'author' attribute and fails with:

Traceback (most recent call last):
  File "./jira2trac", line 15, in <module>
    run()
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/scripts/__init__.py", line 65, in run
    startup(options)
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/scripts/__init__.py", line 84, in startup
    jira.parse_backup_file()
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/__init__.py", line 78, in parse_backup_file
    p.Parse(file, 1)
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/__init__.py", line 285, in _start_element
    'author': attrs['author'], 'type': attrs['type']}
KeyError: 'author'
Last edited 11 years ago by Jun Omae (previous) (diff)

comment:13 Changed 11 years ago by ddt101@…

To handle anonymous users I've changed to following code in __init__.py between lines 283 and 300:

        elif name == 'Action':
            action = {'id': attrs['id'], 'issue': attrs['issue'],
                       'type': attrs['type']}

            action['created'] = self.to_datetime(attrs['created'])

            try:
                action['author'] = attrs['author']
            except KeyError:
                action['author'] = 'anonymous'

            try:
                action['body'] = attrs['body']
            except KeyError:
                action['body'] = ''

            self._add_item('actions', action, self.comments)
Last edited 11 years ago by Jun Omae (previous) (diff)

comment:14 Changed 11 years ago by anonymous

No failed on parsing Component elments with key error on description field. Seems that JIRA allows for some components to NOT have a description and the plugin chokes yet again:

DEBUG - 2013-07-10 12:38:15,763 - Start element: Component {'project': '10010', 'assigneetype': '0', 'id': '10000', 'lead': 'rfournier', 'name': 'Monthly Reports'}
Traceback (most recent call last):
  File "./jira2trac", line 15, in <module>
    run()
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/scripts/__init__.py", line 65, in run
    startup(options)
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/scripts/__init__.py", line 84, in startup
    jira.parse_backup_file()
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/__init__.py", line 78, in parse_backup_file
    p.Parse(file, 1)
  File "/cygdrive/c/Downloads/jiratotracintegration-13321/jiratotracintegration/0.11/trunk/jira2trac/__init__.py", line 241, in _start_element
    'name': attrs['name'], 'description': attrs['description'],
KeyError: 'description'

Will add the try/except KeyError clause to handle this as well.

Last edited 11 years ago by Jun Omae (previous) (diff)

comment:15 Changed 11 years ago by ddt101@…

Had to also add handling for anonymous users. I guess our JIRA allowes creation of Components without leads causing a KeyError: 'lead' when it's missing:

        elif name == 'Component':
            component = {'project': attrs['project'], 'id': attrs['id'],
                         'name': attrs['name'], 'owner': attrs['lead']}

            try:
                component['description'] = attrs['description']
            except KeyError:
                component['description'] = ''

            try:
                component['owner'] = attrs['lead']
            except KeyError:
                component['owner'] = 'anonymous'
Last edited 11 years ago by Jun Omae (previous) (diff)

comment:16 Changed 11 years ago by Ryan J Ollos

Status: newaccepted

comment:17 Changed 10 years ago by Ryan J Ollos

Status: acceptednew

Refocusing.

comment:18 Changed 5 years ago by Ryan J Ollos

Cc: Ryan J Ollos removed

comment:19 Changed 5 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.