def development(): os.environ['ENV_FILE'] = 'docker/private/base/docker.env' from envious import load_env load_env() execute(commons) env.settings = 'development' env.login_required = False
#! /usr/bin/env python from newsapi import NewsApiClient import sqlite3 from envious import load_env import os os.environ['ENV_FILE'] = os.path.dirname(os.path.abspath(__file__)) + '/.env' load_env() api_key = os.getenv('API_KEY') newsapi = NewsApiClient(api_key=api_key) ### DATABASE INSERTS ### def sql_insert(source, author, title, description, url, urlToImage, publishedAt, content, news_type, location): try: sqliteConnection = sqlite3.connect('/opt/news_archive/news/db/db.db') cursor = sqliteConnection.cursor() print("Successfully Connected to SQLite") sqlite_insert_query = """INSERT INTO za_news ('source', 'author', 'title', 'description', 'url', 'urlToImage', 'publishedAt', content, news_type, location) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""" count = cursor.execute( sqlite_insert_query, (source, author, title, description, url, urlToImage, publishedAt,
sys.stderr.write("""Usage: %s [domain name] [command] Command can be one of: update [record_name] [ip_address] Update an A record """ % os.path.basename(sys.argv[0])) sys.exit(1) if __name__ == "__main__": if len(sys.argv) < 3: usage() domain_name = sys.argv[1] command = sys.argv[2] os.environ['ENV_FILE'] = os.path.dirname(os.path.abspath(__file__)) + '/.env' load_env() api_key = os.getenv('DNSMADEEASY_API_KEY') secret_key = os.getenv('DNSMADEEASY_SECRET_KEY') if not api_key or not secret_key: print "API Key or Secret Key not set. Please see README.md for instructions" sys.exit(1) dizzy = Dizzy(api_key, secret_key) if command == "update": if len(sys.argv) < 5: usage() record_name = sys.argv[3] record_value = sys.argv[4]