Started moving SFU over to Flask
This commit is contained in:
3
app/SFU.py
Normal file
3
app/SFU.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from app import app
|
||||||
|
|
||||||
|
|
||||||
7
app/__init__.py
Normal file
7
app/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
from app import routes
|
||||||
|
|
||||||
|
|
||||||
13
app/routes.py
Normal file
13
app/routes.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from app import app
|
||||||
|
from flask import render_template
|
||||||
|
from main import loadClients
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
@app.route('/index')
|
||||||
|
|
||||||
|
def index():
|
||||||
|
ClientName = []
|
||||||
|
|
||||||
|
ClientName = loadClients()
|
||||||
|
|
||||||
|
return render_template('index.html', title='SFU', ClientName=ClientName)
|
||||||
12
app/templates/index.html
Normal file
12
app/templates/index.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% for x in ClientName %}
|
||||||
|
{{ ClientName }} <br>
|
||||||
|
{% endfor %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
282
main.py
282
main.py
@@ -7,6 +7,7 @@ from ClientSpecific import *
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def Obtain_Ticket(URL, HOST):
|
def Obtain_Ticket(URL, HOST):
|
||||||
GetTicket = """<?xml version="1.0" encoding="utf-8"?>
|
GetTicket = """<?xml version="1.0" encoding="utf-8"?>
|
||||||
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
|
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
|
||||||
@@ -256,23 +257,12 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
|||||||
Format_Report(ws2, detail_SSheader, detail_columnFormat)
|
Format_Report(ws2, detail_SSheader, detail_columnFormat)
|
||||||
Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat)
|
Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat)
|
||||||
|
|
||||||
def loadMenu():
|
def loadClients():
|
||||||
|
|
||||||
ConfigFile = "StorefrontUtilitiesConfig.xml"
|
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||||
ClientName = []
|
ClientName = []
|
||||||
SF_URL = []
|
SF_URL = []
|
||||||
SF_HOST = []
|
SF_HOST = []
|
||||||
CLIENT_SUMMARY_TAB = []
|
|
||||||
SUMMARY_TAB = []
|
|
||||||
headers = []
|
|
||||||
client_headers = []
|
|
||||||
CLIENT_DETAIL_TAB = []
|
|
||||||
DETAIL_TAB = []
|
|
||||||
client_detail_headers = []
|
|
||||||
detail_headers = []
|
|
||||||
CLIENT_COLUMN_FORMAT = []
|
|
||||||
COLUMN_FORMAT = []
|
|
||||||
detail_columnformat = []
|
|
||||||
|
|
||||||
# Open the config file
|
# Open the config file
|
||||||
with open(ConfigFile) as f:
|
with open(ConfigFile) as f:
|
||||||
@@ -285,129 +275,153 @@ def loadMenu():
|
|||||||
# print(x.text)
|
# print(x.text)
|
||||||
ClientName.append(x.text)
|
ClientName.append(x.text)
|
||||||
|
|
||||||
# Get Storefront API URls
|
# # Get Storefront API URls
|
||||||
for x in y.find_all('storefrontapiurl'):
|
# for x in y.find_all('storefrontapiurl'):
|
||||||
# print(x)
|
# # print(x)
|
||||||
SF_URL.append(x.text)
|
# SF_URL.append(x.text)
|
||||||
|
#
|
||||||
|
# # Get Storefront Host URLs
|
||||||
|
# for x in SF_URL:
|
||||||
|
# temp1 = x.split('://')
|
||||||
|
# temp2 = temp1[1].split('/')
|
||||||
|
# HOST = (temp2[0])
|
||||||
|
# SF_HOST.append(HOST)
|
||||||
|
|
||||||
# Get Storefront Host URLs
|
return(ClientName)
|
||||||
for x in SF_URL:
|
|
||||||
temp1 = x.split('://')
|
|
||||||
temp2 = temp1[1].split('/')
|
|
||||||
HOST = (temp2[0])
|
|
||||||
SF_HOST.append(HOST)
|
|
||||||
|
|
||||||
|
|
||||||
# Get Monthly Report Summary Fields
|
|
||||||
for w in y.find_all('client'):
|
|
||||||
for x in w.find_all('monthlyreport'):
|
|
||||||
for g in x.find_all('summarytab'):
|
|
||||||
for z in g.find_all('columnname'):
|
|
||||||
z.name = "string"
|
|
||||||
CLIENT_SUMMARY_TAB.append(z)
|
|
||||||
client_headers.append(z.text)
|
|
||||||
SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
|
|
||||||
headers.append(client_headers)
|
|
||||||
CLIENT_SUMMARY_TAB = []
|
|
||||||
client_headers = []
|
|
||||||
|
|
||||||
# Get Monthly Report Column Format
|
# def loadMenu():
|
||||||
for w in y.find_all('client'):
|
#
|
||||||
for x in w.find_all('monthlyreport'):
|
# ConfigFile = "StorefrontUtilitiesConfig.xml"
|
||||||
for g in x.find_all('summarytab'):
|
# ClientName = []
|
||||||
for z in g.find_all('columnformat'):
|
# SF_URL = []
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
# SF_HOST = []
|
||||||
COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
# CLIENT_SUMMARY_TAB = []
|
||||||
CLIENT_COLUMN_FORMAT = []
|
# SUMMARY_TAB = []
|
||||||
|
# headers = []
|
||||||
|
# client_headers = []
|
||||||
|
# CLIENT_DETAIL_TAB = []
|
||||||
|
# DETAIL_TAB = []
|
||||||
|
# client_detail_headers = []
|
||||||
|
# detail_headers = []
|
||||||
|
# CLIENT_COLUMN_FORMAT = []
|
||||||
|
# COLUMN_FORMAT = []
|
||||||
|
# detail_columnformat = []
|
||||||
|
#
|
||||||
|
|
||||||
# Get Monthly Report Item Detail Fields
|
#
|
||||||
for w in y.find_all('client'):
|
#
|
||||||
for x in w.find_all('monthlyreport'):
|
# # Get Monthly Report Summary Fields
|
||||||
for g in x.find_all('detailtab'):
|
# for w in y.find_all('client'):
|
||||||
for z in g.find_all('columnname'):
|
# for x in w.find_all('monthlyreport'):
|
||||||
z.name = "string"
|
# for g in x.find_all('summarytab'):
|
||||||
CLIENT_DETAIL_TAB.append(z)
|
# for z in g.find_all('columnname'):
|
||||||
client_detail_headers.append(z.text)
|
# z.name = "string"
|
||||||
DETAIL_TAB.append(CLIENT_DETAIL_TAB)
|
# CLIENT_SUMMARY_TAB.append(z)
|
||||||
detail_headers.append(client_detail_headers)
|
# client_headers.append(z.text)
|
||||||
CLIENT_DETAIL_TAB = []
|
# SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
|
||||||
client_detail_headers = []
|
# headers.append(client_headers)
|
||||||
|
# CLIENT_SUMMARY_TAB = []
|
||||||
choice = 0
|
# client_headers = []
|
||||||
for x in ClientName:
|
#
|
||||||
print(choice, x)
|
# # Get Monthly Report Column Format
|
||||||
choice = choice + 1
|
# for w in y.find_all('client'):
|
||||||
|
# for x in w.find_all('monthlyreport'):
|
||||||
option = int(input())
|
# for g in x.find_all('summarytab'):
|
||||||
|
# for z in g.find_all('columnformat'):
|
||||||
client_Specific_Tabs(ClientName[option])
|
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
|
# COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
||||||
summary_columnformat = dict.fromkeys(headers[option])
|
# CLIENT_COLUMN_FORMAT = []
|
||||||
|
#
|
||||||
# Get specific Summary Column Types for chosen client
|
# # Get Monthly Report Item Detail Fields
|
||||||
for w in y.find_all('client'):
|
# for w in y.find_all('client'):
|
||||||
for x in w.find_all('name'):
|
# for x in w.find_all('monthlyreport'):
|
||||||
if x.text == ClientName[option]:
|
# for g in x.find_all('detailtab'):
|
||||||
for x in w.find_all('monthlyreport'):
|
# for z in g.find_all('columnname'):
|
||||||
for g in x.find_all('summarytab'):
|
# z.name = "string"
|
||||||
for z in g.find_all('columnformat'):
|
# CLIENT_DETAIL_TAB.append(z)
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
# client_detail_headers.append(z.text)
|
||||||
# set Summary Column Types Header Dictionary
|
# DETAIL_TAB.append(CLIENT_DETAIL_TAB)
|
||||||
count = 0
|
# detail_headers.append(client_detail_headers)
|
||||||
for key in summary_columnformat:
|
# CLIENT_DETAIL_TAB = []
|
||||||
summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
# client_detail_headers = []
|
||||||
count = count + 1
|
#
|
||||||
|
# choice = 0
|
||||||
CLIENT_COLUMN_FORMAT = []
|
# for x in ClientName:
|
||||||
# Get specific Detail Column Types for chosen client
|
# print(choice, x)
|
||||||
for w in y.find_all('client'):
|
# choice = choice + 1
|
||||||
for x in w.find_all('name'):
|
#
|
||||||
if x.text == ClientName[option]:
|
# option = int(input())
|
||||||
for x in w.find_all('monthlyreport'):
|
#
|
||||||
for g in x.find_all('detailtab'):
|
# client_Specific_Tabs(ClientName[option])
|
||||||
for z in g.find_all('columnformat'):
|
#
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
# summary_columnformat = dict.fromkeys(headers[option])
|
||||||
|
#
|
||||||
detail_columnformat = dict.fromkeys(detail_headers[option])
|
# # Get specific Summary Column Types for chosen client
|
||||||
# set Detail Column Types Header Dictionary
|
# for w in y.find_all('client'):
|
||||||
count = 0
|
# for x in w.find_all('name'):
|
||||||
for key in detail_columnformat:
|
# if x.text == ClientName[option]:
|
||||||
detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
# for x in w.find_all('monthlyreport'):
|
||||||
count = count + 1
|
# for g in x.find_all('summarytab'):
|
||||||
|
# for z in g.find_all('columnformat'):
|
||||||
# create new report file and add headers based on config file
|
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
wb = workbook.Workbook()
|
# # set Summary Column Types Header Dictionary
|
||||||
ws = wb.active
|
# count = 0
|
||||||
ws.title = "Order Summary"
|
# for key in summary_columnformat:
|
||||||
ws.append(headers[option])
|
# summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||||
|
# count = count + 1
|
||||||
ws2 = wb.create_sheet("Item Detail")
|
#
|
||||||
ws2.append(detail_headers[option])
|
# CLIENT_COLUMN_FORMAT = []
|
||||||
|
# # Get specific Detail Column Types for chosen client
|
||||||
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
# for w in y.find_all('client'):
|
||||||
|
# for x in w.find_all('name'):
|
||||||
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB[option]))
|
# if x.text == ClientName[option]:
|
||||||
DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB[option]))
|
# for x in w.find_all('monthlyreport'):
|
||||||
URL_HOST = [SF_URL[option], SF_HOST[option], REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnformat, headers[option], detail_columnformat, detail_headers[option]]
|
# for g in x.find_all('detailtab'):
|
||||||
return URL_HOST
|
# for z in g.find_all('columnformat'):
|
||||||
|
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
def main():
|
#
|
||||||
URL_HOST = loadMenu()
|
# detail_columnformat = dict.fromkeys(detail_headers[option])
|
||||||
URL = URL_HOST[0]
|
# # set Detail Column Types Header Dictionary
|
||||||
HOST = URL_HOST[1]
|
# count = 0
|
||||||
REPORT_FIELDS = URL_HOST[2]
|
# for key in detail_columnformat:
|
||||||
wb = URL_HOST[3]
|
# detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||||
ws = URL_HOST[4]
|
# count = count + 1
|
||||||
ws2 = URL_HOST[5]
|
#
|
||||||
DETAIL_REPORT_FIELDS = URL_HOST[6]
|
# # create new report file and add headers based on config file
|
||||||
summary_columnFormat = URL_HOST[7]
|
# wb = workbook.Workbook()
|
||||||
|
# ws = wb.active
|
||||||
summary_SSheader = URL_HOST[8]
|
# ws.title = "Order Summary"
|
||||||
detail_columnFormat = URL_HOST[9]
|
# ws.append(headers[option])
|
||||||
detail_SSheader = URL_HOST[10]
|
#
|
||||||
|
# ws2 = wb.create_sheet("Item Detail")
|
||||||
ticket = Obtain_Ticket(URL, HOST)
|
# ws2.append(detail_headers[option])
|
||||||
Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader)
|
#
|
||||||
Release_Ticket(ticket, URL, HOST)
|
# # converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
||||||
|
#
|
||||||
main()
|
# REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB[option]))
|
||||||
|
# DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB[option]))
|
||||||
|
# URL_HOST = [SF_URL[option], SF_HOST[option], REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnformat, headers[option], detail_columnformat, detail_headers[option]]
|
||||||
|
# return URL_HOST
|
||||||
|
#
|
||||||
|
# def main():
|
||||||
|
# URL_HOST = loadMenu()
|
||||||
|
# URL = URL_HOST[0]
|
||||||
|
# HOST = URL_HOST[1]
|
||||||
|
# REPORT_FIELDS = URL_HOST[2]
|
||||||
|
# wb = URL_HOST[3]
|
||||||
|
# ws = URL_HOST[4]
|
||||||
|
# ws2 = URL_HOST[5]
|
||||||
|
# DETAIL_REPORT_FIELDS = URL_HOST[6]
|
||||||
|
# summary_columnFormat = URL_HOST[7]
|
||||||
|
#
|
||||||
|
# summary_SSheader = URL_HOST[8]
|
||||||
|
# detail_columnFormat = URL_HOST[9]
|
||||||
|
# detail_SSheader = URL_HOST[10]
|
||||||
|
#
|
||||||
|
# ticket = Obtain_Ticket(URL, HOST)
|
||||||
|
# Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader)
|
||||||
|
# Release_Ticket(ticket, URL, HOST)
|
||||||
|
#
|
||||||
|
# main()
|
||||||
Reference in New Issue
Block a user