Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About venkatklr

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. venkatklr

    Python while loop not working in the code.

    Gear, I got the output what I wanted. thank you for the help.
  2. venkatklr

    Python while loop not working in the code.

    Gear, did you updated code in your post?
  3. venkatklr

    Python while loop not working in the code.

    Hi , here is the output of this code. no counter is getting for 403 and 200 but if both r1 and r2 gets 200 then the counter starts. 403 200 Link is down 200 200 Link is up counting start counter 1 counter 2 counter 3
  4. Hi All, I have created small script to check 2 URL and if these two is not matching with success code 200, while loop should execute but it is not working. Please can some one help me where I am doing wrong. import requests url1 = ('http://myhost.com/cgi-bin/') url2 = ('http://google.com') responseurl1 = requests.get(url1) responseurl2 = requests.get(url2) r1 = responseurl1.status_code r2 = responseurl2.status_code print(r1) print(r2) statuscode = 200 try: if r1 is r2 is statuscode: print("Link is up") counter = 0 while counter < 3 and r1 is r2 != statuscode: counter = counter +1 print(counter) else: print("Link is down") except Exception as e: print("down")
  5. MrGrj, Thank you for providing article. it is very informative. I am getting dic type output after adding .json() to GET request. my requirement is first check for (Availability Test) for multiple urls and then post to vro. please refer XML (I am using that to create task in vro) here nameSch is for the name create like Availability and href="'+url+ is the server url . Please let me know how can do it.
  6. here is my code. from xml.etree.ElementTree import Element, SubElement, Comment,XML from schedularConf import EXECUTION_CONST (Execution_Const is in different python script and here is the code. import json import xmltodict import requests from xml.etree import ElementTree from string import Template class EXECUTION_CONST(): # Header for HTTP request. headers = {'Content-Type': 'application/xml'} # Availability Tests SCHEDULAR_LISTS = { " Availability Test": "https://servername/vco/api/workflows/workflowID" }) class schedule: def getData(self): try: list = EXECUTION_CONST.SCHEDULAR_LISTS; for name, url in list.iteritems(): mainUrl = url.split("workflows")[0]+"/tasks"; nameSch = name.split("-")[1]; # print (nameSch) list = requests.get(mainUrl,auth = ('username', 'password'),verify=False).text print (list) lists = json.dumps(list) #print (lists) # for l in lists: # if l == " Availability Test": # print(" Availability Test is available" ) # else: # print ("Availability Test is not available") # XML = '<task xmlns="http://www.vmware.com/vco"><name>'+nameSch+'</name><recurrence-cycle>one-time</recurrence-cycle><recurrence-start-date>2017-09-30T11:52:00+03:00</recurrence-start-date><workflow href="'+url+'"></workflow><start-mode>normal</start-mode></task>' # # print (XML) # res = requests.post(mainUrl,data=XML,headers=EXECUTION_CONST.headers, # auth = ('username', 'password'),verify=False).text # print (res); except Exception, e: print e return ;
  7. Hi Administrator, thanks for the link. I am trying to GET data from vmware orchestrator API and if i try to export json, getting this error "'unicode' object has no attribute 'json'" any idea?
  8. how to GET data from API to variable and match with value and then POST it. I want to do it in python script.