All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: FAILING on FlightAware sample code
PostPosted: Wed Oct 12, 2016 1:34 pm 
Offline
LenaYemelyanov - FlightAware user avatar

Joined: Wed Oct 12, 2016 1:20 pm
Posts: 2
Hello,

This is my first time posting here. I'm trying to run through the sample code first before attempting my own project. I selected Python version that uses SOAPpy
Code:
from SOAPpy import Config, HTTPTransport, SOAPAddress, WSDL

username = 'myusername'
apiKey = '0axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

wsdlFile = 'http://flightxml.flightaware.com/soap/FlightXML2'

# This is a custom HTTP transport that allows Basic Authentication.
class myHTTPTransport(HTTPTransport):
    username = None
    passwd = None

    @classmethod
    def setAuthentication(cls,u,p):
        cls.username = u
        cls.passwd = p

    def call(self, addr, data, namespace, soapaction=None, encoding=None,
             http_proxy=None, config=Config):

        if not isinstance(addr, SOAPAddress):
            addr=SOAPAddress(addr, config)

        if self.username != None:
            addr.user = self.username+":"+self.passwd

        return HTTPTransport.call(self, addr, data, namespace, soapaction,
                                  encoding, http_proxy, config)


# Make a FlightXML server request.
myHTTPTransport.setAuthentication(username, apiKey)
DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport)

enroute = DF.Enroute('KSMO',10,'',0)

flights = enroute['enroute']

print "Aircraft en route to KSMO:"
for flight in flights:
    print "%s (%s) \t%s (%s)" % ( flight['ident'], flight['aircrafttype'],
                              flight['originName'], flight['origin'])


The code throws the exact same error for me using my username/apikey pair as it does for the sample stuff that was provided.

The error I get is as follows:

Code:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\XXXX\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)
  File "C:\XXXX\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)
  File "FlightAwareSample.py", line 42, in <module>
    DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport)
  File "C:\XXXX\Anaconda\lib\site-packages\SOAPpy\WSDL.py", line 85, in __init__
    self.wsdl = reader.loadFromString(str(wsdlsource))
  File "C:\XXXX\Anaconda\lib\site-packages\wstools\WSDLTools.py", line 52, in loadFromString
    return self.loadFromStream(StringIO(data))
TypeError: initial_value must be unicode or None, not str


Note: I've redacted some of the file paths

When I spoke with support they said that my username/apikey pair was correct. I do get the following error when I try to go to http://flightxml.flightaware.com/soap/FlightXML2 which is the wsdlFile

Quote:
Gone

The requested resource
/soap/FlightXML2
is no longer available on this server and there is no forwarding address. Please remove all references to this resource.


Any help you can offer would be much appreciated


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Wed Oct 12, 2016 2:01 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1421
Location: FlightAware WHQ
Try changing the path to the wsdl file to be:
http://flightxml.flightaware.com/soap/FlightXML2/wsdl


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Wed Oct 12, 2016 2:36 pm 
Offline
LenaYemelyanov - FlightAware user avatar

Joined: Wed Oct 12, 2016 1:20 pm
Posts: 2
Thank you for your reply. Same exact error message for the changed path. Unfortunately

Code:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\XXXX\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)
  File "C:\XXXX\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)
  File "FlightAwareSample.py", line 42, in <module>
    DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport)
  File "C:\XXXX\Anaconda\lib\site-packages\SOAPpy\WSDL.py", line 85, in __init__
    self.wsdl = reader.loadFromString(str(wsdlsource))
  File "C:\XXXX\Anaconda\lib\site-packages\wstools\WSDLTools.py", line 52, in loadFromString
    return self.loadFromStream(StringIO(data))
TypeError: initial_value must be unicode or None, not str


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Mon Oct 17, 2016 11:10 am 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1421
Location: FlightAware WHQ
Are you using Python 2 or Python 3? I believe that example will only work with Python 2.


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Wed Jan 11, 2017 11:22 am 
Offline
BSWeiss - FlightAware user avatar

Joined: Tue Jan 10, 2017 4:00 pm
Posts: 3
I'm getting a different error when I try and run the sample code for SOAP in Python. I changed the URL to include the /WSDL suffix and now I get this:

DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport)

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
DF = WSDL.Proxy(wsdlFile, transport=myHTTPTransport)
File "C:\Python27\lib\site-packages\SOAPpy\WSDL.py", line 97, in __init__
callinfo = wstools.WSDLTools.callInfoFromWSDL(port, operation.name)
File "C:\Python27\lib\site-packages\wstools\WSDLTools.py", line 1607, in callInfoFromWSDL
logger = logging.getLogger(__name__)
NameError: global name 'logging' is not defined


If I pass in a faulty URL in the WSDLFile argument I get a different error, which leads me to believe that WSDLTools is struggling somehow.


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Wed Jan 11, 2017 11:42 am 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1421
Location: FlightAware WHQ
That seems like you need to initialize the logging subsystem first? Did you make any other changes to the example to cause logging to be a requirement now?


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Wed Jan 11, 2017 12:11 pm 
Offline
BSWeiss - FlightAware user avatar

Joined: Tue Jan 10, 2017 4:00 pm
Posts: 3
I've made no changes, other than the URL and my own API key. It is possible that WSDLTools was has bee updated to require logging?

I'm in Python 2.7.13, WSTools 0.4.4


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Thu Jan 12, 2017 4:05 pm 
Offline
BSWeiss - FlightAware user avatar

Joined: Tue Jan 10, 2017 4:00 pm
Posts: 3
I gave up on SOAPpy. It works fine in suds.


Top
 Profile  
 
 Post subject: Re: FAILING on FlightAware sample code
PostPosted: Thu Mar 02, 2017 12:45 pm 
Offline
FlightAware Staff
conej730 - FlightAware user avatar

Joined: Sat Sep 13, 2008 11:00 pm
Posts: 12
The logging issue only exists with wstools 0.4.4. You'll need to either downgrade wstools to 0.4.3 or upgrade to 0.4.6. The 0.4.5 version has a different issue with SOAPpy where SOAPpy calls callInfoFromWSDL with the wrong number of arguments.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to: