Advertisement
Guest User

RDMwriter.py

a guest
Aug 30th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.18 KB | None | 0 0
  1.  
  2. Skip to content
  3. This repository
  4.  
  5.     Pull requests
  6.     Issues
  7.     Gist
  8.  
  9.     @sudo-Whateverman
  10.  
  11. One of our mostly harmless robots seems to think you are not a human.
  12.  
  13. Because of that, it’s hidden your profile from the public. If you really are human, please contact support to have your profile reinstated.
  14.  
  15. We promise we won’t require DNA proof of your humanity.
  16.  
  17. 1
  18. 0
  19.  
  20.     0
  21.  
  22. sudo-Whateverman/DumbPolluting
  23.  
  24. DumbPolluting/RDMwriter.py
  25. @sudo-Whateverman sudo-Whateverman 4 minutes ago version good
  26.  
  27. 1 contributor
  28. 75 lines (62 sloc) 2.488 kB
  29. __author__ = 'nick'
  30. from suds.client import Client
  31. from suds.plugin import *
  32. url = 'http://director.resourcedm.com/cgi-bin/cgi.cgi?WSDL'
  33. # url ='http://10.1.2.75/cgi-bin/cgi.cgi?wsdl'
  34.  
  35. def getWSDLconnection(url):
  36.     # This function will prompt the user to enter the wsdl link, can be used from commandline or use the default value
  37.     # default is http://director.resourcedm.com/cgi-bin/cgi.cgi?WSDL
  38.     client = Client(url)
  39.     return client
  40.  
  41. def genPointLinks():
  42.     # will write the additional data needed to write a script
  43.     return 0
  44.  
  45. def genHttpPoints():
  46.     # will write the HTTP retriever point with a regex to read the data from shufersal;
  47.     return 0
  48.  
  49. def generateupdateStatement():
  50.     # creates a string for setting the value using a point link
  51.     return 0
  52.  
  53. def genNames(client):
  54.     # Genereates a list of Equip/point and its corresponding value to pass to a higher function
  55.     NameList = []
  56.     Slaves = client.service.GetSlaveList().Slave
  57.     for i in range(len(Slaves)):
  58.         # print Slaves[i].Name
  59.         try:
  60.             Points = client.service.GetSlave(Slaves[i].Name).Items.Item
  61.         except AttributeError:
  62.             print Slaves[i].Name + " has no Items to list"
  63.         else:
  64.             for j in range(len(Points)):
  65.                 NameList.append(
  66.                     [str(Slaves[i].Name + '/' + Points[j].Name), str(Points[j].Value), str(Points[j].Units)])
  67.                 # print str(Slaves[i].Name + '/' + Points[j].Name) +" : "+ str(Points[j].Value)  + str(Points[j].Units)
  68.     return NameList
  69.  
  70. def genCredentials(client,username,password):
  71.     userCred = client.factory.create('UserCredentials')
  72.     userCred.UserName = username
  73.     userCred.Password = password
  74.     client.set_options(soapheaders=userCred)
  75.  
  76. def writeSlave(Name,point_struct):
  77.     points = client.factory.create('ArrayOfSettings')
  78.     points.Setting = client.factory.create('Setting')
  79.     points.Setting.Name = point_struct.Name
  80.     points.Setting.Value = point_struct.Value
  81.     client.service.SetSlave(Name,points)
  82.  
  83.  
  84. client = getWSDLconnection(url)
  85. Slaves = client.service.GetSlaveList()
  86. # HVAC1 = Slaves.Slave[1]
  87. inp2 = Slaves.Slave[0]
  88. points = client.service.GetSlave(inp2.Name)
  89. # off6 = points.Items.Item[-5]
  90. genCredentials(client,username='igor',password='1111')
  91. settables = []
  92. for setpoint in points.Items.Item:
  93.     try :
  94.         writeSlave(inp2.Name,setpoint)
  95.     except WebFault , e :
  96.         print e
  97.     else:
  98.         settables.append(setpoint.Name)
  99.  
  100. print(settables)
  101.  
  102.  
  103.     Status API Training Shop Blog About Pricing
  104.  
  105.     © 2015 GitHub, Inc. Terms Privacy Security Contact Help
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement