I have created a program that creates a web architecture in a local server then loads the necessary browser to display the html and php pages on localhost.
The os.system
call kills the python process but doesn't kill the other processes -- for example, httpd.exe
and mysqld.exe
The subprocess
call kills the httpd.exe
and mysqld.exe
programs but continues to run the python code, and no code executes after the subprocess
call.
How would i go about killing or hiding all necessary processes after the python code is executed?
Here is my code.
os.makedirs(dr + x + '/admin' + '/css')
dobj = open(dr + x + '/admin' + '/css' + '/style.css', 'w')
dobj.close()
del dobj
os.makedirs(dr + x + '/admin' + '/js')
os.makedirs(dr + x + '/admin' + '/img')
################################################################################
## THE OS SYSTEM CALLS CLOSE THE APP BUT OPEN THE PROCESSES
## AND THE SUBPROCESS CALLS CLOSE BOTH PROCESSES AND LEAVES THE APP OPEN
## CANT WIN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
os.makedirs(dr + x + '/admin' + '/conf')
#os.system(r'C:\\xampp\\apache\\bin\\httpd.exe')
#os.system(r'C:\\xampp\\mysql\\bin\\mysqld.exe')
subprocess.Popen(['C:\\xampp\\apache\\bin\\httpd.exe'], shell=True, creationflags=subprocess.SW_HIDE)
subprocess.Popen(['C:\\xampp\\mysql\\bin\\mysqld.exe'], shell=True, creationflags=subprocess.SW_HIDE)
webbrowser.open('localhost/' + x)
sys.exit()
################################################################################
else:
backmaybe = raw_input('Already Exists... Try Again? (Y/N) ')
if backmaybe == 'y':
start()
else:
sys.exit()