Puppet sets the locale for running scripts to be "C" which is the Posix default. From Python's getdefaultlocale() method: According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above. which causes getdefaultlocale() to return None. Reproduce: $ export LANG=C $ pulp-admin repo list -u admin -p admin AttributeError: 'NoneType' object has no attribute 'lower' Fix is to check if we got None back and not try to munge the locale if so.
verified [root@preethi ~]# export LANG=C [root@preethi ~]# pulp-admin repo list -u admin -p admin +-------------------------------------------+ List of Available Repositories +-------------------------------------------+ Label f12_i386-5 Name f12 Feed {u'url': u'file:///var/mypackages/', u'type': u'local', u'supported_types': [u'yum', u'local', u'rhn']} Arch i386 Sync Schedule None Packages 0 Files 0 Label local-repo Name f12 Feed {u'url': u'file:///var/mypackages/', u'type': u'local', u'supported_types': [u'yum', u'local', u'rhn']} Arch i386 Sync Schedule None Packages 0 Files 0 Label local-repo-1 Name local Feed {u'url': u'file:///root/rpm-dir/', u'type': u'local', u'supported_types': [u'yum', u'local', u'rhn']} Arch noarch Sync Schedule None Packages 0 Files 0 Label f13 Name f13 Feed {u'url': u'http://download.devel.redhat.com/released/F-13/GOLD/Fedora/x86_64/os/', u'type': u'yum', u'supported_types': [u'yum', u'local', u'rhn']} Arch x86_64 Sync Schedule None Packages 3102 Files 8 Label f12_x86_64 Name f12 Feed {u'url': u'http://download.devel.redhat.com/released/F-12/GOLD/Fedora/x86_64/os/', u'type': u'yum', u'supported_types': [u'yum', u'local', u'rhn']} Arch x86_64 Sync Schedule None Packages 2998 Files 8
Closed after review.
This is happening again, we aren't being defensive if there is no locale set: otice: /Stage[main]//Service[pulp-server]/ensure: ensure changed 'stopped' to 'running' notice: /Stage[main]//Exec[pulp-auth-2]/returns: executed successfully notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: Traceback (most recent call last): notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: File "/usr/bin/pulp-admin", line 170, in <module> notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: admin.main() notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: File "/usr/lib/python2.7/site-packages/pulp/client/cli/base.py", line 135, in main notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: self.setup_server() notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: File "/usr/lib/python2.7/site-packages/pulp/client/cli/base.py", line 107, in setup_server notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: self._server = server.PulpServer(host, int(port), scheme, path) notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: File "/usr/lib/python2.7/site-packages/pulp/client/server.py", line 182, in __init__ notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: default_locale = locale.getdefaultlocale()[0].lower().replace('_', '-') notice: /Stage[main]//Exec[pulp-create-f13-repo]/returns: AttributeError: 'NoneType' object has no attribute 'lower' err: /Stage[main]//Exec[pulp-create-f13-repo]/returns: change from notrun to 0 failed: /usr/bin/pulp-admin repo create --id f13-x86_64 --feed yum:http://mirror.uoregon.edu/fedora/linux/releases/14/Fedora/x86_64/os/ returned 1 instead of one of [0] at /cloud/configure/recipes/aeolus_recipe/manifests/pulp.pp:32 notice: Finished catalog run in 1.76 seconds Note the code in server.py: default_locale = locale.getdefaultlocale()[0].lower().replace('_', '-') this bug was fixed earlier with: + default_locale = locale.getdefaultlocale()[0] + if default_locale: + default_locale = default_locale.lower().replace('_', '-') in sha: b58d871628d77cd290a70ffb6afa3ff2f3a10ab0
Created attachment 494005 [details] patch to resolve issue Patch to resolve the issue
Thanks Mike. After applying patch I am seeing this. Still related to MISSING lang. Traceback (most recent call last): File "/usr/bin/pulp-admin", line 170, in <module> admin.main() File "/usr/lib/python2.7/site-packages/pulp/client/cli/base.py", line 137, in main command.main(args[1:]) File "/usr/lib/python2.7/site-packages/pulp/client/core/base.py", line 118, in main action.main(args[1:]) File "/usr/lib/python2.7/site-packages/pulp/client/core/base.py", line 226, in main self.run() File "/usr/lib/python2.7/site-packages/pulp/client/core/auth.py", line 46, in run cert_dict = self.user_api.admin_certificate() File "/usr/lib/python2.7/site-packages/pulp/client/api/user.py", line 53, in admin_certificate return self.server.GET(path)[1] File "/usr/lib/python2.7/site-packages/pulp/client/server.py", line 291, in GET return self._request('GET', path, queries) File "/usr/lib/python2.7/site-packages/pulp/client/server.py", line 243, in _request connection.request(method, url, body=body, headers=self.headers) File "/usr/lib64/python2.7/httplib.py", line 946, in request self._send_request(method, url, body, headers) File "/usr/lib64/python2.7/httplib.py", line 986, in _send_request self.putheader(hdr, value) File "/usr/lib64/python2.7/httplib.py", line 924, in putheader str = '%s: %s' % (header, '\r\n\t'.join(values)) TypeError: sequence item 0: expected string, NoneType found
Just FYI, I had to add a couple more lines to the patch above to get myself unstuck. Needed to set default_locale to something, or the error in comment 5 would be thrown. default_locale = locale.getdefaultlocale()[0] if default_locale: default_locale = default_locale.lower().replace('_', '-') else: default_locale = "us-en"
Fixed in commit: commit db1a98790221bfb96a3648de4924f508696b6c0b tree 13313e35be78b7426d0093bd212c61ad39b4beda 629718 - adding sane default language encoding src/pulp/client/server.py
build: 0.173
[root@preethi ~]# rpm -q pulp pulp-0.0.173-1.fc14.noarch [root@preethi ~]# export LANG=C [root@preethi ~]# [root@preethi ~]# pulp-admin repo list +------------------------------------------+ List of Available Repositories +------------------------------------------+ Id f13-original Name f13-original Feed URL http://download.devel.redhat.com/released/F-13/GOLD/Fedora/x86_64/os/ Feed Type yum Feed Certs No Consumer Certs No Architecture x86_64 Sync Schedule None Packages 3102 Files 0 Distributions ks-f13-original-x86_64 Publish True Clones [] Groups None Filters [] Notes {}
Closing with Community Release 15 pulp-0.0.223-4.