From cfa93e00928df3e9b1b9bc8b051bcbe3195262cb Mon Sep 17 00:00:00 2001 From: Dan Dembinski Date: Mon, 3 Jun 2019 21:40:50 -0400 Subject: [PATCH] Updated to allow updating URL/Hostname easier. --- main.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 698e8c1..591838a 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ import requests from lxml import etree -def Obtain_Ticket(): +def Obtain_Ticket(URL, HOST): GetTicket = """ @@ -13,15 +13,16 @@ def Obtain_Ticket(): """ - headers = {'Host': 'soprema.gli.us.com', 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'} - response = requests.post('http://soprema.gli.us.com/Store/storefrontapi.asmx', data=GetTicket, headers=headers).text + headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'} + response = requests.post(url=URL, data=GetTicket, headers=headers).text + # print(response) temp1 = response.split('') temp2 = temp1[1].split('') ticket = temp2[0] # print("got ticket: " + ticket) return ticket -def Release_Ticket(ticket): +def Release_Ticket(ticket, URL, HOST): ReleaseTicket = """ @@ -30,12 +31,11 @@ def Release_Ticket(ticket): """ - headers = {'Host': 'soprema.gli.us.com', 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'} - - response = requests.post('http://soprema.gli.us.com/Store/storefrontapi.asmx', data=ReleaseTicket, headers=headers).text + headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'} + response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text # print("released ticket "+ticket) -def Run_Report(ticket): +def Run_Report(ticket, URL, HOST): send = """ @@ -51,14 +51,16 @@ def Run_Report(ticket): """ - headers = {'Host': 'soprema.gli.us.com', 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'} - response = requests.post('http://soprema.gli.us.com/Store/storefrontapi.asmx', data=send, headers=headers).text + headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'} + response = requests.post(url=URL, data=send, headers=headers).text print(response) def main(): - ticket = Obtain_Ticket() - Run_Report(ticket) - Release_Ticket(ticket) + URL = 'http://soprema.gli.us.com/Store/storefrontapi.asmx' + HOST = 'soprema.gli.us.com' + ticket = Obtain_Ticket(URL, HOST) + Run_Report(ticket, URL, HOST) + Release_Ticket(ticket, URL, HOST) main()