Edgewall Software

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12294 closed enhancement (fixed)

System Information should be a unique list

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.10
Component: general Version:
Severity: normal Keywords: system
Cc: Branch:
Release Notes:

Duplicate entries returned by ISystemInfoProvider implementations are removed from the list returned by Environment.get_systeminfo.

API Changes:

trac.util.get_pkginfo includes the package name in the dictionary it returns.

Internal Changes:


While working on #12287 it occurred that two plugins might add the same package via System Information. The proposed change will make the System Information list unique.

  • trac/env.py

    diff --git a/trac/env.py b/trac/env.py
    index fb08ff6..63cf53b 100644
    a b class Environment(Component, ComponentManager):  
    303303        info = self.systeminfo[:]
    304304        for provider in self.system_info_providers:
    305305            info.extend(provider.get_system_info() or [])
    306         info.sort(key=lambda (name, version): (name != 'Trac', name.lower()))
    307         return info
     306        return sorted(set(info),
     307                      key=lambda (name, ver): (name != 'Trac', name.lower()))
    309309    # ISystemInfoProvider methods

Attachments (0)

Change History (3)

comment:1 by Ryan J Ollos, 5 years ago

Also, I think we should add name to the dictionary returned by trac.util.get_pkginfo, so that a plugin implementation of get_systeminfo can follow the pattern:

    def get_system_info(self):
        import dns
        pkginfo = get_pkginfo(dns)
        yield pkginfo['name'], pkginfo['version']

The change only needs to be made on 1.2dev though.

How about using get_pkginfo everywhere rather than relying on attributes that aren't consistent among packages and could be changed by the package author? For example, for Pillow I could only see to use:

>>> import PIL

However, get_pkginfo(PIL)['version'] seems much simpler. get_pkginfo(PIL).get('version', '') might be even safer.

Related: I'm still unsure of the complexity of the trac_version method that was created by extracting code in [14354/trunk/trac/env.py]. Under which conditions would get_pkginfo(core).get('version') return None for the Trac package?

Last edited 5 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Ryan J Ollos, 5 years ago

API Changes: modified (diff)
Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

In [14405], name attribute added to dictionary returned by get_pkginfo.

Other changes committed to 1.0-stable in [14406,14408:14409], merged to trunk in [14407,14410].

comment:3 by Ryan J Ollos, 5 years ago

API Changes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.