devserver: move scripts to venv.

There's a dependency error in importing google.protobuf.descriptor.
To avoid further troubles, this CL tends to move monitor scripts for
devserver to venv.

BUG=chromium:708890
TEST=Run bin/apache_log_metrics & bin/tail_until_writer_finished.

Change-Id: Ib1b69e12aea1e09c3d2c6a3d41bc796070d9daa0
Reviewed-on: https://chromium-review.googlesource.com/490707
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/bin/find_virtualenv.sh b/bin/find_virtualenv.sh
new file mode 100644
index 0000000..87972d2
--- /dev/null
+++ b/bin/find_virtualenv.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# Copyright 2017 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Find the virtualenv repo to use.
+#
+# This is meant to be sourced in scripts that need virtualenv.  The
+# sourcing script should cd into the directory containing this script
+# first.  This script defines functions for performing common tasks:
+#
+# exec_python_module -- Execute Python module inside of virtualenv
+set -eu
+
+realpath() {
+    readlink -f -- "$1"
+}
+
+readonly venv_repo=$(realpath ../../../../infra_virtualenv)
+readonly create_script=$(realpath "${venv_repo}/bin/create_venv")
+readonly venv_home=$(realpath ../venv)
+readonly reqs_file=$(realpath "${venv_home}/requirements.txt")
+
+exec_python_module() {
+    venvdir=$("${create_script}" "$reqs_file")
+    export PYTHONPATH=${venv_home}
+    exec "${venvdir}/bin/python" -m "$@"
+}