Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I store the response codes as a log from the target url #87

Open
selininwonderland opened this issue Apr 18, 2023 · 0 comments
Open

Comments

@selininwonderland
Copy link

selininwonderland commented Apr 18, 2023

I would like to use polling2 to send requests and take an action when status requirements are valid and also would like to monitor and store the response codes from the target endpoint. It could be either written as a log file to troubleshoot. Log part I added recently but it does not work like this to see the what is response code or what this function actually doing.
Could u help me understand how can I implement the response code from the target URL? Thanks in advance

my current usage of a piece of code like this

continueToPoll = True
while continueToPoll:
     try:
         r = polling2.poll(lambda: requests.request("GET", Url, auth=(userName, password)),step=60,poll_forever=True,verify=False,log_error=logging.DEBUG)

     except:
         print("Connection refused by the server..")
         weekNumber = datetime.datetime.today().weekday()
         start = datetime.time(5, 0, 0)
         end = datetime.time(18, 0, 0)
         current = datetime.datetime.now().time()

         if current>= start and current <= end:
           if weekNumber < 5:
               time.sleep(300)
           else:
                time.sleep(3600)
         else:
              time.sleep(3600)
         continue

     x = r.json()
     r.close()
     currentChangeStatus = x['fields']['status']['name']
     if currentStatus == expectedStatus: continueToPoll = False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant