#!/usr/bin/env python3 from pathlib import Path from fabric import Connection, config from decouple import config as decouple # Read from env REMOTE_HOST = decouple("REMOTE_HOST", default="localhost") REMOTE_PORT = decouple("REMOTE_PORT", default=22, cast=int) REMOTE_USER = decouple("REMOTE_USER", default="root") REMOTE_SUDO_PASSWORD = decouple("REMOTE_SUDO_PASSWORD") REPO_URL = decouple("REPO_URL", default="example.com") REPO_NAME = str(Path(REPO_URL).name) SITE_NAME = REPO_NAME.split("-")[0] # Set up fabric fabric_config = config.Config(overrides={ "run": { "hide": True }, "sudo": { "password": REMOTE_SUDO_PASSWORD } }) conn_info = f"{REMOTE_USER}@{REMOTE_HOST}:{REMOTE_PORT}" target = Connection(conn_info, config=fabric_config) # Deploy print("[$] Cleaning up...") target.run("rm -rf /tmp/{REPO_NAME}") target.sudo(f"rm -rf /var/www/{SITE_NAME}", pty=True) target.sudo(f"mkdir /var/www/{SITE_NAME}", pty=True)
For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ from decouple import config as decouple import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = decouple('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = decouple('DEBUG', default=True, cast=bool) ALLOWED_HOSTS = ['0.0.0.0', 'localhost'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'api' ]
def config(key, default=undefined, cast=undefined): if DEBUG and default is undefined: default = '' return decouple(key, default=default, cast=cast)
import json from decouple import config as decouple CLIENT_ID = json.loads(open('client_secret.json', 'r').read())['web']['client_id'] GOOGLE_API_KEY = decouple('GOOGLE_API_KEY') FB_APP_ID = decouple('FACEBOOK_APP_ID') FB_GRAPH_URL = "https://graph.facebook.com" FB_PERMISSION_URL = FB_GRAPH_URL + "/%s/permissions" FB_TOKEN_URL = FB_GRAPH_URL + "/oauth/access_token?grant_type=fb_exchange_token&client_id=%s&client_secret=%s&" \ "fb_exchange_token=%s" FB_USER_URL = FB_GRAPH_URL + "/v2.8/me" FB_USER_INFO_URL = FB_USER_URL + "?access_token=%s&fields=name,id,email" FB_USER_PIC_URL = FB_USER_URL + "/picture?access_token=%s&redirect=0&height=200&width=200" MESSAGE_NOT_LOGGED = "You weren't logged in to begin with!" MESSAGE_LOGIN = "******" MESSAGE_LOGOUT = "You have successfully been logged out." SCRIPT_FOR_RESTAURANT = """ <script> function myFunction() { alert( 'You are not authorized to delete this restaurant. Please create your own restaurant in order to delete.' ); } </script> <body onload='myFunction'>" """ LOGIN_OUTPUT = """ <h1>Welcome, %s!</h1>
def megabytes(mb): return mb * (1024 ** 2) def one_or_true(text): return text == '1' or text == 'True' def config(key, default=undefined, cast=undefined): if DEBUG and default is undefined: default = '' return decouple(key, default=default, cast=cast) DEBUG = decouple('DEBUG', default=False, cast=one_or_true) SECRET_KEY = decouple('SECRET_KEY') VERSION = '0.0.1' PROJECT_ROOT = path.abspath(path.join(path.dirname(__file__), '../')) ALLOWED_HOSTS = ['*'] WSGI_APPLICATION = 'devjournal.wsgi.application' ROOT_URLCONF = 'devjournal.urls' LANGUAGE_CODE = 'en-US' USE_I18N = True USE_L10N = True USE_TZ = True STATIC_URL = '/static/'