Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_environ_parse(content, commands):
content = textwrap.dedent(content)
result = environ.parse(content)
assert result == commands
def _read_env(app_root, env):
files = [e.strip() for e in env.split(',')]
content = []
for envfile in files:
try:
with open(os.path.join(app_root, envfile)) as f:
content.append(f.read())
except IOError:
pass
return environ.parse('\n'.join(content))
def load_env(filename):
manage_dir = os.path.dirname(__file__)
env_file = os.path.join(manage_dir, filename)
env = honcho.environ.parse(open(env_file).read())
for key, value in env.items():
os.environ.setdefault(key, value)
def backup_db():
"""This is designed to be run locally on backup target"""
app_env = honcho.environ.parse(open('.env').read())
db = dj_database_url.parse(app_env['DATABASE_URL'])
with hide('stderr'):
local(DUMP_COMMAND % db)
local("mkdir -p ../db-backups")
local("rdiff-backup --include ./stargeo.sql.gz --exclude '**' . ../db-backups")
local("rdiff-backup --remove-older-than 30B ../db-backups")
local("rm stargeo.sql.gz")