<s> from fabric . api import * <EOL> from fabric import operations <EOL> from fabtools import require <EOL> import fabtools <EOL> import requests <EOL> import os <EOL> PROJ_NAME = os . environ [ "<STR_LIT>" ] . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> VENV_DIR = '<STR_LIT>' . format ( PROJ_NAME ) <EOL> PROJ_DIR = '<STR_LIT>' . format ( PROJ_NAME ) <EOL> def newrelic_deploy ( ) : <EOL> url = "<STR_LIT>" <EOL> data = { "<STR_LIT>" : "<STR_LIT>" } <EOL> headers = { '<STR_LIT>' : os . environ [ '<STR_LIT>' ] } <EOL> requests . post ( url , data = data , headers = headers ) <EOL> @ task <EOL> def deploy ( ) : <EOL> newrelic_deploy ( ) <EOL> with prefix ( '<STR_LIT>' + VENV_DIR + '<STR_LIT>' ) : <EOL> with cd ( PROJ_DIR ) : <EOL> run ( '<STR_LIT>' ) <EOL> fabtools . python . install_requirements ( PROJ_DIR + '<STR_LIT>' ) <EOL> run ( '<STR_LIT>' ) <EOL> with cd ( '<STR_LIT>' ) : <EOL> run ( '<STR_LIT>' ) <EOL> run ( '<STR_LIT>' ) <EOL> restart ( ) <EOL> @ task <EOL> def install_upstart_conf ( ) : <EOL> with cd ( PROJ_DIR ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def start ( ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def stop ( ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def restart ( ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def uninstall ( ) : <EOL> run ( '<STR_LIT>' + PROJ_DIR ) <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def setup ( ) : <EOL> require . python . pip ( ) <EOL> fabtools . python . install ( '<STR_LIT>' , use_sudo = True ) <EOL> fabtools . require . deb . package ( '<STR_LIT>' ) <EOL> install_node ( ) <EOL> run ( '<STR_LIT>' + PROJ_NAME + '<STR_LIT>' ) <EOL> with prefix ( '<STR_LIT>' + VENV_DIR + '<STR_LIT>' ) : <EOL> run ( '<STR_LIT>' + PROJ_NAME ) <EOL> fabtools . python . install_requirements ( PROJ_DIR + '<STR_LIT>' ) <EOL> with cd ( PROJ_DIR ) : <EOL> run ( '<STR_LIT>' ) <EOL> with cd ( '<STR_LIT>' ) : <EOL> run ( '<STR_LIT>' ) <EOL> run ( '<STR_LIT>' ) <EOL> install_upstart_conf ( ) <EOL> install_mongo ( ) <EOL> start ( ) <EOL> @ task <EOL> def install_mongo ( ) : <EOL> with prefix ( '<STR_LIT>' + VENV_DIR + '<STR_LIT>' ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def install_node ( ) : <EOL> fabtools . require . deb . package ( '<STR_LIT>' ) <EOL> @ task <EOL> def migrate_mongoengine ( ) : <EOL> with prefix ( '<STR_LIT>' + VENV_DIR + '<STR_LIT>' ) : <EOL> with cd ( PROJ_DIR ) : <EOL> run ( '<STR_LIT>' ) <EOL> start ( ) <EOL> @ task <EOL> def shell ( ) : <EOL> return operations . open_shell ( ) <EOL> @ task <EOL> def recalculate_streak ( user = None ) : <EOL> with prefix ( '<STR_LIT>' + VENV_DIR + '<STR_LIT>' ) : <EOL> with cd ( PROJ_DIR ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def invalidate_cache ( user = None ) : <EOL> with prefix ( '<STR_LIT>' + VENV_DIR + '<STR_LIT>' ) : <EOL> with cd ( PROJ_DIR ) : <EOL> run ( '<STR_LIT>' ) </s>
