Bug 675123 - move config.json into virtualenv, a=testonly, DONTBUILD

This commit is contained in:
Jonathan Griffin 2011-08-03 17:23:15 -07:00
Родитель da5f2e8b5b
Коммит 0737ea3b18
5 изменённых файлов: 56 добавлений и 6 удалений

21
testing/tps/INSTALL.sh Normal file → Executable file
Просмотреть файл

@ -55,13 +55,27 @@ fi
# install TPS
cd ${CWD}
python setup.py develop
python setup.py install
if [ "$?" -gt 0 ]
then
exit 1
fi
CONFIG="`find ${VIRTUAL_ENV} -name config.json.in`"
NEWCONFIG=${CONFIG:0:${#CONFIG}-3}
cd "../../services/sync/tests/tps"
TESTDIR="`pwd`"
cd "../../tps"
EXTDIR="`pwd`"
sed 's|__TESTDIR__|'"${TESTDIR}"'|' "${CONFIG}" | sed 's|__EXTENSIONDIR__|'"${EXTDIR}"'|' > "${NEWCONFIG}"
rm ${CONFIG}
echo
echo "***********************************************************************"
echo
echo "To run TPS, activate the virtualenv using:"
echo " source ${TARGET}/${BIN_NAME}"
@ -69,3 +83,8 @@ echo "then execute tps using:"
echo " runtps --binary=/path/to/firefox"
echo
echo "See runtps --help for all options"
echo
echo "To change your TPS config, please edit the file: "
echo "${NEWCONFIG}"
echo
echo "***********************************************************************"

Просмотреть файл

@ -0,0 +1,7 @@
To edit the TPS configuration, do not edit config.json.in in the tree.
Instead, edit config.json inside your virtualenv; it will be located at
something like:
(linux): /path/to/virtualenv/lib/python2.6/site-packages/tps-0.2.40-py2.6.egg/tps/config.json
(win): /path/to/virtualenv/Lib/site-packages/tps-0.2.40-py2.6.egg/tps/config.json

Просмотреть файл

@ -18,6 +18,8 @@
},
"platform": "win32",
"os": "win7",
"es": "localhost:9200"
"es": "localhost:9200",
"testdir": "__TESTDIR__",
"extensiondir": "__EXTENSIONDIR__"
}

Просмотреть файл

@ -58,7 +58,7 @@ setup(name='tps',
keywords='',
author='Jonathan Griffin',
author_email='jgriffin@mozilla.com',
url='http://hg.mozilla.org/services/tps',
url='http://hg.mozilla.org/services/services-central',
license='MPL',
dependency_links = [
"http://people.mozilla.org/~jgriffin/packages/"
@ -72,4 +72,7 @@ setup(name='tps',
[console_scripts]
runtps = tps.cli:main
""",
data_files=[
('tps', ['config/config.json.in']),
],
)

Просмотреть файл

@ -38,6 +38,7 @@
import json
import optparse
import os
import sys
import logging
from threading import RLock
@ -76,7 +77,7 @@ def main():
"will be searched;")
parser.add_option("--configfile",
action = "store", type = "string", dest = "configfile",
default = "config.json",
default = None,
help = "path to the config file to use "
"[default: %default]")
parser.add_option("--pulsefile",
@ -86,15 +87,33 @@ def main():
"json format that you want to inject into the monitor")
(options, args) = parser.parse_args()
configfile = options.configfile
if configfile is None:
if os.environ.get('VIRTUAL_ENV'):
configfile = os.path.join(os.path.dirname(__file__), 'config.json')
else:
raise Exception("Unable to find config.json in a VIRTUAL_ENV; you must "
"specify a config file using the --configfile option")
# load the config file
f = open(options.configfile, 'r')
f = open(configfile, 'r')
configcontent = f.read()
f.close()
config = json.loads(configcontent)
rlock = RLock()
extensionDir = os.path.join(os.getcwd(), "..", "..", "services", "sync", "tps")
extensionDir = config.get("extensiondir")
if not extensionDir or extensionDir == '__EXTENSIONDIR__':
extensionDir = os.path.join(os.getcwd(), "..", "..", "services", "sync", "tps")
else:
if sys.platform == 'win32':
# replace msys-style paths with proper Windows paths
import re
m = re.match('^\/\w\/', extensionDir)
if m:
extensionDir = "%s:/%s" % (m.group(0)[1:2], extensionDir[3:])
extensionDir = extensionDir.replace("/", "\\")
if options.binary is None:
# If no binary is specified, start the pulse build monitor, and wait