From 5ffee726e0ba082b5eeda3baa7ee2d2a0210cda0 Mon Sep 17 00:00:00 2001 From: Christophe CHAUVET Date: Fri, 23 Dec 2011 19:47:44 +0100 Subject: [PATCH] Add possibility to define FABRICRC environment variable --- docs/usage/fab.rst | 8 +++++++- fabric/state.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/usage/fab.rst b/docs/usage/fab.rst index f929ace129..3bffbf3704 100644 --- a/docs/usage/fab.rst +++ b/docs/usage/fab.rst @@ -400,7 +400,13 @@ will be used to update :doc:`env ` when ``fab`` runs, and is loaded prior to the loading of any fabfile. By default, Fabric looks for ``~/.fabricrc``, and this may be overridden by -specifying the :option:`-c` flag to ``fab``. +specifying the :option:`-c` flag to ``fab``, or define environement variable +``FABRICRC`` with the full pathfilename, eg: + +.. code-block:: + + export FABRICRC=/path/to/rcfile + # see below for content of the file For example, if your typical SSH login username differs from your workstation username, and you don't want to modify ``env.user`` in a project's fabfile diff --git a/fabric/state.py b/fabric/state.py index 069982cb38..15b1341137 100644 --- a/fabric/state.py +++ b/fabric/state.py @@ -94,10 +94,14 @@ def _rc_path(): """ rc_file = '.fabricrc' if not win32: + if 'FABRICRC' in os.environ: + return os.path.expanduser(os.environ['FABRICRC']) return os.path.expanduser("~/" + rc_file) else: from win32com.shell.shell import SHGetSpecialFolderPath from win32com.shell.shellcon import CSIDL_PROFILE + if 'FABRICRC' in os.environ: + return os.environ['FABRICRC'] return "%s/%s" % ( SHGetSpecialFolderPath(0, CSIDL_PROFILE), rc_file @@ -157,7 +161,7 @@ def _rc_path(): help="comma-separated list of hosts to exclude" ), - make_option('-i', + make_option('-i', action='append', dest='key_filename', default=None,