import sys
from suds.client import Client

address = "piwebservices.snowyhydro.com.au"
#address = "wsf.cdyne.com"

servicename = "PIWebServices/PITimeSeries.svc"
#servicename = "WeatherWS/Weather.asmx"

#Get WSDL file for PI Web Services
url = 'http://' + address + '/' + servicename + '?wsdl'
print url

#Connect to the web service
client = Client(url)
			
print client
			
#Call web service
result = client.service.GetProductVersion()
print result

strset = client.factory.create('ArrayOfString')
       
strset.string = []

strset.string.append("pi:\\SHLHIS4\RANDOM GARBAGE")
        	        
try:
    results = client.service.SignUpForPIUpdates(strset,10)
except Exception as e:
    print("Failed Subscribing To : " + str(strset))
    print("Exception In Subscription : " + str(e))    

if (results.Errors[0] != 0):            
    print("Unable to Subscribe - PIWS Call Failed")
    try:
        print("Web Services Error: " + results.ErrDescs[0])
    except:
        print("Unknown Error Type (Exception While Getting Error Info)")                    