OSpurge fails on ressources with non-ascii caracters

Bug #1645761 reported by Zarrouk Mohamed
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
ospurge
Fix Released
Undecided
Zarrouk Mohamed

Bug Description

If a ressource has a non-ascii name (chineese name: 华为技术公司), ospurge faills with following traceback (for this example i created a network with the chineese name):
* Resources type: NeutronNetworks
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/zarrouk/ospurge/ospurge/client.py", line 872, in <module>
    main()
  File "/home/zarrouk/ospurge/ospurge/client.py", line 850, in main
    args.insecure, **data)
  File "/home/zarrouk/ospurge/ospurge/client.py", line 662, in perform_on_project
    res_actions[action]()
  File "ospurge/base.py", line 167, in dump
    print(self.resource_str(resource))
  File "/home/zarrouk/ospurge/ospurge/client.py", line 268, in resource_str
    return "network {} (id {})".format(net['name'], net['id'])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

Revision history for this message
Zarrouk Mohamed (zarrouk) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/404286

Changed in ospurge:
assignee: nobody → Zarrouk Mohamed (zarrouk)
status: New → In Progress
Revision history for this message
Jordan Pittier (jordan-pittier) wrote :

Could you attach a complete stack trace please ?

description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ospurge (master)

Reviewed: https://review.openstack.org/404286
Committed: https://git.openstack.org/cgit/openstack/ospurge/commit/?id=712bb2bce5acb01063bc186c304ca0e1b377bd16
Submitter: Jenkins
Branch: master

commit 712bb2bce5acb01063bc186c304ca0e1b377bd16
Author: zarrouk <email address hidden>
Date: Tue Nov 29 16:40:03 2016 +0100

    Use unicode formatting

    The openstack clients return unicode strings as ressource names.
    In python2.7, we need to use unicode encoding when dealing with string
    formatting otherwise it is treated as python2 str and we try to cast
    a unicode string into an str.
    In python 3 prefixing a string with u has no effect and is supported
    and considered as a python3 str which are natively unicode strings.

    Change-Id: Id77ed2f28fd206b900a0e273fece244517e55505
    Closes-Bug: #1645761

Changed in ospurge:
status: In Progress → 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.