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.
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
|
||||
passwords_loaded = False
|
||||
environment_configured = False
|
||||
"""
|
||||
Whether or not passwords have been read from ``fabfile.cfg`` and added to the
|
||||
current environment.
|
||||
Whether or not the environment has been configured via ``fabfile.cfg``.
|
||||
"""
|
||||
|
||||
def load_passwords():
|
||||
|
||||
def configure_environment():
|
||||
"""
|
||||
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
|
||||
if not passwords_loaded:
|
||||
global environment_configured
|
||||
if not environment_configured:
|
||||
if os.path.exists('fabfile.cfg'):
|
||||
parser = SafeConfigParser()
|
||||
if not parser.read('fabfile.cfg'):
|
||||
warn("Config parser failed to read file `fabfile.cfg`")
|
||||
elif parser.has_section('passwords'):
|
||||
for key in parser.options('passwords'):
|
||||
setattr(env, 'password_{0}'.format(key), parser.get('passwords', key))
|
||||
passwords_loaded = True
|
||||
else:
|
||||
if parser.has_section('passwords'):
|
||||
for key in parser.options('passwords'):
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue