5 Replies Latest reply: May 20, 2014 9:14 AM by Sunil Lala RSS

updateStreamDefects with custom attributes

prapier Genius
Currently Being Moderated

This python example is for Web Services API v5 (6.0.x) and includes comments regarding the changes needed to make this work for v4 (5.5.x) .  The attached file contains the complete code to create the DefectServiceClient and connect to the Integrity Manager.tServiceClient


# updateStreamDefects example - assumes custom attribute named "My_Attribute" that takes a text value all ready exists in CIM
# list of CIDs
cids = 10251, 10250
streamDefectFilter = DefectServiceClient.factory.create("streamDefectFilterSpecDataObj")
# v4 only
# v5 only
streamIdDataDO = DefectServiceClient.factory.create("streamIdDataObj")
streamDefectFilter.streamIdList = streamIdDataDO
# v4 and v5
streamDefects = DefectServiceClient.service.getStreamDefects(cids, streamDefectFilter)
for sd in streamDefects:
  defectId = sd.id.id
  ver = sd.id.verNum
  # v5 only
  defectTriageId = sd.id.defectTriageId
  defectTriageVerNum = sd.id.defectTriageVerNum
  print " defectId = " + str(defectId) + " verNum = " + str(ver) + " defectTriageId = " + str(defectTriageId) + " defectTriageVerNum = " + str(defectTriageVerNum)
  # v4 and v5
  streamDefectId =  DefectServiceClient.factory.create("streamDefectIdDataObj")
  streamDefectId.id = defectId
  streamDefectId.verNum = ver
  # v5 only
  streamDefectId.defectTriageId = defectTriageId
  streamDefectId.defectTriageVerNum = defectTriageVerNum
  # v4 and v5
  defectStateCustomDO = DefectServiceClient.factory.create("defectStateCustomAttributeValueDataObj")
  attributeDef = DefectServiceClient.factory.create("attributeDefinitionIdDataObj")
  attributeVal = DefectServiceClient.factory.create("attributeValueIdDataObj")
  attributeDef.name = "My_Attribute"
  attributeVal.name = "Some Value"
  defectStateCustomDO.attributeDefinitionId = attributeDef
  defectStateCustomDO.attributeValueId = attributeVal
  defectStateSpecDO = DefectServiceClient.factory.create("defectStateSpecDataObj")
  defectStateSpecDO.defectStateCustomAttributeValues = defectStateCustomDO
  defectStateSpecDO.comment = "Special"
  # v4 only
  #DefectServiceClient.service.updateStreamDefects(streamDefectId, "*/*", defectStateSpecDO);
  # v5 only
  DefectServiceClient.service.updateStreamDefects(streamDefectId, defectStateSpecDO);
  #print defectStateSpecDO
  #print streamDefectId
#check on results
streamDefects = DefectServiceClient.service.getStreamDefects(cids, streamDefectFilter)
for sd in streamDefects:
  print "CID: " + str(sd.cid)
  for hi in sd.history:
  print hi

  • Re: updateStreamDefects with custom attributes
    Currently Being Moderated



    I tried the above example to add attribute. I get error


    suds.WebFault: Server raised fault: 'No attribute found for name My_Attribute.'


    I am using Web Services API v5 (6.0.x)


    How to fix this?




  • Re: updateStreamDefects with custom attributes
    Sunil Lala Explorer
    Currently Being Moderated

    I am getting the following errors when I try to run this:


    Traceback (most recent call last):

      File "./set_coverity_fields.py", line 30, in <module>

        ConfServiceClient = suds.client.Client(MyConfSrv, timeout=3600)

      File "/usr/lib/python2.6/site-packages/suds/client.py", line 112, in __init__

        self.wsdl = reader.open(url)

      File "/usr/lib/python2.6/site-packages/suds/reader.py", line 152, in open

        d = self.fn(url, self.options)

      File "/usr/lib/python2.6/site-packages/suds/wsdl.py", line 136, in __init__

        d = reader.open(url)

      File "/usr/lib/python2.6/site-packages/suds/reader.py", line 79, in open

        d = self.download(url)

      File "/usr/lib/python2.6/site-packages/suds/reader.py", line 101, in download

        return sax.parse(string=content)

      File "/usr/lib/python2.6/site-packages/suds/sax/parser.py", line 136, in parse


      File "/usr/lib64/python2.6/xml/sax/expatreader.py", line 107, in parse

        xmlreader.IncrementalParser.parse(self, source)

      File "/usr/lib64/python2.6/xml/sax/xmlreader.py", line 123, in parse


      File "/usr/lib64/python2.6/xml/sax/expatreader.py", line 211, in feed


      File "/usr/lib64/python2.6/xml/sax/handler.py", line 38, in fatalError

        raise exception

    xml.sax._exceptions.SAXParseException: <unknown>:1:0: not well-formed (invalid token)


    Any ideas?




More Like This

  • Retrieving data ...