Skip to content

Commit b3297c0

Browse files
author
gau1991
committed
Attempt to Fix #409, Python locale issue
1 parent 1b0b1d5 commit b3297c0

File tree

11 files changed

+174
-90
lines changed

11 files changed

+174
-90
lines changed

ee/cli/plugins/debug.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def debug_nginx(self):
6363
debug_address = ['0.0.0.0/0']
6464
for ip_addr in debug_address:
6565
if not ("debug_connection "+ip_addr in open('/etc/nginx/'
66-
'nginx.conf').read()):
66+
'nginx.conf', encoding='utf-8').read()):
6767
Log.info(self, "Setting up Nginx debug connection"
6868
" for "+ip_addr)
6969
EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ "
@@ -79,7 +79,8 @@ def debug_nginx(self):
7979

8080
# stop global debug
8181
elif not self.start and not self.app.pargs.site_name:
82-
if "debug_connection " in open('/etc/nginx/nginx.conf').read():
82+
if "debug_connection " in open('/etc/nginx/nginx.conf',
83+
encoding='utf-8').read():
8384
Log.info(self, "Disabling Nginx debug connections")
8485
EEShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\""
8586
" /etc/nginx/nginx.conf")
@@ -146,7 +147,8 @@ def debug_php(self):
146147
data = dict(php="9001", debug="9001")
147148
Log.info(self, 'Writting the Nginx debug configration to file '
148149
'/etc/nginx/conf.d/upstream.conf ')
149-
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
150+
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
151+
encoding='utf-8', mode='w')
150152
self.app.render((data), 'upstream.mustache', out=ee_nginx)
151153
ee_nginx.close()
152154
self.trigger_php = True
@@ -165,7 +167,8 @@ def debug_php(self):
165167
data = dict(php="9000", debug="9001")
166168
Log.debug(self, 'Writting the Nginx debug configration to file'
167169
' /etc/nginx/conf.d/upstream.conf ')
168-
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
170+
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
171+
encoding='utf-8', mode='w')
169172
self.app.render((data), 'upstream.mustache', out=ee_nginx)
170173
ee_nginx.close()
171174
self.trigger_php = True
@@ -186,7 +189,8 @@ def debug_fpm(self):
186189
config.remove_option('global', 'include')
187190
config['global']['log_level'] = 'debug'
188191
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
189-
with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile:
192+
with open('/etc/php5/fpm/php-fpm.conf',
193+
encoding='utf-8', mode='w') as configfile:
190194
Log.debug(self, "Writting php5-FPM configuration into "
191195
"/etc/php5/fpm/php-fpm.conf")
192196
config.write(configfile)
@@ -206,7 +210,8 @@ def debug_fpm(self):
206210
config.remove_option('global', 'include')
207211
config['global']['log_level'] = 'notice'
208212
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
209-
with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile:
213+
with open('/etc/php5/fpm/php-fpm.conf',
214+
encoding='utf-8', mode='w') as configfile:
210215
Log.debug(self, "writting php5 configuration into "
211216
"/etc/php5/fpm/php-fpm.conf")
212217
config.write(configfile)
@@ -278,7 +283,7 @@ def debug_wp(self):
278283
" grep true".format(wp_config)):
279284
Log.info(self, "Starting WordPress debug")
280285
open("{0}/htdocs/wp-content/debug.log".format(webroot),
281-
'a').close()
286+
encoding='utf-8', mode='a').close()
282287
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
283288
"content/debug.log"
284289
"".format(webroot,

ee/cli/plugins/site.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def show(self):
152152
.format(ee_domain)):
153153
Log.info(self, "Display NGINX configuration for {0}"
154154
.format(ee_domain))
155-
f = open('/etc/nginx/sites-available/{0}'.format(ee_domain), "r")
155+
f = open('/etc/nginx/sites-available/{0}'.format(ee_domain),
156+
encoding='utf-8', mode='r')
156157
text = f.read()
157158
Log.info(self, Log.ENDC + text)
158159
f.close()
@@ -436,7 +437,7 @@ def default(self):
436437
data = setupdatabase(self, data)
437438
try:
438439
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
439-
'w')
440+
encoding='utf-8', mode='w')
440441
eedbconfig.write("<?php \ndefine('DB_NAME', '{0}');"
441442
"\ndefine('DB_USER', '{1}'); "
442443
"\ndefine('DB_PASSWORD', '{2}');"
@@ -851,7 +852,7 @@ def default(self):
851852
data = setupdatabase(self, data)
852853
try:
853854
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
854-
'w')
855+
encoding='utf-8', mode='w')
855856
eedbconfig.write("<?php \ndefine('DB_NAME', '{0}');"
856857
"\ndefine('DB_USER', '{1}'); "
857858
"\ndefine('DB_PASSWORD', '{2}');"

ee/cli/plugins/site_functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def setupdomain(self, data):
2222
# write nginx config for file
2323
try:
2424
ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}'
25-
.format(ee_domain_name), 'w')
25+
.format(ee_domain_name), encoding='utf-8',
26+
mode='w')
2627

2728
self.app.render((data), 'virtualconf.mustache',
2829
out=ee_site_nginx_conf)

0 commit comments

Comments
 (0)