повысить исключение xml.sax._exceptions.SAXParseException: <unknown>: 1: 0: неправильно сформировано (неверный токен) - PullRequest
2 голосов
/ 30 мая 2019

Я установил suds-jurko следующим образом, и когда я пытаюсь запустить свой скрипт, я сталкиваюсь с показанной ошибкой трассировки ... может ли кто-нибудь дать руководство по ее исправлению?

sudo pip install suds-jurko
Collecting suds-jurko
  Downloading https://files.pythonhosted.org/packages/bd/6f/54fbf0999a606680d27c69b1ad12dfff62768ecb9fe48524cebda6eb4423/suds-jurko-0.6.tar.bz2 (143kB)
    100% |████████████████████████████████| 153kB 2.6MB/s 
Installing collected packages: suds-jurko
  Running setup.py install for suds-jurko ... done
Successfully installed suds-jurko-0.6
You are using pip version 9.0.2, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Трассировка:

usernamesMBP2:$ python coverity.py 
Traceback (most recent call last):
  File "coverity.py", line 76, in <module>
    defectServiceClient = DefectServiceClient(host, port, ssl, username, password)
  File "coverity.py", line 48, in __init__
    WebServiceClient.__init__(self, 'defect', host, port, ssl, username, password)
  File "coverity.py", line 36, in __init__
    self.client = Client(self.wsdlFile)
  File "/Library/Python/2.7/site-packages/suds/client.py", line 115, in __init__
    self.wsdl = reader.open(url)
  File "/Library/Python/2.7/site-packages/suds/reader.py", line 150, in open
    d = self.fn(url, self.options)
  File "/Library/Python/2.7/site-packages/suds/wsdl.py", line 136, in __init__
    d = reader.open(url)
  File "/Library/Python/2.7/site-packages/suds/reader.py", line 74, in open
    d = self.download(url)
  File "/Library/Python/2.7/site-packages/suds/reader.py", line 100, in download
    return sax.parse(string=content)
  File "/Library/Python/2.7/site-packages/suds/sax/parser.py", line 133, in parse
    sax.parse(source)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 110, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 217, in feed
    self._err_handler.fatalError(exc)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:0: not well-formed (invalid token)
"

версия Python:

usernamesMBP2:pythonscripts gnakkala$ python --version
Python 2.7.10

coverity.py: -

from suds.client import Client
from suds.wsse import Security, UsernameToken
#
#For basic logging
import logging
logging.basicConfig()

import base64, zlib
#
# -----------------------------------------------------------------------------
class WebServiceClient:
    def __init__(self, webservice_type, host, port, ssl, username, password):
        url = ''
        if (ssl):
            url = 'https://' + host + ':' + port
        else:
            url = 'http://' + host + ':' + port
        if webservice_type == 'configuration':
            self.wsdlFile = url + '/ws/v9/configurationservice?wsdl'
        elif webservice_type == 'defect':
            self.wsdlFile = url + '/ws/v9/defectservice?wsdl'
        else:
            raise "unknown web service type: " + webservice_type

        self.client = Client(self.wsdlFile)
        self.security = Security()
        self.token = UsernameToken(username, password)
        self.security.tokens.append(self.token)
        self.client.set_options(wsse=self.security)

    def getwsdl(self):
        print(self.client)

# -----------------------------------------------------------------------------
class DefectServiceClient(WebServiceClient):
    def __init__(self, host, port, ssl, username, password):
        WebServiceClient.__init__(self, 'defect', host, port, ssl, username, password)

# -----------------------------------------------------------------------------
class ConfigServiceClient(WebServiceClient):
    def __init__(self, host, port, ssl, username, password):
        WebServiceClient.__init__(self, 'configuration', host, port, ssl, username, password)
    def getProjects(self):
        return self.client.service.getProjects()        

# -----------------------------------------------------------------------------
if __name__ == '__main__':
#-------------TODO
    #
    #------------connection details,   
    #To run these examples adjust these connection parameters 
    #to match your instance URL and credentials
    #
    #
    host = 'coverity-dev.sd.COMPANY.com'
    port = '8443'
    ssl = False
    username = 'username'
    password = 'password'       

    streamname = 'test'

#-------------end of TODO

    defectServiceClient = DefectServiceClient(host, port, ssl, username, password)
    configServiceClient = ConfigServiceClient(host, port, ssl, username, password)

#
#--------configservice calls---------------------------

    #---Mapping existing stream
    streamIdDO = configServiceClient.client.factory.create('streamIdDataObj')
    streamIdDO.name=streamname

    #---create new project and map existing stream to that project
    projectSpecIdDO = configServiceClient.client.factory.create('projectSpecDataObj')
    projectSpecIdDO.name='test'
    projectSpecIdDO.streams=streamIdDO
    configServiceClient.client.service.createProject(projectSpecIdDO)
...