Replace load_passwords()
with configure_environment()
within fablib
.
Now this adds "settings" as well as passwords to the environment.
This commit is contained in:
parent
a6a42b73f2
commit
05162cc1f4
|
@ -28,4 +28,4 @@ This subpackage contains various tasks and associated functions for use with
|
||||||
Fabric deployment and maintenance.
|
Fabric deployment and maintenance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from rattail.fablib.core import load_passwords, put, upload_template, make_deploy
|
from rattail.fablib.core import configure_environment, put, upload_template, make_deploy
|
||||||
|
|
|
@ -35,27 +35,32 @@ from fabric.utils import warn
|
||||||
from fabric.contrib.files import upload_template as fab_upload_template
|
from fabric.contrib.files import upload_template as fab_upload_template
|
||||||
|
|
||||||
|
|
||||||
passwords_loaded = False
|
environment_configured = False
|
||||||
"""
|
"""
|
||||||
Whether or not passwords have been read from ``fabfile.cfg`` and added to the
|
Whether or not the environment has been configured via ``fabfile.cfg``.
|
||||||
current environment.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def load_passwords():
|
|
||||||
|
def configure_environment():
|
||||||
"""
|
"""
|
||||||
Looks for a ``fabfile.cfg`` file in the current working directory; if
|
Looks for a ``fabfile.cfg`` file in the current working directory; if
|
||||||
present, any passwords it contains will be added to the environment.
|
present, any passwords and settings it contains will be added to the
|
||||||
|
environment.
|
||||||
"""
|
"""
|
||||||
global passwords_loaded
|
global environment_configured
|
||||||
if not passwords_loaded:
|
if not environment_configured:
|
||||||
if os.path.exists('fabfile.cfg'):
|
if os.path.exists('fabfile.cfg'):
|
||||||
parser = SafeConfigParser()
|
parser = SafeConfigParser()
|
||||||
if not parser.read('fabfile.cfg'):
|
if not parser.read('fabfile.cfg'):
|
||||||
warn("Config parser failed to read file `fabfile.cfg`")
|
warn("Config parser failed to read file `fabfile.cfg`")
|
||||||
elif parser.has_section('passwords'):
|
else:
|
||||||
for key in parser.options('passwords'):
|
if parser.has_section('passwords'):
|
||||||
setattr(env, 'password_{0}'.format(key), parser.get('passwords', key))
|
for key in parser.options('passwords'):
|
||||||
passwords_loaded = True
|
setattr(env, 'password_{0}'.format(key), parser.get('passwords', key))
|
||||||
|
if parser.has_section('settings'):
|
||||||
|
for key in parser.options('settings'):
|
||||||
|
setattr(env, 'setting_{0}'.format(key), parser.get('settings', key))
|
||||||
|
environment_configured = True
|
||||||
|
|
||||||
|
|
||||||
def put(local_path, remote_path, owner='root:root', **kwargs):
|
def put(local_path, remote_path, owner='root:root', **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue