@@ -258,11 +258,7 @@ def installWordPress(self):
258258 if website .master .package .dataBases > website .master .databases_set .all ().count ():
259259 pass
260260 else :
261- statusFile = open (tempStatusPath , 'w' )
262- statusFile .writelines (
263- "Maximum database limit reached for this website." + " [404]" )
264- statusFile .close ()
265- return 0
261+ raise BaseException ("Maximum database limit reached for this website." )
266262
267263 statusFile = open (tempStatusPath , 'w' )
268264 statusFile .writelines ('Setting up Database,20' )
@@ -283,11 +279,7 @@ def installWordPress(self):
283279 if website .package .dataBases > website .databases_set .all ().count ():
284280 pass
285281 else :
286- statusFile = open (tempStatusPath , 'w' )
287- statusFile .writelines (
288- "Maximum database limit reached for this website." + " [404]" )
289- statusFile .close ()
290- return 0
282+ raise BaseException ("Maximum database limit reached for this website." )
291283
292284 statusFile = open (tempStatusPath , 'w' )
293285 statusFile .writelines ('Setting up Database,20' )
@@ -302,10 +294,7 @@ def installWordPress(self):
302294 ProcessUtilities .executioner (command )
303295
304296 if finalPath .find (".." ) > - 1 :
305- statusFile = open (tempStatusPath , 'w' )
306- statusFile .writelines ("Specified path must be inside virtual host home." + " [404]" )
307- statusFile .close ()
308- return 0
297+ raise BaseException ("Specified path must be inside virtual host home." )
309298
310299 if not os .path .exists (finalPath ):
311300 command = 'mkdir -p ' + finalPath
@@ -361,8 +350,9 @@ def installWordPress(self):
361350
362351 ##
363352
364- command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
365- ProcessUtilities .executioner (command , externalApp )
353+ if home != '0' :
354+ command = "chown " + externalApp + ":" + 'nobody' + " " + finalPath
355+ ProcessUtilities .executioner (command , externalApp )
366356
367357 permPath = '/home/%s/public_html' % (domainName )
368358 command = 'chmod 750 %s' % (permPath )
@@ -381,7 +371,7 @@ def installWordPress(self):
381371 homeDir = "/home/" + domainName + "/public_html"
382372
383373 if not os .path .exists (homeDir ):
384- command = "chown -R " + externalApp + ":" + 'nobody' + " " + homeDir
374+ command = "chown " + externalApp + ":" + 'nobody' + " " + homeDir
385375 ProcessUtilities .executioner (command , externalApp )
386376
387377 try :
@@ -437,11 +427,7 @@ def installPrestaShop(self):
437427 if website .master .package .dataBases > website .master .databases_set .all ().count ():
438428 pass
439429 else :
440- statusFile = open (tempStatusPath , 'w' )
441- statusFile .writelines (
442- "Maximum database limit reached for this website." + " [404]" )
443- statusFile .close ()
444- return 0
430+ raise BaseException ("Maximum database limit reached for this website." )
445431
446432 statusFile = open (tempStatusPath , 'w' )
447433 statusFile .writelines ('Setting up Database,20' )
@@ -462,11 +448,7 @@ def installPrestaShop(self):
462448 if website .package .dataBases > website .databases_set .all ().count ():
463449 pass
464450 else :
465- statusFile = open (tempStatusPath , 'w' )
466- statusFile .writelines (
467- "Maximum database limit reached for this website." + " [404]" )
468- statusFile .close ()
469- return 0
451+ raise BaseException ("Maximum database limit reached for this website." )
470452
471453 statusFile = open (tempStatusPath , 'w' )
472454 statusFile .writelines ('Setting up Database,20' )
@@ -481,9 +463,6 @@ def installPrestaShop(self):
481463 ProcessUtilities .executioner (command )
482464
483465 if finalPath .find (".." ) > - 1 :
484- statusFile = open (tempStatusPath , 'w' )
485- statusFile .writelines ("Specified path must be inside virtual host home." + " [404]" )
486- statusFile .close ()
487466 raise BaseException ('Specified path must be inside virtual host home.' )
488467
489468 if not os .path .exists (finalPath ):
@@ -501,14 +480,14 @@ def installPrestaShop(self):
501480 statusFile .writelines ('Downloading and extracting PrestaShop Core..,30' )
502481 statusFile .close ()
503482
504- command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % (
483+ command = "wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % (
505484 finalPath )
506485 ProcessUtilities .executioner (command , externalApp )
507486
508- command = "sudo unzip -o %sprestashop_1.7.4.2.zip -d " % (finalPath ) + finalPath
487+ command = "unzip -o %sprestashop_1.7.4.2.zip -d " % (finalPath ) + finalPath
509488 ProcessUtilities .executioner (command , externalApp )
510489
511- command = "sudo unzip -o %sprestashop.zip -d " % (finalPath ) + finalPath
490+ command = "unzip -o %sprestashop.zip -d " % (finalPath ) + finalPath
512491 ProcessUtilities .executioner (command , externalApp )
513492
514493 ##
@@ -541,8 +520,9 @@ def installPrestaShop(self):
541520
542521 ##
543522
544- command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
545- ProcessUtilities .executioner (command , externalApp )
523+ if home == '0' :
524+ command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
525+ ProcessUtilities .executioner (command , externalApp )
546526
547527 command = "rm -f prestashop_1.7.4.2.zip"
548528 ProcessUtilities .executioner (command , externalApp )
@@ -610,7 +590,8 @@ def setupGit(self):
610590 statusFile = open (tempStatusPath , 'w' )
611591 statusFile .writelines ('GIT successfully installed,20' )
612592 statusFile .close ()
613- except subprocess .CalledProcessError :
593+
594+ except BaseException as msg :
614595 statusFile = open (tempStatusPath , 'w' )
615596 statusFile .writelines ('Installing GIT..,0' )
616597 statusFile .close ()
@@ -638,9 +619,6 @@ def setupGit(self):
638619 ## Security Check
639620
640621 if finalPath .find (".." ) > - 1 :
641- statusFile = open (tempStatusPath , 'w' )
642- statusFile .writelines ("Specified path must be inside virtual host home." + " [404]" )
643- statusFile .close ()
644622 raise BaseException ('Specified path must be inside virtual host home.' )
645623
646624 permPath = '/home/%s/public_html' % (domainName )
@@ -664,17 +642,11 @@ def setupGit(self):
664642 try :
665643 command = 'git clone --depth 1 --no-single-branch git@' + defaultProvider + '.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
666644 output = ProcessUtilities .outputExecutioner (command , externalApp )
667- if output .find ('Checking out files: 100%' ) == - 1 :
668- statusFile = open (tempStatusPath , 'w' )
669- statusFile .writelines ('%s. [404]' % (output ))
670- statusFile .close ()
671- return 0
672- except subprocess .CalledProcessError as msg :
673- statusFile = open (tempStatusPath , 'w' )
674- statusFile .writelines (
675- 'Failed to clone repository, make sure you deployed your key to repository. [404]' )
676- statusFile .close ()
677- return 0
645+ finalPathGit = '%s/.git' % (finalPath .rstrip ('/' ))
646+ if not os .path .exists (finalPathGit ):
647+ raise BaseException (output )
648+ except BaseException as msg :
649+ raise BaseException ('Failed to clone repository, make sure you deployed your key to repository. Error: %s' % (str (msg )))
678650
679651 ##
680652
@@ -710,6 +682,7 @@ def setupGit(self):
710682 permPath = '/home/%s/public_html' % (domainName )
711683 command = 'chmod 750 %s' % (permPath )
712684 ProcessUtilities .executioner (command )
685+
713686 statusFile = open (tempStatusPath , 'w' )
714687 statusFile .writelines (str (msg ) + " [404]" )
715688 statusFile .close ()
@@ -833,9 +806,6 @@ def installJoomla(self):
833806 command = 'wget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P ' + finalPath
834807 ProcessUtilities .executioner (command , virtualHostUser )
835808 else :
836- statusFile = open (tempStatusPath , 'w' )
837- statusFile .writelines ("File already exists." + " [404]" )
838- statusFile .close ()
839809 raise BaseException ('File already exists.' )
840810
841811 command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath
@@ -1041,11 +1011,7 @@ def installMagento(self):
10411011 if website .master .package .dataBases > website .master .databases_set .all ().count ():
10421012 pass
10431013 else :
1044- statusFile = open (tempStatusPath , 'w' )
1045- statusFile .writelines (
1046- "Maximum database limit reached for this website." + " [404]" )
1047- statusFile .close ()
1048- return 0
1014+ raise BaseException ( "Maximum database limit reached for this website." )
10491015
10501016 statusFile = open (tempStatusPath , 'w' )
10511017 statusFile .writelines ('Setting up Database,20' )
@@ -1066,11 +1032,7 @@ def installMagento(self):
10661032 if website .package .dataBases > website .databases_set .all ().count ():
10671033 pass
10681034 else :
1069- statusFile = open (tempStatusPath , 'w' )
1070- statusFile .writelines (
1071- "Maximum database limit reached for this website." + " [404]" )
1072- statusFile .close ()
1073- return 0
1035+ raise BaseException ( "Maximum database limit reached for this website." )
10741036
10751037 statusFile = open (tempStatusPath , 'w' )
10761038 statusFile .writelines ('Setting up Database,20' )
@@ -1081,10 +1043,7 @@ def installMagento(self):
10811043 ## Security Check
10821044
10831045 if finalPath .find (".." ) > - 1 :
1084- statusFile = open (tempStatusPath , 'w' )
1085- statusFile .writelines ("Specified path must be inside virtual host home." + " [404]" )
1086- statusFile .close ()
1087- return 0
1046+ raise BaseException ( "Specified path must be inside virtual host home." )
10881047
10891048 permPath = '/home/%s/public_html' % (domainName )
10901049 command = 'chmod 755 %s' % (permPath )
@@ -1155,8 +1114,9 @@ def installMagento(self):
11551114
11561115 ##
11571116
1158- command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
1159- ProcessUtilities .executioner (command , externalApp )
1117+ if home != '0' :
1118+ command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
1119+ ProcessUtilities .executioner (command , externalApp )
11601120
11611121 installUtilities .reStartLiteSpeed ()
11621122
0 commit comments