[tfs] Allow overriding tf.cmd location
Review Request #7999 — Created Feb. 25, 2016 and submitted
Allow an environment variable to specify location of tf.cmd for rbtools. This will allow tf commands from visual studio 2013+ to work alongside an installation of Team Explorer Everywhere.
Before:
C:\>rbt post -d >>> RBTools 0.8 alpha 0 (dev) >>> Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] >>> Running on Windows-10-10.0.10586 Checking location "%RBT_TF_PATH%\tf.cmd" Caught OSError: [Error 2] The system cannot find the file specified
After:
C:\>rbt post -d >>> RBTools 0.8 alpha 0 (dev) >>> Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] >>> Running on Windows-10-10.0.10586 Checking location C:\Program Files (x86)\TEE-CLC-14.0.2\tf.cmd Using location C:\Program Files (x86)\TEE-CLC-14.0.2\tf.cmd
Description | From | Last Updated |
---|---|---|
These shouldn't be one sentence per line. |
brennie | |
Perhaps this should be exposed as a .reviewboardrc option instead? |
brennie | |
Blank line between these. |
brennie | |
The config in __init__ is from load_config :) We'll also want to use options (also included above) instead, see my … |
brennie | |
I believe we'll want to add an option group to rbtools.commands.Command, similar to perforce_options circa line 435. That way, we … |
brennie | |
tf_locations.extend Otherwise, your array will look like ['my-custom-path', ['tf.cmd', '...']] which is not what you were intending. |
brennie |
- Change Summary:
-
I dug in further and it turns out that variable expansion isn't currently working for win/tfs. Rather than switch check_install to run in the shell, I've added a call to have python expand the variables before checking the installation.
- Testing Done:
-
~ Running "tf" uses tf.exe from the path and running "rbt" will first check for tf.cmd in the specified location before trying the path then the installation locations.
~ Before:
+ + C:\>rbt post -d
+ >>> RBTools 0.8 alpha 0 (dev)
+ >>> Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]
+ >>> Running on Windows-10-10.0.10586
+ Checking location "%RBT_TF_PATH%\tf.cmd"
+ Caught OSError: [Error 2] The system cannot find the file specified
+ + + + + After:
+ + C:\>rbt post -d
+ >>> RBTools 0.8 alpha 0 (dev)
+ >>> Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]
+ >>> Running on Windows-10-10.0.10586
+ Checking location C:\Program Files (x86)\TEE-CLC-14.0.2\tf.cmd
+ Using location C:\Program Files (x86)\TEE-CLC-14.0.2\tf.cmd
+ - Diff:
-
Revision 2 (+5 -2)
-
Tool: PEP8 Style Checker Processed Files: rbtools/clients/tfs.py Tool: Pyflakes Processed Files: rbtools/clients/tfs.py
-
Tool: Pyflakes Processed Files: rbtools/clients/tfs.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/tfs.py
- Change Summary:
-
Switched to pulling the cmd location from config rather than environment variables. Tested with no TF_CMD, one explicitly defining it, and one with an environment variable.
D:\GitHub\rbtools>more %APPDATA%\.reviewboardrc OPEN_BROWSER = True # TF_CMD = 'C:\\Program Files (x86)\\TEE-CLC-14.0.2\\tf.cmd' # TF_CMD = '%programfiles(x86)%\\TEE-CLC-14.0.2\\tf.cmd'
The override should now work across platforms.
- Diff:
-
Revision 4 (+17 -9)
-
Tool: Pyflakes Processed Files: rbtools/clients/tfs.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/tfs.py
-
-
The
config
in__init__
is fromload_config
:)We'll also want to use
options
(also included above) instead, see my notes below. -
I believe we'll want to add an option group to
rbtools.commands.Command
, similar toperforce_options
circa line 435.That way, we can also specify, e.g.
--tf-path
on the command line, and we can get a named options.Then we can do:
if options.tf_cmd_path: tf_locations.append(options.tf_cmd_path)
-
tf_locations.extend
Otherwise, your array will look like
['my-custom-path', ['tf.cmd', '...']]
which is not what you were intending.
- Change Summary:
-
- Use the already loaded config
- Allow command line specification of tf cmd.
Testing
- rbt post -d --tf-cmd "C:\Program Files (x86)\TEE-CLC-14.0.2\tf.cmd"
- Specification in %APPDATA%.reviewboardrc also work (with and without env variables).
-
Tool: Pyflakes Processed Files: rbtools/clients/tfs.py rbtools/commands/__init__.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/tfs.py rbtools/commands/__init__.py