def setenv(): path = Path(os.path.dirname(os.path.abspath(__file__))) file_to_load = Path(os.path.join(path.parent.parent, ".env")) if file_to_load.is_file(): env_file.load(file_to_load) # Now PUBKEY, SUBKEY and PUBNUBID are defined else: # .env not found, assuming anv variable are defined elsewhere pass
def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fool_articles.settings') env_file.load() try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?") from exc execute_from_command_line(sys.argv)
def read(path=None): """return a dictionary with environment variables depending on the current directory""" if not path: path = os.getcwd() result = dict() while os.path.dirname(path) != path: f = os.path.join(path, ".envrc") if os.path.exists(f) or os.path.lexists(f): vars = env_file.load(f) result.update(vars) path = os.path.dirname(path) return result
native = fromstr(wkt, srid=SRID) native.transform(API_SRID) extent = native.extent width = extent[2] - extent[0] native = native.buffer(width * buffer) return tuple(native.extent) ROOT_URL = "" PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) VAR_DIR = '/opt/geotrek-admin/var' TMP_DIR = os.path.join(VAR_DIR, 'tmp') DOT_ENV_FILE = os.path.join(VAR_DIR, 'conf/env') if os.path.exists(DOT_ENV_FILE): env_file.load(path=DOT_ENV_FILE) ALLOWED_HOSTS = os.getenv('SERVER_NAME', 'localhost').split(' ') ALLOWED_HOSTS = ['*' if host == '_' else host for host in ALLOWED_HOSTS] CACHE_ROOT = os.path.join(VAR_DIR, 'cache') TITLE = _("Geotrek") DEBUG = False TEST = 'test' in sys.argv VERSION = __version__ ADMINS = () MANAGERS = ADMINS
"num_of_detected": len(faces), "method": method } except KeyboardInterrupt: sys.exit() except: print("An exception occurred: detect_anomaly_review", sys.exc_info()[0]) return { "num_of_detected": -1, "method": -1 } env_file.load() print(os.environ.get('DETECT_VERSION')) mysql_helper = MysqlHelper() reviewHandler = ReviewDetector() offset = 0 limit = 100 while True: mysql_helper.get_reviews(offset, limit) count = mysql_helper.queryCursor.rowcount if count <= 0 : break offset += limit for (review_id, file_path) in mysql_helper.queryCursor: print("=====================================================================") faces_count = reviewHandler.detect_anomaly_review(file_path)
For more information on this file, see https://docs.djangoproject.com/en/3.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import env_file 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__))) try: d = int(os.environ.get('DEBUG')) except Exception: env_file.load(os.path.join(BASE_DIR, '../.env.dev')) # 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 = os.environ.get('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = int(os.environ.get('DEBUG', default=0)) ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split(' ') # Application definition INSTALLED_APPS = [
Generated by 'django-admin startproject' using Django 3.1.4. For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path import os import dj_database_url import django_heroku import env_file env_file.load('.env') # Build paths inside the project like this: BASE_DIR / 'subdir'. from django.conf.global_settings import DATABASES 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.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.getenv('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.environ.get('DEBUG') ALLOWED_HOSTS = ['*']
""" WSGI config for twitter_feels project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/ """ import os import env_file env_file.load() os.environ.setdefault("DJANGO_SETTINGS_MODULE", "twitter_feels.settings") # https://github.com/kennethreitz/dj-static import dj_static from django.conf import settings from django.contrib.staticfiles.handlers import StaticFilesHandler as DebugHandler class PrefixableDebugHandler(DebugHandler): def get_base_url(self): url = super(PrefixableDebugHandler, self).get_base_url() if url.startswith(settings.SITE_PREFIX): url = url[len(settings.SITE_PREFIX) - 1:] return url def get_response(self, request): if request.path.startswith(settings.SITE_PREFIX): request.path = request.path[len(settings.SITE_PREFIX) - 1:]
framework. """ import os import sys from path import path PROJECT_ROOT = path(__file__).abspath().realpath().dirname().parent.parent sys.path.append(PROJECT_ROOT) # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # if running multiple sites in the same mod_wsgi process. To fix this, use # mod_wsgi daemon mode with each site in its own daemon process, or use # os.environ["DJANGO_SETTINGS_MODULE"] = "jajaja.settings" os.environ['CELERY_LOADER'] = 'django' os.environ.setdefault("DJANGO_SETTINGS_MODULE", "message_coding.settings.production") import env_file env_file.load(PROJECT_ROOT / '.env') # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
#!/usr/bin/env python import env_file import os os.chdir(os.path.dirname(__file__)) env_file.load() env_file.load(".env") env_file.load([".env", "dev.env"]) for var, value in os.environ.items(): print("%s=%s" % (var, value))
os.path.join(BASE_DIR, 'templates'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env") env_file.load(path) SECRET_KEY = "https://www.youtube.com/channel/UCTZUTvv_1Onm-f-533Hyurw" DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': os.getenv('DB_NAME'), 'USER': os.getenv('DB_USER', os.getenv('USER', 'postgres')), 'PASSWORD': os.getenv('DB_PASS', ''), 'HOST': os.getenv('DB_HOST'), 'PORT': os.getenv('DB_PORT', '5432'), } } WSGI_APPLICATION = 'project.wsgi.application'
import os import json import env_file from wit import Wit """ Running command: python build_buckets.py """ """ Load environment variables """ env = env_file.load(".env") AUTH_TOKEN = os.environ.get("AUTH_TOKEN") JSON_FILE = os.environ.get("JSON_FILE") QUOTE_FILE = os.environ.get("QUOTE_FILE") """ Decode intent numbers """ decode = { "intent_0": "none", "intent_1": "anger", "intent_2": "disgust", "intent_3": "fear", "intent_4": "happiness", "intent_5": "sadness", "intent_6": "surprise", } """ Connect to WitAI client """ client = Wit(AUTH_TOKEN)
def main(): LabelEncoder = pp.LabelEncoder() OneHotEncoder = pp.OneHotEncoder(sparse=False) reload_sql_data = 1 if reload_sql_data: print('downloading sql data...', end=' ') env_file.load('../env') conn = pyodbc.connect('DRIVER={};SERVER={};UID={};PWD={}'.format( os.environ['DRIVER'], os.environ['SERVER'], os.environ['DB_USER'], os.environ['DB_PASSWORD'])) cursor = conn.cursor() sql_result = [] cursor.execute("EXEC [KEPServer].[dbo].[ML_Base]") for row in cursor.fetchall(): sql_result.append(row) np.save('data/ML_Base', sql_result, allow_pickle=True) print('done') print('reading data...', end=' ') data = np.load('data/ML_Base.npy', allow_pickle=True) data = data[data[:, 1] < 3600] print('done') print('discarding rows...', end=' ') data = discard_rows_with_few_designation_copies(data, 10) print('done') print('normalizing fields...', end=' ') bcn81, min_bcn81, max_bcn81 = process(data[:, 2].astype('float64')) ord10, min_ord10, max_ord10 = process(data[:, 3].astype('float64')) ird01, min_ird01, max_ird01 = process(data[:, 4].astype('float64')) bcw30, min_bcw30, max_bcw30 = process(data[:, 5].astype('float64')) bcm01, min_bcm01, max_bcm01 = process(data[:, 8].astype('float64')) days_ago_normed, seconds_normed = get_day_and_time_of_day(data[:, 9]) onehot_station, station_categories = get_onehot_encoding( data[:, 10], LabelEncoder, OneHotEncoder) onehot_design, design_categories = get_onehot_encoding( data[:, 6], LabelEncoder, OneHotEncoder) onehot_glapp, glapp_categories = get_onehot_encoding( data[:, 7], LabelEncoder, OneHotEncoder) ct, min_ct, max_ct = process(data[:, 1]) print('done') print('calculating CDF...') CDF = get_cdf_per_designation(data[:, 0]) print('done') print('formatting and saving...', end=' ') source = np.concatenate( (bcn81, ord10, ird01, bcw30, bcm01, days_ago_normed, seconds_normed, onehot_station, onehot_design, onehot_glapp), axis=1) source_valid = source[CDF[:, -1] == 0] source_train = source[CDF[:, -1] == 1] target_valid = ct[CDF[:, -1] == 0] target_train = ct[CDF[:, -1] == 1] helpers = np.array([[min_bcn81, max_bcn81], [min_ord10, max_ord10], [min_ird01, max_ird01], [min_bcw30, max_bcw30], [min_bcm01, max_bcm01], [min_ct, max_ct], [station_categories], [design_categories], [glapp_categories]]) np.save('../app/data/helpers', helpers) np.save('data/source_valid', source_valid) np.save('data/source_train', source_train) np.save('data/target_valid', target_valid) np.save('data/target_train', target_train) print('done')