Skip to content

Commit fbc8639

Browse files
committed
Fix #442 Site create issue
1 parent 3b7db46 commit fbc8639

File tree

1 file changed

+50
-24
lines changed

1 file changed

+50
-24
lines changed

ee/cli/plugins/site_functions.py

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -184,31 +184,35 @@ def setupwordpress(self, data):
184184
Log.debug(self, "Generating wp-config for WordPress Single site")
185185
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
186186
+ "core config "
187-
+ "--dbname={0} --dbprefix={1} --dbuser={2} "
187+
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
188+
"--dbhost=\'{3}\' "
188189
.format(data['ee_db_name'], ee_wp_prefix,
189-
data['ee_db_user'])
190+
data['ee_db_user'], data['ee_db_host'])
190191
+ "--dbpass= "
191192
"--extra-php<<PHP \n {1}\nPHP\""
192193
.format(data['ee_db_pass'],
193194
"\n\ndefine(\'WP_DEBUG\', false);"))
194195
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
195196
+ "core config "
196-
+ "--dbname={0} --dbprefix={1} --dbuser={2} "
197+
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
198+
"--dbuser=\'{2}\' --dbhost=\'{3}\' "
197199
.format(data['ee_db_name'], ee_wp_prefix,
198-
data['ee_db_user'])
199-
+ "--dbpass={0} "
200+
data['ee_db_user'], data['ee_db_host'])
201+
+ "--dbpass=\'{0}\' "
200202
"--extra-php<<PHP \n {1}\nPHP\""
201203
.format(data['ee_db_pass'],
202204
"\n\ndefine(\'WP_DEBUG\', false);"),
203205
log=False
204-
)
206+
) or Log.error(self,
207+
"Unable to Generate "
208+
"wp-config")
205209
else:
206210
Log.debug(self, "Generating wp-config for WordPress multisite")
207211
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
208212
+ "core config "
209-
+ "--dbname={0} --dbprefix={1} "
210-
.format(data['ee_db_name'], ee_wp_prefix)
211-
+ "--dbuser={0} --dbpass= "
213+
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
214+
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
215+
+ "--dbuser=\'{0}\' --dbpass= "
212216
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
213217
.format(data['ee_db_user'], data['ee_db_pass'],
214218
"\ndefine(\'WP_ALLOW_MULTISITE\', "
@@ -218,9 +222,11 @@ def setupwordpress(self, data):
218222
"\n\ndefine(\'WP_DEBUG\', false);"))
219223
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
220224
+ "core config "
221-
+ "--dbname={0} --dbprefix={1} "
222-
.format(data['ee_db_name'], ee_wp_prefix)
223-
+ "--dbuser={0} --dbpass={1} "
225+
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
226+
"--dbhost=\'{2}\' "
227+
.format(data['ee_db_name'], ee_wp_prefix,
228+
data['ee_db_host'])
229+
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
224230
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
225231
.format(data['ee_db_user'], data['ee_db_pass'],
226232
"\ndefine(\'WP_ALLOW_MULTISITE\', "
@@ -229,7 +235,9 @@ def setupwordpress(self, data):
229235
" true);",
230236
"\n\ndefine(\'WP_DEBUG\', false);"),
231237
log=False
232-
)
238+
) or Log.error(self,
239+
"Unable to Generate "
240+
"wp-config")
233241
EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
234242
os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
235243

@@ -257,43 +265,61 @@ def setupwordpress(self, data):
257265
Log.debug(self, "{0}".format(e))
258266
Log.error(self, "Unable to input WordPress user email")
259267

268+
try:
269+
while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
270+
ee_wp_email):
271+
Log.info(self, "EMail not Valid in config, "
272+
"Please provide valid email id")
273+
ee_wp_email = input("Enter your email: ")
274+
except EOFError as e:
275+
Log.debug(self, "{0}".format(e))
276+
Log.error(self, "Unable to input WordPress user email")
277+
260278
Log.debug(self, "Setting up WordPress tables")
261279

262280
if not data['multisite']:
263281
Log.debug(self, "Creating tables for WordPress Single site")
264282
Log.debug(self, "php /usr/bin/wp --allow-root core install "
265-
"--url={0} --title={0} --admin_name={1} "
283+
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
266284
.format(data['www_domain'], ee_wp_user)
267-
+ "--admin_password= --admin_email={1}"
285+
+ "--admin_password= --admin_email=\'{1}\'"
268286
.format(ee_wp_pass, ee_wp_email))
269287
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install "
270-
"--url={0} --title={0} --admin_name={1} "
288+
"--url=\'{0}\' --title=\'{0}\' "
289+
"--admin_name=\'{1}\' "
271290
.format(data['www_domain'], ee_wp_user)
272-
+ "--admin_password={0} --admin_email={1}"
291+
+ "--admin_password=\'{0}\' --admin_email=\'{1}\'"
273292
.format(ee_wp_pass, ee_wp_email),
274293
errormsg="Unable to setup WordPress Tables",
275-
log=False)
294+
log=False) or Log.error(self,
295+
"Unable to setup "
296+
"WordPress Tables")
276297
else:
277298
Log.debug(self, "Creating tables for WordPress multisite")
278299
Log.debug(self, "php /usr/bin/wp --allow-root "
279300
"core multisite-install "
280-
"--url={0} --title={0} --admin_name={1} "
301+
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
281302
.format(data['www_domain'], ee_wp_user)
282-
+ "--admin_password= --admin_email={1} "
303+
+ "--admin_password= --admin_email=\'{1}\' "
283304
"{subdomains}"
284305
.format(ee_wp_pass, ee_wp_email,
285306
subdomains='--subdomains'
286307
if not data['wpsubdir'] else ''))
287308
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root "
288309
"core multisite-install "
289-
"--url={0} --title={0} --admin_name={1} "
310+
"--url=\'{0}\' --title=\'{0}\' "
311+
"--admin_name=\'{1}\' "
290312
.format(data['www_domain'], ee_wp_user)
291-
+ "--admin_password={0} --admin_email={1} "
313+
+ "--admin_password=\'{0}\' "
314+
"--admin_email=\'{1}\' "
292315
"{subdomains}"
293316
.format(ee_wp_pass, ee_wp_email,
294317
subdomains='--subdomains'
295318
if not data['wpsubdir'] else ''),
296-
errormsg="Unable to setup WordPress Tables")
319+
errormsg="Unable to setup WordPress Tables",
320+
log=False) or Log.error(self,
321+
"Unable to setup "
322+
"WordPress Tables")
297323

298324
Log.debug(self, "Updating WordPress permalink")
299325
EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root "
@@ -323,7 +349,7 @@ def setupwordpressnetwork(self, data):
323349
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
324350
Log.info(self, "Setting up WordPress Network \t", end='')
325351
EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
326-
' --title={0} {subdomains}'
352+
' --title=\'{0}\' {subdomains}'
327353
.format(data['www_domain'], subdomains='--subdomains'
328354
if not data['wpsubdir'] else ''))
329355
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

0 commit comments

Comments
 (0)