Updating to most recent
This commit is contained in:
180
XMLTesting.py
180
XMLTesting.py
@@ -1,74 +1,136 @@
|
||||
from bs4 import BeautifulSoup as bs
|
||||
# import csv
|
||||
from openpyxl import workbook
|
||||
import requests
|
||||
from datetime import datetime, timedelta
|
||||
import time
|
||||
from main import Obtain_Ticket, Release_Ticket
|
||||
|
||||
|
||||
URL = "http://ccm.gli.us.com/store/storefrontapi.asmx"
|
||||
temp1 = URL.split('://')
|
||||
temp2 = temp1[1].split('/')
|
||||
HOST = (temp2[0])
|
||||
|
||||
ticket = Obtain_Ticket(URL, HOST)
|
||||
|
||||
print("CCM is starting")
|
||||
now = datetime.now()
|
||||
first = now.replace(day=1)
|
||||
lastMonth = first - timedelta(days=1)
|
||||
previous = lastMonth.strftime("%m/01/%Y")
|
||||
now = now.strftime("%m/%d/%Y")
|
||||
|
||||
|
||||
REPORT_FIELDS = '<string>Order ID</string>, <string>Order Status</string>'
|
||||
|
||||
# ws4 = wb.create_sheet("Downloaded Items")
|
||||
|
||||
report_filter = """ <filterNameOrXml><?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Date/Time Created" query="IsBetweenDate" minValue=""" + '"' + previous + ' 00:00"' + """ maxValue=""" + '"' + now + ' 00:00"' """/> <PFWebFilter:Step publicFieldName="PrintingFreeDownloadOnly" query="ExactEquals" minValue="download" maxValue="" /> </PFWebFilter:UserFilter></filterNameOrXml>
|
||||
"""
|
||||
|
||||
|
||||
send = """<?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:Body>
|
||||
<GetReport xmlns="http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111">
|
||||
<token>""" + ticket + """</token>
|
||||
<reportName>Items</reportName>
|
||||
<archived>false</archived>
|
||||
""" + report_filter + """
|
||||
<columnNames>"""+REPORT_FIELDS+"""</columnNames>
|
||||
</GetReport>
|
||||
</soap12:Body>
|
||||
</soap12:Envelope>"""
|
||||
|
||||
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length',
|
||||
'SOAPAction': 'http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111/GetReport'}
|
||||
response = requests.post(url=URL, data=send, headers=headers).text
|
||||
|
||||
|
||||
|
||||
###REPORT ColumnFormat TESTING#####
|
||||
temp1 = response.split('</GetReportResult>')
|
||||
temp2 = temp1[1].split('<error />')
|
||||
report = (temp2[0])
|
||||
|
||||
with open("StorefrontUtilitiesConfig.xml") as f:
|
||||
r = f.read()
|
||||
print(report)
|
||||
|
||||
y = bs(r, "lxml")
|
||||
|
||||
ClientName = []
|
||||
SF_URL = []
|
||||
SF_HOST = []
|
||||
CLIENT_SUMMARY_TAB = []
|
||||
SUMMARY_TAB = []
|
||||
client_headers = []
|
||||
headers = []
|
||||
|
||||
CLIENT_COLUMN_FORMAT = []
|
||||
COLUMN_FORMAT = []
|
||||
|
||||
for x in y.find_all('name'):
|
||||
# print(x.text)
|
||||
ClientName.append(x.text)
|
||||
# print(ClientName)
|
||||
|
||||
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 = []
|
||||
Release_Ticket(ticket, URL, HOST)
|
||||
|
||||
|
||||
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 = []
|
||||
|
||||
|
||||
option = 0
|
||||
columnformat = dict.fromkeys(headers[option])
|
||||
|
||||
|
||||
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)
|
||||
|
||||
count = 0
|
||||
|
||||
|
||||
# from bs4 import BeautifulSoup as bs
|
||||
# # import csv
|
||||
# from openpyxl import workbook
|
||||
#
|
||||
#
|
||||
#
|
||||
# ###REPORT ColumnFormat TESTING#####
|
||||
#
|
||||
# with open("StorefrontUtilitiesConfig.xml") as f:
|
||||
# r = f.read()
|
||||
#
|
||||
# y = bs(r, "lxml")
|
||||
#
|
||||
# ClientName = []
|
||||
# SF_URL = []
|
||||
# SF_HOST = []
|
||||
# CLIENT_SUMMARY_TAB = []
|
||||
# SUMMARY_TAB = []
|
||||
# client_headers = []
|
||||
# headers = []
|
||||
#
|
||||
# CLIENT_COLUMN_FORMAT = []
|
||||
# COLUMN_FORMAT = []
|
||||
#
|
||||
# for x in y.find_all('name'):
|
||||
# # print(x.text)
|
||||
# ClientName.append(x.text)
|
||||
# # print(ClientName)
|
||||
#
|
||||
# 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 = []
|
||||
#
|
||||
#
|
||||
# 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 = []
|
||||
#
|
||||
#
|
||||
# option = 0
|
||||
# columnformat = dict.fromkeys(headers[option])
|
||||
#
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
# count = 0
|
||||
#
|
||||
#
|
||||
# # print(columnformat)
|
||||
# for key in columnformat:
|
||||
# columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
# count = count + 1
|
||||
# print(columnformat)
|
||||
for key in columnformat:
|
||||
columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
count = count + 1
|
||||
print(columnformat)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user