Modify

Opened 13 years ago

Closed 13 years ago

#8985 closed defect (invalid)

fail on fresh install CentoOS 5.6

Reported by: anonymous Owned by: Roberto Longobardi
Priority: normal Component: TestManagerForTracPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Most recent call last:

Traceback (most recent call last):

File "build/bdist.linux-i686/egg/trac/web/main.py", line 511, in _dispatch_request File "build/bdist.linux-i686/egg/trac/web/main.py", line 192, in dispatch File "build/bdist.linux-i686/egg/trac/core.py", line 78, in extensions File "build/bdist.linux-i686/egg/trac/core.py", line 213, in getitem File "build/bdist.linux-i686/egg/trac/core.py", line 119, in maybe_init File "build/bdist.linux-i686/egg/testmanager/api.py", line 88, in init

AttributeError: 'unicode' object has no attribute 'partition'

Attachments (0)

Change History (3)

comment:1 Changed 13 years ago by anonymous

  • api.py

    old new  
    8585                if row[0] == 'default':
    8686                    self.default_outcome = row[1].lower()
    8787                else:
    88                     color = row[0].partition('.')[0]
    89                     outcome = row[0].partition('.')[2].lower()
     88                    color = row[0].split('.',1)[0]
     89                    outcome = row[0].split('.',1)[-1].lower()
    9090                    caption = row[1]
    9191
    9292                    if color not in self.outcomes_by_color:
     
    311311            elif type == 'testplan':
    312312                req.perm.require('TEST_PLAN_ADMIN')
    313313               
    314                 catid = path.rpartition('_TT')[2]
     314                catid = path.split('_TT')[-1]
    315315
    316316                try:
    317317                    # Add the new test plan in the database
     
    345345                        tcIdsList = [tcId]
    346346                   
    347347                    try:
    348                         catid = path.rpartition('_TT')[2]
     348                        #catid = path.rpartition('_TT')[2]
     349                       catid = path.split('_TT')[-1]
    349350                        tcat = TestCatalog(self.env, catid)
    350351                       
    351352                        for tcId in tcIdsList:
    352353                            if tcId is not None and tcId != '':
    353354                                old_pagename = tcId
    354                                 tc_id = tcId.rpartition('_TC')[2]
     355                                #tc_id = tcId.rpartition('_TC')[2]
     356                                tc_id = tcId.split('_TC')[-1]
    355357
    356358                                tc = TestCase(self.env, tc_id, tcId)
    357359                                tc.author = author
     
    375377                        req.redirect(req.href.wiki(pagename))
    376378               
    377379                    # Redirect to test catalog, forcing a page refresh by means of a random request parameter
    378                     req.redirect(req.href.wiki(pagename.rpartition('_TC')[0], random=str(datetime.now(utc).microsecond)))
     380                    #req.redirect(req.href.wiki(pagename.rpartition('_TC')[0], random=str(datetime.now(utc).microsecond)))
     381                    req.redirect(req.href.wiki('_TC'.join(pagename.split('_TC')[:-1]), random=str(datetime.now(utc).microsecond)))
    379382                   
    380383                elif duplicate and duplicate != '':
    381384                    # Duplicate test case
    382                     old_id = tcId.rpartition('_TC')[2]
     385                    #old_id = tcId.rpartition('_TC')[2]
     386                    old_id = tcId.split('_TC')[-1]
    383387                    old_pagename = tcId
    384388                    try:
    385389                        old_tc = TestCase(self.env, old_id, old_pagename)
     
    430434                req.perm.require('TEST_PLAN_ADMIN')
    431435               
    432436                planid = req.args.get('planid')
    433                 catid = path.rpartition('_TT')[2]
     437                #catid = path.rpartition('_TT')[2]
     438                catid = path.split('_TT')[-1]
    434439
    435440                self.env.log.debug("About to delete test plan %s on catalog %s" % (planid, catid))

comment:2 Changed 13 years ago by anonymous

Summary: fail on fresh installfail on fresh install CentoOS 5.6

I hacked up the partition/rpartition stuff with split and rsplit. I doing so there are too many places where the path is being analyzed and where the same bits of code exist over and over. These path functions SHOULD be refactored into the util.py module to reduce chance for bugs like the one in get_enclosing_catalog in model.py

else:
            #cat_id = page_name.rpartition('TT')[0].page_name.rpartition('TT')[2].rpartition('_')[0]
            # XXX THIS LOOKS LIKE A BUG. STRING FROM FIRST rpartition WILL NOT HAVE ATTRIBUTE page_name
            cat_id = page_name.rsplit('TT',1)[0].rsplit('TT',1)[-1].rsplit('_',1)[0]

comment:3 Changed 13 years ago by Roberto Longobardi

Resolution: invalid
Status: newclosed

Hi, I guess the problem is your Python version.

Only versions 2.5+ are supported. See also #4846.

Consider that Python 2.4 is not supported by Trac either.

I'll think about using split instead of partition. In the meantime, you can add the following functions to "utils.py":

def partition(str, ch):

        idx = str.find(ch)

        if idx >= 0:
                return (str[0:idx], ch, str[idx+1:])
        else:
                return (str,'','')

def rpartition(str, ch):

        idx = str.rfind(ch)

        if idx >= 0:
                return (str[0:idx], ch, str[idx+1:])
        else:
                return ('','',str)

And replace every occurrence of their use as follows:

somestring.partition('A') ====> partition(somestring, 'A')
somestring.rpartition('A') ====> rpartition(somestring, 'A')

Ciao, Roberto

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Roberto Longobardi.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.