Reland "Don't download PESQ and POLQA in the low_bandwidth_audio_test.py script."

This reverts commit bb1222f3adacec0a096451a79c391663e9f22335.

Reason for revert: Fixing

Original change's description:
> Revert "Don't download PESQ and POLQA in the low_bandwidth_audio_test.py script."
> 
> This reverts commit 20196984558b890ee7648d5cc778bc055fdeb5b2.
> 
> Reason for revert: Fails on Mac
> https://build.chromium.org/p/client.webrtc.perf/builders/Mac%2010.11/builds/4070
> 
> Original change's description:
> > Don't download PESQ and POLQA in the low_bandwidth_audio_test.py script.
> > 
> > They should've been downloaded already.
> > 
> > NOTRY=True
> > 
> > Bug: chromium:755660
> > Change-Id: I8ecb355f06026a38bd9377633e2be6c55d7c6452
> > Reviewed-on: https://webrtc-review.googlesource.com/5620
> > Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org>
> > Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
> > Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#20109}
> 
> TBR=kjellander@webrtc.org,phoglund@webrtc.org,ehmaldonado@webrtc.org,oprypin@webrtc.org
> 
> Change-Id: I0cfc1d0b398587a023af528536e7d995c6de1413
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:755660
> Reviewed-on: https://webrtc-review.googlesource.com/5940
> Reviewed-by: Edward Lemur <ehmaldonado@webrtc.org>
> Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20112}

No-Try: true
Bug: chromium:755660
Change-Id: Idbf30003c78c4093afcaf99dc0c5bb3468cdcf6d
Reviewed-on: https://webrtc-review.googlesource.com/5941
Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org>
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20113}
diff --git a/audio/test/low_bandwidth_audio_test.py b/audio/test/low_bandwidth_audio_test.py
index 93da7db..412b267 100755
--- a/audio/test/low_bandwidth_audio_test.py
+++ b/audio/test/low_bandwidth_audio_test.py
@@ -27,6 +27,18 @@
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
 SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
 
+NO_TOOLS_ERROR_MESSAGE = (
+  'Could not find PESQ or POLQA at %s.\n'
+  '\n'
+  'To fix this run:\n'
+  '  python %s %s\n'
+  '\n'
+  'Note that these tools are Google-internal due to licensing, so in order to '
+  'use them you will have to get your own license and manually put them in the '
+  'right location.\n'
+  'See https://cs.chromium.org/chromium/src/third_party/webrtc/tools_webrtc/'
+  'download_tools.py?rcl=bbceb76f540159e2dba0701ac03c514f01624130&l=13')
+
 
 def _LogCommand(command):
   logging.info('Running %r', command)
@@ -55,17 +67,26 @@
     return 'linux'
 
 
-def _DownloadTools():
+def _GetPathToTools():
   tools_dir = os.path.join(SRC_DIR, 'tools_webrtc')
   toolchain_dir = os.path.join(tools_dir, 'audio_quality')
 
-  # Download PESQ and POLQA.
-  download_script = os.path.join(tools_dir, 'download_tools.py')
-  command = [sys.executable, download_script, toolchain_dir]
-  subprocess.check_call(_LogCommand(command))
+  platform = _GetPlatform()
 
-  pesq_path = os.path.join(toolchain_dir, _GetPlatform(), 'pesq')
-  polqa_path = os.path.join(toolchain_dir, _GetPlatform(), 'PolqaOem64')
+  pesq_path = os.path.join(toolchain_dir, platform, 'pesq')
+  if not os.path.isfile(pesq_path):
+    pesq_path = None
+
+  polqa_path = os.path.join(toolchain_dir, platform, 'PolqaOem64')
+  if not os.path.isfile(polqa_path):
+    polqa_path = None
+
+  if (platform != 'mac' and not polqa_path) or not pesq_path:
+    logging.error(NO_TOOLS_ERROR_MESSAGE,
+                  toolchain_dir,
+                  os.path.join(tools_dir, 'download_tools.py'),
+                  toolchain_dir)
+
   return pesq_path, polqa_path
 
 
@@ -140,15 +161,8 @@
   # Analyze audio.
   command = [executable_path, '-q', '-LC', 'NB',
              '-Ref', reference_file, '-Test', degraded_file]
-  try:
-    process = subprocess.Popen(_LogCommand(command),
-                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-  except OSError as e:
-    if e.errno == os.errno.ENOENT:
-      logging.warning('POLQA executable missing, skipping test.')
-      return {}
-    else:
-      raise
+  process = subprocess.Popen(_LogCommand(command),
+                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   out, err = process.communicate()
 
   # Find the scores in stdout of POLQA.
@@ -176,7 +190,9 @@
 
   args = _ParseArgs()
 
-  pesq_path, polqa_path = _DownloadTools()
+  pesq_path, polqa_path = _GetPathToTools()
+  if pesq_path is None:
+    return 1
 
   out_dir = os.path.join(args.build_dir, '..')
   if args.android:
@@ -189,7 +205,7 @@
   # Check if POLQA can run at all, or skip the 48 kHz tests entirely.
   example_path = os.path.join(SRC_DIR, 'resources',
                               'voice_engine', 'audio_tiny48.wav')
-  if _RunPolqa(polqa_path, example_path, example_path):
+  if polqa_path and _RunPolqa(polqa_path, example_path, example_path):
     analyzers.append(Analyzer(_RunPolqa, polqa_path, 48000))
 
   for analyzer in analyzers: