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):
|
||||
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">
|
||||
@@ -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)
|
||||
Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat)
|
||||
|
||||
def loadMenu():
|
||||
def loadClients():
|
||||
|
||||
ConfigFile = "StorefrontUtilitiesConfig.xml"
|
||||
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||
ClientName = []
|
||||
SF_URL = []
|
||||
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
|
||||
with open(ConfigFile) as f:
|
||||
@@ -285,129 +275,153 @@ def loadMenu():
|
||||
# print(x.text)
|
||||
ClientName.append(x.text)
|
||||
|
||||
# Get Storefront API URls
|
||||
for x in y.find_all('storefrontapiurl'):
|
||||
# print(x)
|
||||
SF_URL.append(x.text)
|
||||
# # Get Storefront API URls
|
||||
# for x in y.find_all('storefrontapiurl'):
|
||||
# # print(x)
|
||||
# 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
|
||||
for x in SF_URL:
|
||||
temp1 = x.split('://')
|
||||
temp2 = temp1[1].split('/')
|
||||
HOST = (temp2[0])
|
||||
SF_HOST.append(HOST)
|
||||
return(ClientName)
|
||||
|
||||
|
||||
# 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
|
||||
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('columnformat'):
|
||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
||||
CLIENT_COLUMN_FORMAT = []
|
||||
# def loadMenu():
|
||||
#
|
||||
# ConfigFile = "StorefrontUtilitiesConfig.xml"
|
||||
# ClientName = []
|
||||
# SF_URL = []
|
||||
# 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 = []
|
||||
#
|
||||
|
||||
# Get Monthly Report Item Detail Fields
|
||||
for w in y.find_all('client'):
|
||||
for x in w.find_all('monthlyreport'):
|
||||
for g in x.find_all('detailtab'):
|
||||
for z in g.find_all('columnname'):
|
||||
z.name = "string"
|
||||
CLIENT_DETAIL_TAB.append(z)
|
||||
client_detail_headers.append(z.text)
|
||||
DETAIL_TAB.append(CLIENT_DETAIL_TAB)
|
||||
detail_headers.append(client_detail_headers)
|
||||
CLIENT_DETAIL_TAB = []
|
||||
client_detail_headers = []
|
||||
|
||||
choice = 0
|
||||
for x in ClientName:
|
||||
print(choice, x)
|
||||
choice = choice + 1
|
||||
|
||||
option = int(input())
|
||||
|
||||
client_Specific_Tabs(ClientName[option])
|
||||
|
||||
summary_columnformat = dict.fromkeys(headers[option])
|
||||
|
||||
# Get specific Summary Column Types for chosen client
|
||||
for w in y.find_all('client'):
|
||||
for x in w.find_all('name'):
|
||||
if x.text == ClientName[option]:
|
||||
for x in w.find_all('monthlyreport'):
|
||||
for g in x.find_all('summarytab'):
|
||||
for z in g.find_all('columnformat'):
|
||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
# set Summary Column Types Header Dictionary
|
||||
count = 0
|
||||
for key in summary_columnformat:
|
||||
summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
count = count + 1
|
||||
|
||||
CLIENT_COLUMN_FORMAT = []
|
||||
# Get specific Detail Column Types for chosen client
|
||||
for w in y.find_all('client'):
|
||||
for x in w.find_all('name'):
|
||||
if x.text == ClientName[option]:
|
||||
for x in w.find_all('monthlyreport'):
|
||||
for g in x.find_all('detailtab'):
|
||||
for z in g.find_all('columnformat'):
|
||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
|
||||
detail_columnformat = dict.fromkeys(detail_headers[option])
|
||||
# set Detail Column Types Header Dictionary
|
||||
count = 0
|
||||
for key in detail_columnformat:
|
||||
detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
count = count + 1
|
||||
|
||||
# create new report file and add headers based on config file
|
||||
wb = workbook.Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "Order Summary"
|
||||
ws.append(headers[option])
|
||||
|
||||
ws2 = wb.create_sheet("Item Detail")
|
||||
ws2.append(detail_headers[option])
|
||||
|
||||
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
||||
|
||||
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()
|
||||
#
|
||||
#
|
||||
# # 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
|
||||
# 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('columnformat'):
|
||||
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
# COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
||||
# CLIENT_COLUMN_FORMAT = []
|
||||
#
|
||||
# # Get Monthly Report Item Detail Fields
|
||||
# for w in y.find_all('client'):
|
||||
# for x in w.find_all('monthlyreport'):
|
||||
# for g in x.find_all('detailtab'):
|
||||
# for z in g.find_all('columnname'):
|
||||
# z.name = "string"
|
||||
# CLIENT_DETAIL_TAB.append(z)
|
||||
# client_detail_headers.append(z.text)
|
||||
# DETAIL_TAB.append(CLIENT_DETAIL_TAB)
|
||||
# detail_headers.append(client_detail_headers)
|
||||
# CLIENT_DETAIL_TAB = []
|
||||
# client_detail_headers = []
|
||||
#
|
||||
# choice = 0
|
||||
# for x in ClientName:
|
||||
# print(choice, x)
|
||||
# choice = choice + 1
|
||||
#
|
||||
# option = int(input())
|
||||
#
|
||||
# client_Specific_Tabs(ClientName[option])
|
||||
#
|
||||
# summary_columnformat = dict.fromkeys(headers[option])
|
||||
#
|
||||
# # Get specific Summary Column Types for chosen client
|
||||
# for w in y.find_all('client'):
|
||||
# for x in w.find_all('name'):
|
||||
# if x.text == ClientName[option]:
|
||||
# for x in w.find_all('monthlyreport'):
|
||||
# for g in x.find_all('summarytab'):
|
||||
# for z in g.find_all('columnformat'):
|
||||
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
# # set Summary Column Types Header Dictionary
|
||||
# count = 0
|
||||
# for key in summary_columnformat:
|
||||
# summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
# count = count + 1
|
||||
#
|
||||
# CLIENT_COLUMN_FORMAT = []
|
||||
# # Get specific Detail Column Types for chosen client
|
||||
# for w in y.find_all('client'):
|
||||
# for x in w.find_all('name'):
|
||||
# if x.text == ClientName[option]:
|
||||
# for x in w.find_all('monthlyreport'):
|
||||
# for g in x.find_all('detailtab'):
|
||||
# for z in g.find_all('columnformat'):
|
||||
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
#
|
||||
# detail_columnformat = dict.fromkeys(detail_headers[option])
|
||||
# # set Detail Column Types Header Dictionary
|
||||
# count = 0
|
||||
# for key in detail_columnformat:
|
||||
# detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
# count = count + 1
|
||||
#
|
||||
# # create new report file and add headers based on config file
|
||||
# wb = workbook.Workbook()
|
||||
# ws = wb.active
|
||||
# ws.title = "Order Summary"
|
||||
# ws.append(headers[option])
|
||||
#
|
||||
# ws2 = wb.create_sheet("Item Detail")
|
||||
# ws2.append(detail_headers[option])
|
||||
#
|
||||
# # converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
||||
#
|
||||
# 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