<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , print_function , unicode_literals <EOL> from fabric . operations import local as lrun , run , sudo , put <EOL> from fabric . api import * <EOL> from fabric . colors import green , red , yellow , blue <EOL> from fabric . contrib . console import confirm <EOL> import os <EOL> import requests <EOL> from requests . auth import HTTPBasicAuth <EOL> def local ( ) : <EOL> """<STR_LIT>""" <EOL> env . compose_file = "<STR_LIT>" <EOL> env . project_dir = "<STR_LIT:.>" <EOL> env . run = lrun <EOL> env . cd = lcd <EOL> def production ( ) : <EOL> """<STR_LIT>""" <EOL> env . hosts = [ "<STR_LIT>" ] <EOL> env . port = <NUM_LIT> <EOL> env . user = "<STR_LIT:root>" <EOL> env . compose_file = "<STR_LIT>" <EOL> env . project_dir = "<STR_LIT>" <EOL> env . run = run <EOL> env . cd = cd <EOL> def copy_secrets ( ) : <EOL> """<STR_LIT>""" <EOL> secrets = [ "<STR_LIT>" ] <EOL> for secret in secrets : <EOL> remote_path = "<STR_LIT:/>" . join ( [ env . project_dir , secret ] ) <EOL> print ( blue ( "<STR_LIT>" . format ( <EOL> secret = secret , remote_path = remote_path , host = env . host <EOL> ) ) ) <EOL> put ( secret , remote_path ) <EOL> def rollback ( commit = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> with env . cd ( env . project_dir ) : <EOL> env . run ( "<STR_LIT>" . format ( commit ) ) <EOL> docker_compose ( "<STR_LIT>" ) <EOL> def deploy ( ) : <EOL> """<STR_LIT>""" <EOL> lrun ( "<STR_LIT>" ) <EOL> copy_secrets ( ) <EOL> with env . cd ( env . project_dir ) : <EOL> env . run ( "<STR_LIT>" ) <EOL> build ( ) <EOL> restart ( ) <EOL> def restart ( ) : <EOL> """<STR_LIT>""" <EOL> docker_compose ( "<STR_LIT>" ) <EOL> def build ( cache = True ) : <EOL> """<STR_LIT>""" <EOL> docker_compose ( "<STR_LIT>" if cache else "<STR_LIT>" ) <EOL> def status ( ) : <EOL> """<STR_LIT>""" <EOL> docker_compose ( "<STR_LIT>" ) <EOL> def django_shell ( ) : <EOL> """<STR_LIT>""" <EOL> docker_compose ( "<STR_LIT>" ) <EOL> def migrate_database ( ) : <EOL> """<STR_LIT>""" <EOL> docker_compose ( "<STR_LIT>" ) <EOL> def logs ( service = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> docker_compose ( "<STR_LIT>" if not service else "<STR_LIT>" . format ( service ) ) <EOL> def docker_compose ( command ) : <EOL> """<STR_LIT>""" <EOL> with env . cd ( env . project_dir ) : <EOL> return env . run ( "<STR_LIT>" . format ( file = env . compose_file , command = command ) ) </s>
