Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Stakeholder Bulk Upload. UPDATE: Move to Django #271

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/pe_reports/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Third-Party Libraries
from celery import Celery
from flask import Flask
from flask import Flask, render_template
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
Expand All @@ -21,6 +21,7 @@
# Stakeholder views
from pe_reports.home.views import home_blueprint
from pe_reports.stakeholder.views import stakeholder_blueprint
from pe_reports.stakeholder_bulk_upload.views import stakeholder_bulk_upload_blueprint

from ._version import __version__ # noqa: F401

Expand All @@ -38,25 +39,19 @@
# Configure the redis server
app.config["CELERY_BROKER_URL"] = "redis://localhost:6379/0"
app.config["CELERY_RESULT_BACKEND"] = "redis://localhost:6379/0"
app.config["UPLOAD_FOLDER"] = "src/pe_reports/uploads/"
app.config["ALLOWED_EXTENSIONS"] = {"txt", "csv"}

CENTRAL_LOGGING_FILE = "pe_reports_logging.log"
DEBUG = False
# Setup Logging
"""Set up logging and call the run_pe_script function."""
if DEBUG is True:
level = "DEBUG"
else:
level = "INFO"

# Create central logging
logging.basicConfig(
filename=CENTRAL_LOGGING_FILE,
filename="flaskLog.log",
filemode="a",
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
datefmt="%m/%d/%Y %I:%M:%S",
level=level,
level=logging.INFO,
)

app.config["LOGGER"] = logging.getLogger(__name__)

# Creates a Celery object
celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
Expand All @@ -75,11 +70,18 @@

# Register the flask apps
app.register_blueprint(stakeholder_blueprint)
app.register_blueprint(stakeholder_bulk_upload_blueprint)

# TODO: Add login blueprint. Issue #207 contains details
# app.register_blueprint(manage_login_blueprint)
app.register_blueprint(home_blueprint)


@app.errorhandler(404)
def page_not_found(e):
return render_template("404.html")


if __name__ == "__main__":
logging.info("The program has started...")
app.run(host="127.0.0.1", debug=DEBUG, port=8000)
app.run(host="127.0.0.1", debug=False, port=8000)
23 changes: 22 additions & 1 deletion src/pe_reports/data/config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Standard Python Libraries
from configparser import ConfigParser
import os

# Third-Party Libraries
from importlib_resources import files
Expand All @@ -12,7 +13,6 @@
def config(filename=REPORT_DB_CONFIG, section="postgres"):
"""Parse Postgres configuration details from database configuration file."""
parser = ConfigParser()

parser.read(filename, encoding="utf-8")

db = dict()
Expand All @@ -25,3 +25,24 @@ def config(filename=REPORT_DB_CONFIG, section="postgres"):
raise Exception(f"Section {section} not found in {filename}")

return db


def whois_xml_api_key():
"""Fetch the WhoisXML API key."""
section = "whoisxml"
if os.path.isfile(REPORT_DB_CONFIG):
parser = ConfigParser()
parser.read(REPORT_DB_CONFIG, encoding="utf-8")
if parser.has_section(section):
params = parser.items(section)
_key = params[0]
key = _key[1]
else:
raise Exception(
"Section {} not found in the {} file".format(section, REPORT_DB_CONFIG)
)
else:
raise Exception(
"Database.ini file not found at this path: {}".format(REPORT_DB_CONFIG)
)
return key
Loading