Advertisement
Guest User

Untitled

a guest
May 11th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def checkMySQL():
  2.   cmd = ('mysql --user=%s --password=%s -e "select 1+1;" > /dev/null')% (user, password)
  3.   process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
  4.   process.wait()                                                                                            
  5.   state = process.poll()                                                                                    
  6.                                                                                                    
  7.   if state > 0:
  8.     print "MySQL not running. Exiting status(1)"
  9.     sys.exit(1)
  10.  
  11.   else:
  12.     print "continue..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement