From e6d6a3bf92c8957cf3b45a83d1c629696b3964a7 Mon Sep 17 00:00:00 2001
From: Ben Patterson <bpatterson@edx.org>
Date: Fri, 1 Aug 2014 16:08:36 -0400
Subject: [PATCH] bok-choy: check mysql the old way.

---
 pavelib/utils/test/bokchoy_utils.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/pavelib/utils/test/bokchoy_utils.py b/pavelib/utils/test/bokchoy_utils.py
index c71c616..c667ffc 100644
--- a/pavelib/utils/test/bokchoy_utils.py
+++ b/pavelib/utils/test/bokchoy_utils.py
@@ -5,7 +5,6 @@ import sys
 import os
 import time
 import httplib
-import subprocess
 from paver.easy import sh
 from pavelib.utils.envs import Env
 from pavelib.utils.process import run_background_process
@@ -126,13 +125,10 @@ def is_mysql_running():
     """
     Returns True if mysql is running, False otherwise.
     """
-    # We need to check whether or not mysql is running as a process
-    # even if it is not daemonized.
-    with open(os.devnull, 'w') as DEVNULL:
-        #pgrep returns the PID, which we send to /dev/null
-        returncode = subprocess.call("pgrep mysqld", stdout=DEVNULL, shell=True)
-    return returncode == 0
-
+    # We use the MySQL CLI client and capture its stderr
+    # If the client cannot connect successfully, stderr will be non-empty
+    output = os.popen('status mysql 2>&1').read()
+    return output.startswith("mysql start/running, process")
 
 def clear_mongo():
     """
--
libgit2 0.26.0