def __init__(self, name, product): config = configparser.ConfigParser() config.read('tools.ini') self.settings = config['HANDOFFS'] self.name = name self.product = product self.base_path = os.path.join(os.sep, *self.settings['path'].split('/')) self.image_path = os.path.join(self.base_path, 'src') self.handoff_folder = os.path.join(self.base_path, self.name, self.product) self.localized_folder = os.path.join(self.handoff_folder, 'localized') self.article_registry = os.path.join('cache', self.product, 'localized_articles.json') self.image_registry = os.path.join('cache', self.product, 'localized_images.json') self.locales = self.settings['locales'].split(',') self.vendor_settings = config['VENDOR'] if 'name' in self.vendor_settings: self.vendor_ftp = { 'vendor': self.vendor_settings['name'], 'host': self.vendor_settings['ftp_host'], 'user': self.vendor_settings['ftp_user'], 'password': self.vendor_settings['ftp_password'], 'folder': self.vendor_settings['ftp_folder'] } else: self.vendor_ftp = { 'vendor': yamjam()['VENDOR_NAME'], 'host': yamjam()['VENDOR_FTP_HOST'], 'user': yamjam()['VENDOR_FTP_USER'], 'password': yamjam()['VENDOR_FTP_PASSWORD'], 'folder': yamjam()['VENDOR_FTP_FOLDER'] }
def __init__(self, name, product): config = configparser.ConfigParser() config.read('tools.ini') self.settings = config['HANDOFFS'] self.name = name self.product = product self.base_path = os.path.join(os.sep, *self.settings['path'].split('/')) self.image_path = os.path.join(self.base_path, 'src') self.handoff_folder = os.path.join(self.base_path, self.name, self.product) self.localized_folder = os.path.join(self.handoff_folder, 'localized') self.article_registry = os.path.join('cache', self.product, 'localized_articles.json') self.image_registry = os.path.join('cache', self.product, 'localized_images.json') self.locales = self.settings['locales'].split(',') self.vendor_settings = config['VENDOR'] if 'name' in self.vendor_settings: self.vendor_ftp = {'vendor': self.vendor_settings['name'], 'host': self.vendor_settings['ftp_host'], 'user': self.vendor_settings['ftp_user'], 'password': self.vendor_settings['ftp_password'], 'folder': self.vendor_settings['ftp_folder']} else: self.vendor_ftp = {'vendor': yamjam()['VENDOR_NAME'], 'host': yamjam()['VENDOR_FTP_HOST'], 'user': yamjam()['VENDOR_FTP_USER'], 'password': yamjam()['VENDOR_FTP_PASSWORD'], 'folder': yamjam()['VENDOR_FTP_FOLDER']}
def __init__(self, subdomain): self.subdomain = subdomain self.config = configparser.ConfigParser() self.config.read('tools.ini') self.settings = self.config['ZENDESK'] self.product_cache = os.path.join('cache', self.subdomain) self.root = 'https://{}.zendesk.com/api/v2/'.format(self.subdomain) self.session = requests.Session() self.session.headers = {'Content-Type': 'application/json'} if 'user' in self.settings and 'api_token' in self.settings: self.session.auth = ('{}/token'.format(self.settings['user']), self.settings['api_token']) else: self.session.auth = ('{}/token'.format(yamjam()['ZEN_USER']), yamjam()['ZEN_API_TOKEN'])
def messenger_setup(): page_access_token = yamjam()['pamojaness']['page_access_token'] url = 'https://graph.facebook.com/v2.6/me/messenger_profile?' \ 'access_token=' + page_access_token persistent_menu = [{ "locale": "default", "call_to_actions": [{ "type": "postback", "title": '☱ Menu', "payload": "main_menu" }] }] data = { 'get_started': { 'payload': 'get_started' }, 'whitelisted_domains': [ 'https://acquiro.serveo.net', 'https://pawaness.herokuapp.com', 'https://m.me', 'https://tinyurl.com', 'https://13d6f5ca.ngrok.io' ], 'persistent_menu': persistent_menu } response = requests.post(url, json=data) print(response.json())
def lint_yamjam(argz, plain=False): '''attempt to read configs with yamjam, capturing and humanizing errors''' if plain: prtfn = print else: prtprn = pprint.PrettyPrinter() prtfn = prtprn.pprint for pth in argz.split(';'): if os.path.exists(os.path.expanduser(pth)) == False: print('Warning: %s Not Found.' % pth) else: print('config: %s' % pth) try: cfg = yamjam(pth) except TypeError: print('ERROR: yaml does not evaluate to a dictionary') print_contents(pth, 1) except YAMLError as exc: if hasattr(exc, 'problem_mark'): mark = exc.problem_mark print("Error position: (%s:%s)" % (mark.line + 1, mark.column + 1)) print_contents(pth, 2) else: print("Error in configuration file: %s" % exc) print_contents(pth, 3) prtfn(cfg) print('Confirmed: Valid YAML')
def _load_yaml(section='mysqldump'): """ load the database information from yaml config, :param section: load the specified section in the yaml file. :type section: str :return dict """ try: from YamJam import yamjam dbinfo = yamjam()[section] except (ImportError, KeyError): dbinfo = {} return dbinfo
def get_max_delays_today(): keys = yamjam("keys.yaml") midnight = datetime.datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) top_3_delays = VVSJourney.objects.filter(day_of_operation__gte=midnight).annotate(max_delay=Max('vvsdata__delay')).order_by('-max_delay')[:3] top_3_text = [] for candidate in top_3_delays: top_3_text.append("{}, {}s".format(candidate.vvs_transport.line.line_text, candidate.max_delay)) text = "Top 3 Verspätungen: {}".format(",".join(top_3_text)) auth = tweepy.OAuthHandler(keys['twitter']['sbahn']['consumer_key'], keys['twitter']['sbahn']['consumer_secret']) auth.set_access_token(keys['twitter']['sbahn']['access_token'], keys['twitter']['sbahn']['access_token_secret']) api = tweepy.API(auth) try: api.update_status(text) except tweepy.error.TweepError as e: print(e)
def send_alert(alerts): try: alert_string = "" for house, val in alerts.iteritems(): alert_string += "<b>" + house + "</b>" + "<br>" name = val.pop('name') alert_string += "<b>" + name + "</b>" + "<br>" for type, values in val.iteritems(): alert_string += "<b>" + type + "</b>" + "<br>" for astro, values2 in values.iteritems(): alert_string += values2 + "<br>" alert_string += "Visit " + TELESCOPE_URL + " for detailed information." user = yamjam()['keeper_user'] m = Mailer(user) m.send_mail("Lense Alert", alert_string, ['*****@*****.**']) except Exception as e: logger.error("Exception in sending alert" + str(e))
from collections import OrderedDict from constants import MASTER_SERVER_URL, MASTER_SERVER_PORT, TIME_FORMAT, QUICK_INTERRUPT_THRESHOLD, GRAYLOG_SERVER_URL, \ LAST_UPDATED, GRAYLOG_SEARCH_ABSOLUTE, PINS, MAX_STATUS_COUNT, DYFO_TIME_FORMAT_INPUT, MAX_HEALTHCHECK_COUNT, \ ASTRO_STATS_STREAM_ID, AUTHORIZATION_URL from RequestEndPoint.request_util import RestCall from YamJam import yamjam from models import Configs import datetime from constants import DATA_DISPLAY_RANGE, PI, GET_PIN_STATUS import pytz from models import House from rest_framework import status from dyfo_auth.Auth import Auth from Telescope.settings import logger drona_user = yamjam()['drona_user'] rest_call = RestCall(user_auth=drona_user) graylog_rest_call = RestCall(user_auth={ 'user': '******', 'pass': '******' }) def convert_to_standard_datetime(time): from_zone = tz.tzutc() to_zone = tz.tzlocal() utc = dt.strptime(time, '%Y-%m-%dT%H:%M:%S.%fZ') utc = utc.replace(tzinfo=from_zone) central = utc.astimezone(to_zone) return central.strftime(TIME_FORMAT)
import os import dj_database_url from .base import * from YamJam import yamjam print('settings: development ') CFG = yamjam()['essy'] SECRET_KEY = CFG['django_secret_key'] DEBUG = True DATABASES = { 'sqlite': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': CFG['local_psql']['database_name'], 'USER': CFG['local_psql']['user']['name'], 'PASSWORD': CFG['local_psql']['user']['pass'], 'PORT': '5432', 'HOST': '127.0.0.1' }, 'heroku': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': CFG['heroku_psql']['database_name'], 'USER': CFG['heroku_psql']['user']['name'], 'PASSWORD': CFG['heroku_psql']['user']['pass'],
""" Django settings for BrewSite project. For more information on this file, see https://docs.djangoproject.com/en/1.6/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.6/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from YamJam import yamjam BASE_DIR = os.path.dirname(os.path.dirname(__file__)) CFG = yamjam()['PyBrew'] # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = CFG['DjangoSecret'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = []
from YamJam import yamjam CFG = yamjam('etc/adminpanel/config.yaml')
def get_json(args): request_json = requests.get('http://m.vvs.de/VELOC') json = request_json.json() keys = yamjam("keys.yaml") auth = tweepy.OAuthHandler(keys['twitter']['rbahn']['consumer_key'], keys['twitter']['rbahn']['consumer_secret']) auth.set_access_token(keys['twitter']['rbahn']['access_token'], keys['twitter']['rbahn']['access_token_secret']) api_rbahn = tweepy.API(auth) auth = tweepy.OAuthHandler(keys['twitter']['sbahn']['consumer_key'], keys['twitter']['sbahn']['consumer_secret']) auth.set_access_token(keys['twitter']['sbahn']['access_token'], keys['twitter']['sbahn']['access_token_secret']) api_sbahn = tweepy.API(auth) auth = tweepy.OAuthHandler(keys['twitter']['ubahn']['consumer_key'], keys['twitter']['ubahn']['consumer_secret']) auth.set_access_token(keys['twitter']['ubahn']['access_token'], keys['twitter']['ubahn']['access_token_secret']) api_ubahn = tweepy.API(auth) auth = tweepy.OAuthHandler(keys['twitter']['bus']['consumer_key'], keys['twitter']['bus']['consumer_secret']) auth.set_access_token(keys['twitter']['bus']['access_token'], keys['twitter']['bus']['access_token_secret']) api_bus = tweepy.API(auth) redis_connection = redis.StrictRedis(host='localhost', port=6379, db=1) for entry in json: timestamp_before = unix_timestamp_to_datetime(entry.get("TimestampBefore")[6:16]) day_of_operation = unix_timestamp_to_datetime(entry.get("DayOfOperation")[6:16]) timestamp = unix_timestamp_to_datetime(entry.get("Timestamp")[6:16]) vvs_id = entry.get("ID") line_text = entry.get("LineText") longitude = entry.get("Longitude") longitude_before = entry.get("LongitudeBefore", "0") latitude = entry.get("Latitude") latitude_before = entry.get("LatitudeBefore", "0") if latitude_before is None: latitude_before = 0 if longitude_before is None: longitude_before = 0 is_at_stop = entry.get("IsAtStop") journey_id = entry.get("JourneyIdentifier") delay = entry.get("Delay") product_id = entry.get("ProductIdentifier") mod_code = entry.get("ModCode") real_time_available = entry.get("RealtimeAvailable") operator = entry.get("Operator") try: direction, created = Direction.objects.get_or_create(name=entry.get("DirectionText").encode('iso-8859-1').decode('utf-8')) except IntegrityError: pass try: current_stop, created = Stop.objects.get_or_create(vvs_id=entry.get("CurrentStop").split("#")[0]) except IntegrityError: pass try: if entry.get("NextStop").split("#")[0]: next_stop, created = Stop.objects.get_or_create(vvs_id=entry.get("NextStop").split("#")[0]) else: next_stop = current_stop except IntegrityError: pass try: line, created = Line.objects.get_or_create(line_text=line_text) except IntegrityError: pass if not is_at_stop: is_at_stop = False else: is_at_stop = True transport, created = VVSTransport.objects.get_or_create(line=line, direction=direction, journey_id=journey_id, operator=operator, mod_code=mod_code, product_id=product_id) journey, created = VVSJourney.objects.get_or_create(vvs_transport=transport, day_of_operation=day_of_operation, vvs_id=vvs_id) if journey.vvs_id not in cache and delay >= 10*60: print(journey.vvs_id) time_string = str(datetime.timedelta(seconds=delay)) text = "{} Richtung {} mit der nächsten Haltestelle {} hat {} Verspätung".format(line.line_text, direction.name, next_stop.name, str(time_string)) json_text ="{{\"delay\":\"{}\", \"line\":\"{}\",\"direction\":\"{}\",\"next_stop\":\"{}\"}}".format(str(time_string), line.line_text, direction.name, next_stop.name) print(json_text) if not redis_connection.exists(journey.vvs_id): redis_connection.set(journey.vvs_id, json_text, 60*60) keys = redis_connection.keys("*") print("redis") if len(keys) > 20: time_to_live = [] for key in keys: time_to_live.append((key, redis_connection.ttl(key))) sorted(time_to_live, key=itemgetter(1)) print(time_to_live) to_delete = time_to_live[0:len(time_to_live)-20] for key in to_delete: redis_connection.delete(key) cache.set(journey.vvs_id, delay, 60*60) # 60 Minute timeout if mod_code == MOD_RBAHN: api = api_rbahn elif mod_code == MOD_SBAHN: api = api_sbahn elif mod_code == MOD_UBAHN: api = api_ubahn elif mod_code == MOD_BUS: api = api_bus try: api.update_status(text) except tweepy.error.TweepError as e: print(e) print("{} Richtung {} mit der nächsten Haltestelle {} hat {}s Verspätung".format(line.line_text, direction.name, next_stop.name, str(time_string))) if delay == 0 and journey.vvs_id in cache: cache.delete(journey.vvs_id) VVSData.objects.create(vvs_journey=journey, timestamp=timestamp, timestamp_before=timestamp_before, coordinates_before=Point(float(longitude_before), float(latitude_before)), coordinates=Point(float(longitude), float(latitude)), delay=delay, current_stop=current_stop, next_stop=next_stop, real_time_available=real_time_available, is_at_stop=is_at_stop)
from apiclient.discovery import build from apiclient.errors import HttpError from YamJam import yamjam # for managing secret keys from datetime import datetime parser = argparse.ArgumentParser(description='Download comments from youtube') parser.add_argument( '--videoId', type=str, help='url of the video after v=') args = parser.parse_args() # Set DEVELOPER_KEY to the API key value from the APIs & auth > Registered apps # tab of # https://cloud.google.com/console # Please ensure that you have enabled the YouTube Data API for your project. DEVELOPER_KEY = yamjam()['yt_comments']['YOUTUBE_KEY'] YOUTUBE_API_SERVICE_NAME = "youtube" YOUTUBE_API_VERSION = "v3" YOUTUBE_URL_PREFIX = 'https://www.youtube.com/watch?v=' youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY) _MAX_RESULTS_PER_QUERY = 100 def get_comment_threads(kwagrs): ''' Returns list of comment threads For list of kwargs visit
""" Django settings for the dj project. For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from YamJam import yamjam from django.urls import reverse_lazy parms = yamjam()['dj'] LOGIN_URL = reverse_lazy('login') LOGIN_REDIRECT_URL = reverse_lazy('home') BASE_DIR = os.path.dirname(os.path.dirname(__file__)) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug',
For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from YamJam import yamjam BASE_DIR = os.path.dirname(os.path.dirname(__file__)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! keys = yamjam("keys.yaml") SECRET_KEY = keys['django_secret_key'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth',
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # for yamjam working properly on server cur_user = os.getenv('USER') ROOT_DIR = os.path.expanduser('~/') if '10khourslru' in cur_user: ROOT_DIR = os.path.dirname(os.path.dirname(ROOT_DIR)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = yamjam(os.path.join( ROOT_DIR, '.yamjam/config.yaml'))['hours']['DJANGO_SECRET_KEY'] GOOGLE_OAUTH2_CLIENT_ID = yamjam(os.path.join( ROOT_DIR, '.yamjam/config.yaml'))['hours']['GOOGLE_CLIENT_ID'] GOOGLE_OAUTH2_CLIENT_SECRET = yamjam( os.path.join(ROOT_DIR, '.yamjam/config.yaml'))['hours']['GOOGLE_CLIENT_SECRET'] # SMPT settings EMAIL_HOST = 'smtp.beget.com' EMAIL_PORT = 25 EMAIL_HOST_USER = yamjam(os.path.join(ROOT_DIR, '.yamjam/config.yaml'))['hours']['user'] EMAIL_HOST_PASSWORD = yamjam(os.path.join( ROOT_DIR, '.yamjam/config.yaml'))['hours']['password'] EMAIL_USE_TLS = True
For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os 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/1.8/howto/deployment/checklist/ from YamJam import yamjam # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = yamjam()['myquizzes']['secret_key'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages',
For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os import dj_database_url from YamJam import yamjam # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) CFG = yamjam()['fmtc'] # SECURITY WARNING: keep the secret key used in production secret! # SECRET_KEY = '3hb3&d00*4*=8ar^0j$f!d)vfk4eb-uja@dk1j=v)xra!lse-y' SECRET_KEY = CFG['secret_key'] DEBUG = True DEVELOPEMENT_MODE = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions',
# Elapsed time decreases in time based intervals from YamJam import yamjam from . import pyrow, find import time import logging from usb.core import USBError workoutstateactive = [1, 2, 3, 4, 5, 6, 7, 8, 9] workoutstateidle = [0, 10, 11, 12, 13] workoutstatewait = [2, 6, 7, 8, 9] workoutstatestroke = [1, 3, 4, 5] try: CFG = yamjam()['pyrow'] email_host = CFG['email_host'] email_port = CFG['email_port'] email_use_tls = CFG['email_use_tls'] email_host_user = CFG['email_host_user'] email_host_password = CFG['email_host_password'] email_fromaddress = CFG['email_fromaddress'] email_recipients = CFG['email_recipients'] except KeyError: email_host = '' email_port = '' email_use_tls = '' email_host_user = '' email_host_password = '' email_fromaddress = '' email_recipients = ''
import requests from YamJam import yamjam config = yamjam()['hackway'] page_access_token = config['PAGE_ACCESS_TOKEN'] profile_url = 'https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + page_access_token data = { "code": "30", "name": "Python3", "questions": [{ "question": "What statement do you use to remove the last element in a python list?", "difficulty_level": "simple", "answers": [{ "answer": "pop", "state": "1" }, { "answer": "remove", "state": "2" }, { "answer": "get", "state": "2" }, { "answer": "eliminate", "state": "2" }]
from YamJam import yamjam CFG = yamjam('etc/mapapi/config.yaml')
This Bot uses the Updater class to handle the bot. First, a few handler functions are defined. Then, those functions are passed to the Dispatcher and registered at their respective places. Then, the bot is started and runs until we press Ctrl-C on the command line. Usage: Basic Echobot example, repeats messages. Press Ctrl-C on the command line or send a signal to the process to stop the bot. """ """ states: get_name <- get name for new note """ from YamJam import yamjam CFG = yamjam()['sharenote'] from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, MessageHandler, Filters from commands import Commands from customfilters import ScenarioFilter def main(): # Create new command instance commands = Commands() scenarios = commands.getSenarios() # Create the EventHandler and pass it your bot's token. updater = Updater(CFG['telegram']['token'])
''' Yet another abstraction. I did not know where to put initialisation of API, so here it is. ''' import dota2api from YamJam import yamjam # this is just the way to access secret files in public projects # fill free to replace the right part with your API key or # learn how to use YamJam here: http://yamjam.readthedocs.io/en/v0.1.7/ DOTA_API_KEY = yamjam()['AtoD']['DOTA2_API_KEY'] api = dota2api.Initialise(DOTA_API_KEY)
# -*- encoding: utf-8 -*- from YamJam import yamjam from configurations import Configuration import os from os.path import join, expanduser CFG = yamjam()['RecomendadorUD'] BASE_DIR = os.path.dirname(os.path.dirname(__file__)) HOME_DIR = expanduser("~")+"/www/Django/RecomendadorUD" MEDIA_DIR_PROD = join(HOME_DIR+"/prod/", 'media') MEDIA_DIR_DEV = join(HOME_DIR+"/dev/", 'media') class Base(Configuration): SECRET_KEY = CFG['SECRET_KEY']#os.environ.get("SECRET_KEY", '') DEBUG=True ALLOWED_HOSTS = [] TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.request", 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.core.context_processors.request', 'django.contrib.messages.context_processors.messages', 'django.contrib.auth.context_processors.auth', "apps.establishment_system.context_processors.notificaciones", "allauth.account.context_processors.account", "allauth.socialaccount.context_processors.socialaccount", )
Generated by 'django-admin startproject' using Django 2.2.6. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os from YamJam import yamjam # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cfg = yamjam()['bcm_dev'] # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = cfg['secret_key'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [
from os.path import dirname, abspath, join from os import environ from YamJam import yamjam from datetime import timedelta BASE_DIR = dirname(dirname(abspath(__file__))) config = yamjam(join(BASE_DIR, '.yamjam/config.yaml')) DEBUG = environ.get('AGONY_DEBUG') is not None SECRET_KEY = config['secret-key'] ADMINS = list(map(tuple, config['admins'])) ALLOWED_HOSTS = config['allowed-hosts'] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', 'core.apps.CoreConfig', 'rest_framework', 'rest_framework_gis' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
#!/usr/bin/env python # -*- coding: utf-8 -*- from models import User from sqlalchemy.orm import sessionmaker import logging import keyboards from sqlalchemy import create_engine from translator import _ from scenarios import Scenurios from manager import Manager from YamJam import yamjam db_CFG = yamjam()['sharenote']['database'] class Commands: def __init__(self): # Create database session connection Session = sessionmaker() engine = create_engine( 'postgresql://%s:%s@%s:%d/%s' % (db_CFG['user'], db_CFG['password'], db_CFG['host'], db_CFG['port'], db_CFG['name'])) Session.configure(bind=engine) self.session = Session() # Create scenarios manager self.scenarios = Scenurios(self, self.session) # Enable logging
'DEFAULT_FILTER_BACKENDS': ( 'rest_framework.filters.DjangoFilterBackend', 'rest_framework.filters.OrderingFilter', ), 'ORDERING_PARAM': 'order_by' } ATOMIC_REQUESTS = True _TEMPLATE_LOADERS = [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ] cfg = yamjam('/etc/pdt/config.yaml;./config.yaml') yam_config = cfg['pdt'] DEBUG = yam_config['debug'] import os if DEBUG and not os.environ.get('TESTING'): INSTALLED_APPS += ('debug_toolbar', ) DEBUG_TOOLBAR_CONFIG = { "SHOW_TOOLBAR_CALLBACK": lambda x: DEBUG, "SHOW_COLLAPSED": True, "RENDER_PANELS": True }
from os.path import expanduser try: from YamJam import yamjam, YAMLError except ImportError: raise ImportError("Install yamjam. Run `pip install -r requirements.txt`") logger = logging.getLogger(__name__) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) EMG_CONFIG = os.environ.get( 'EMG_CONFIG', os.path.join(expanduser("~"), 'emg', 'config.yaml') ) EMG_CONF = yamjam(EMG_CONFIG) try: LOGDIR = EMG_CONF['emg']['log_dir'] except KeyError: LOGDIR = os.path.join(expanduser("~"), 'emg', 'log') if not os.path.exists(LOGDIR): os.makedirs(LOGDIR) LOGGING_CLASS = 'cloghandler.ConcurrentRotatingFileHandler' LOGGING_FORMATER = ( '%(asctime)s %(levelname)5.5s [%(name)30.30s]' ' (proc.%(process)5.5d) %(funcName)s:%(lineno)d %(message)s') LOGGING = {
Generated by 'django-admin startproject' using Django 1.10.5. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os from YamJam import yamjam # Environment configuration. (**DO NOT MESSUP WITH THIS**) YAMS = yamjam()['parallelapi'] # 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/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'cnwdjc8*A***xqdunxuqwnecunw#$S3ciNCJ2Cc3dskc45sd#' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ["api.gsb-eng.com"]
For more information on this file, see https://docs.djangoproject.com/en/2.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os import dj_database_url import django_heroku from YamJam import yamjam if os.environ.get('TWILIO_ACCOUNT_SID'): TWILIO_SID = os.environ.get('TWILIO_ACCOUNT_SID') else: TWILIO_SID = yamjam()['machine']['TWILIO_ACCOUNT_SID'] if os.environ.get('TWILIO_AUTH_TOKEN'): TWILIO_AUTH = os.environ.get('TWILIO_AUTH_TOKEN') else: TWILIO_AUTH = yamjam()['machine']['TWILIO_AUTH_TOKEN'] # 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/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '(f9_e)kb9aof@tch8h^coa%((dpwcl#)zxtx0glxloy)36v@35'