fixed formatting
This commit is contained in:
parent
9055516737
commit
2a3b075516
|
@ -27,7 +27,7 @@ from utils import (file_exists, get, load_driver_conf, parse_bool,
|
|||
put, run, run_sql_script, sudo, FabricException)
|
||||
|
||||
# Loads the driver config file (defaults to driver_config.py)
|
||||
dconf = load_driver_conf()
|
||||
dconf = load_driver_conf() # pylint: disable=invalid-name
|
||||
|
||||
# Fabric settings
|
||||
fabric_output.update({
|
||||
|
@ -108,7 +108,8 @@ def restart_database():
|
|||
# in the container is postgres itself
|
||||
local('docker restart {}'.format(dconf.CONTAINER_NAME))
|
||||
else:
|
||||
sudo('pg_ctl -D {} -w -t 600 restart -m fast'.format(dconf.PG_DATADIR), user=dconf.DB_USER)
|
||||
sudo('pg_ctl -D {} -w -t 600 restart -m fast'.format(
|
||||
dconf.PG_DATADIR), user=dconf.DB_USER)
|
||||
elif dconf.DB_TYPE == 'oracle':
|
||||
run_sql_script('restartOracle.sh')
|
||||
else:
|
||||
|
@ -138,7 +139,7 @@ def create_user():
|
|||
if dconf.DB_TYPE == 'postgres':
|
||||
sql = "CREATE USER {} SUPERUSER PASSWORD '{}';".format(dconf.DB_USER, dconf.DB_PASSWORD)
|
||||
run("PGPASSWORD={} psql -c \\\"{}\\\" -U postgres -h {}".format(
|
||||
dconf.DB_PASSWORD, sql, dconf.DB_USER, dconf.DB_HOST))
|
||||
dconf.DB_PASSWORD, sql, dconf.DB_HOST))
|
||||
elif dconf.DB_TYPE == 'oracle':
|
||||
run_sql_script('createUser.sh', dconf.DB_USER, dconf.DB_PASSWORD)
|
||||
else:
|
||||
|
@ -272,7 +273,7 @@ def save_next_config(next_config, t=None):
|
|||
|
||||
@task
|
||||
def free_cache():
|
||||
if dconf.HOST_CONN != 'docker': # Read-only file system
|
||||
if dconf.HOST_CONN != 'docker': # pylint: disable=not-context-manager
|
||||
with show('everything'), settings(warn_only=True):
|
||||
res = sudo("sync && echo 3 | tee /proc/sys/vm/drop_caches")
|
||||
if res.failed:
|
||||
|
@ -417,7 +418,7 @@ def dump_database():
|
|||
if file_exists(dumpfile):
|
||||
LOG.info('%s already exists ! ', dumpfile)
|
||||
return False
|
||||
else:
|
||||
|
||||
LOG.info('Dump database %s to %s', dconf.DB_NAME, dumpfile)
|
||||
|
||||
if dconf.DB_TYPE == 'oracle':
|
||||
|
|
|
@ -4,14 +4,14 @@ import os
|
|||
from fabric.api import hide, local, settings, task
|
||||
from fabric.api import get as _get, put as _put, run as _run, sudo as _sudo
|
||||
|
||||
dconf = None
|
||||
dconf = None # pylint: disable=invalid-name
|
||||
|
||||
|
||||
def load_driver_conf():
|
||||
# The default config file is 'driver_config.py' but you can use
|
||||
# set the env 'DRIVER_CONFIG' to the path of a different config
|
||||
# file to override it.
|
||||
global dconf
|
||||
global dconf # pylint: disable=global-statement,invalid-name
|
||||
if not dconf:
|
||||
driver_conf = os.environ.get('DRIVER_CONFIG', 'driver_config')
|
||||
if driver_conf.endswith('.py'):
|
||||
|
@ -150,14 +150,14 @@ def run_sql_script(scriptfile, *args):
|
|||
|
||||
@task
|
||||
def file_exists(filename):
|
||||
with settings(warn_only=True), hide('warnings'):
|
||||
with settings(warn_only=True), hide('warnings'): # pylint: disable=not-context-manager
|
||||
res = run('[ -f {} ]'.format(filename))
|
||||
return res.return_code == 0
|
||||
|
||||
|
||||
@task
|
||||
def dir_exists(dirname):
|
||||
with settings(warn_only=True), hide('warnings'):
|
||||
with settings(warn_only=True), hide('warnings'): # pylint: disable=not-context-manager
|
||||
res = run('[ -d {} ]'.format(dirname))
|
||||
return res.return_code == 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue