Skip to content

Commit 03dc173

Browse files
GrahamDumpletonpkubatrh
authored andcommitted
Set defaults for lang/locale and I/O encoding. (sclorg#167)
* Set defaults for lang/locale and I/O encoding. * Fix use of wrong locale. Was AU instead of US.
1 parent b73c524 commit 03dc173

20 files changed

Lines changed: 209 additions & 4 deletions

File tree

2.7/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
77
EXPOSE 8080
88

99
ENV PYTHON_VERSION=2.7 \
10+
PATH=$HOME/.local/bin/:$PATH \
11+
PYTHONIOENCODING=UTF-8 \
12+
LC_ALL=en_US.UTF-8 \
13+
LANG=en_US.UTF-8 \
1014
PIP_NO_CACHE_DIR=off
1115

16+
1217
LABEL io.k8s.description="Platform for building and running Python 2.7 applications" \
1318
io.k8s.display-name="Python 2.7" \
1419
io.openshift.expose-services="8080:http" \

2.7/Dockerfile.rhel7

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ FROM rhscl/s2i-base-rhel7
55
EXPOSE 8080
66

77
ENV PYTHON_VERSION=2.7 \
8+
PATH=$HOME/.local/bin/:$PATH \
9+
PYTHONIOENCODING=UTF-8 \
10+
LC_ALL=en_US.UTF-8 \
11+
LANG=en_US.UTF-8 \
812
PIP_NO_CACHE_DIR=off
913

1014
# Labels consumed by Red Hat build service.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask
2+
gunicorn

2.7/test/locale-test-app/wsgi.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import locale
2+
import os
3+
import sys
4+
5+
from flask import Flask
6+
application = Flask(__name__)
7+
8+
@application.route('/')
9+
def hello():
10+
assert os.environ['PYTHONIOENCODING'] == 'UTF-8'
11+
assert os.environ['LC_ALL'] == 'en_US.UTF-8'
12+
assert os.environ['LANG'] == 'en_US.UTF-8'
13+
14+
assert locale.getdefaultlocale() == ('en_US', 'UTF-8')
15+
assert locale.getpreferredencoding() == 'UTF-8'
16+
17+
print(u'\u292e')
18+
19+
return b'Hello World from locale test application!'
20+
21+
print('-- GLOBAL --')
22+
23+
for k,v in os.environ.items():
24+
print('%r=%r' % (k, v))
25+
26+
print()
27+
28+
print(sys.stdout.encoding)
29+
print(locale.getlocale())
30+
print(locale.getdefaultlocale())
31+
print(locale.getpreferredencoding())
32+
33+
try:
34+
print(u'\u292e')
35+
except Exception as e:
36+
print(e)
37+
38+
print('------------')
39+
40+
if __name__ == '__main__':
41+
application.run()

2.7/test/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
IMAGE_NAME=${IMAGE_NAME:-openshift/python-27-centos7-candidate}
1010

11-
declare -a WEB_APPS=({standalone,setup,django,numpy,app-home,uwsgi}-test-app)
11+
declare -a WEB_APPS=({standalone,setup,django,numpy,app-home,uwsgi,locale}-test-app)
1212

1313
# TODO: Make command compatible for Mac users
1414
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"

3.3/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
77
EXPOSE 8080
88

99
ENV PYTHON_VERSION=3.3 \
10+
PATH=$HOME/.local/bin/:$PATH \
11+
PYTHONIOENCODING=UTF-8 \
12+
LC_ALL=en_US.UTF-8 \
13+
LANG=en_US.UTF-8 \
1014
PIP_NO_CACHE_DIR=off
1115

1216
LABEL io.k8s.description="Platform for building and running Python 3.3 applications" \

3.3/Dockerfile.rhel7

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ FROM openshift/base-rhel7
55
EXPOSE 8080
66

77
ENV PYTHON_VERSION=3.3 \
8+
PATH=$HOME/.local/bin/:$PATH \
9+
PYTHONIOENCODING=UTF-8 \
10+
LC_ALL=en_US.UTF-8 \
11+
LANG=en_US.UTF-8 \
812
PIP_NO_CACHE_DIR=off
913

1014
# Labels consumed by Red Hat build service.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask
2+
gunicorn

3.3/test/locale-test-app/wsgi.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import locale
2+
import os
3+
import sys
4+
5+
from flask import Flask
6+
application = Flask(__name__)
7+
8+
@application.route('/')
9+
def hello():
10+
assert os.environ['PYTHONIOENCODING'] == 'UTF-8'
11+
assert os.environ['LC_ALL'] == 'en_US.UTF-8'
12+
assert os.environ['LANG'] == 'en_US.UTF-8'
13+
14+
assert locale.getdefaultlocale() == ('en_US', 'UTF-8')
15+
assert locale.getpreferredencoding() == 'UTF-8'
16+
17+
print(u'\u292e')
18+
19+
return b'Hello World from locale test application!'
20+
21+
print('-- GLOBAL --')
22+
23+
for k,v in os.environ.items():
24+
print('%r=%r' % (k, v))
25+
26+
print()
27+
28+
print(sys.stdout.encoding)
29+
print(locale.getlocale())
30+
print(locale.getdefaultlocale())
31+
print(locale.getpreferredencoding())
32+
33+
try:
34+
print(u'\u292e')
35+
except Exception as e:
36+
print(e)
37+
38+
print('------------')
39+
40+
if __name__ == '__main__':
41+
application.run()

3.3/test/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
IMAGE_NAME=${IMAGE_NAME:-openshift/python-33-centos7-candidate}
1010

11-
declare -a WEB_APPS=({standalone,setup,django,numpy,app-home,uwsgi}-test-app)
11+
declare -a WEB_APPS=({standalone,setup,django,numpy,app-home,uwsgi,locale}-test-app)
1212

1313
# TODO: Make command compatible for Mac users
1414
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"

0 commit comments

Comments
 (0)