hockeyprincess / google-api-dfp-python

Automatically exported from code.google.com/p/google-api-dfp-python
Apache License 2.0
0 stars 0 forks source link

Problems to connect with API #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

On trying to execute the sample code get_all_placements.py the following error 
appeared:

$ python get_all_placements.py 

Traceback (most recent call last):
  File "get_all_placements.py", line 39, in <module>
    placements = DfpUtils.GetAllEntitiesByStatement(client, 'Placement')
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpUtils.py", line 96, in GetAllEntitiesByStatement
    % method_name)
  File "<string>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/PlacementService.py", line 151, in GetPlacementsByStatement
    request)
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 193, in CallMethod
    self.__ManageSoap(buf, start_time, stop_time, error)
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 118, in __ManageSoap
    raise Error(e)
adspygoogle.common.Errors.Error: 
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/adspygoogle/common/WebService.py", line 208, in CallMethod
    eval('service.%s(request)' % method_name))
  File "<string>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/zsi/v201004/PlacementService_services.py", line 69, in getPlacementsByStatement
    self.binding.Send(None, None, request, soapaction="", **kw)
  File "build/bdist.macosx-10.6-universal/egg/ZSI/client.py", line 267, in Send
    self.SendSOAPData(soapdata, url, soapaction, **kw)
  File "build/bdist.macosx-10.6-universal/egg/ZSI/client.py", line 301, in SendSOAPData
    self.h.send(soapdata)
  File "/Library/Python/2.6/site-packages/adspygoogle/common/zsi/HttpsConnectionHandler.py", line 93, in send
    httplib.HTTPSConnection.endheaders(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 868, in endheaders
    self._send_output()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 740, in _send_output
    self.send(msg)
  File "/Library/Python/2.6/site-packages/adspygoogle/common/zsi/HttpsConnectionHandler.py", line 93, in send
    httplib.HTTPSConnection.endheaders(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 866, in endheaders
    raise CannotSendHeader()
CannotSendHeader [RAW DATA: _________________________________ Thu Nov 11 
11:10:17 2010 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header>
        <RequestHeader xmlns="https://www.google.com/apis/ads/publisher/v201004">
            <applicationName>DfpApi-Python-3.2.0|salesflow</applicationName>
            <authToken>DQAAAIAAAABIpVxXY5_deHvXML-epqpVDJ0qASjdvroK_ZNk3wvqRc3shxQ4_ZytGBAP7FxqFqa3AZV00VibiZAopu79flMDCQGgdd5vzPF0-8mBZDxWx5-3ttBH7JDGAfm6hStvAH9VWlBYtJS7KhJpBATnTvqTRpL28sSSbMYX_agMP6BoWA</authToken>
        </RequestHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body xmlns:ns1="https://www.google.com/apis/ads/publisher/v201004">
        <ns1:getPlacementsByStatement xmlns:ns1="https://www.google.com/apis/ads/publisher/v201004">
            <ns1:filterStatement xsi:type="ns1:Statement">
                <ns1:query> LIMIT 500 OFFSET 0</ns1:query>
            </ns1:filterStatement>
        </ns1:getPlacementsByStatement>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
]

Using python 2.6 without google app engine, with PyXML 0.8.4 and ZSI 2.0-rc3 on 
MAC OS X 10.6

Original issue reported on code.google.com by rogerio....@gmail.com on 11 Nov 2010 at 1:56

GoogleCodeExporter commented 8 years ago
Could you try again with the latest version of the library (4.0.0) and let me 
know if you still seeing the same error?

Original comment by api.sgri...@gmail.com on 16 Nov 2010 at 12:17

GoogleCodeExporter commented 8 years ago
Sorry, cannot test, the error about exception reported at ticket 1 raised 
again. Please, fix it before ask again.

Using python 2.6, pyxml 0.8.4

python get_all_placements.py
/Library/Python/2.6/site-packages/adspygoogle/common/Errors.py:30: 
DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  self.message = msg
Traceback (most recent call last):
  File "get_all_placements.py", line 39, in <module>
    placements = DfpUtils.GetAllEntitiesByStatement(client, 'Placement')
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpUtils.py", line 100, in GetAllEntitiesByStatement
    % method_name)
  File "<string>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/PlacementService.py", line 151, in GetPlacementsByStatement
    request)
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 146, in CallMethod
    pretty_xml=Utils.BoolTypeConvert(config['pretty_xml']))
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpSoapBuffer.py", line 39, in __init__
    super(DfpSoapBuffer, self).__init__(xml_parser, pretty_xml)
  File "/Library/Python/2.6/site-packages/adspygoogle/common/SoapBuffer.py", line 137, in __init__
    raise MissingPackageError(msg)
adspygoogle.common.Errors.MissingPackageError/Library/Python/2.6/site-packages/a
dspygoogle/common/Errors.py:33: DeprecationWarning: BaseException.message has 
been deprecated as of Python 2.6
  return str(self.message)
: PyXML v0.8.3 or newer is required.

Original comment by rogerio....@gmail.com on 16 Nov 2010 at 12:48

GoogleCodeExporter commented 8 years ago
It seems like the PyXML you have is not being picked up by your Python 
instance. Could you do the following test and let me know the details?

$ python
>>> import xml
>>> xml.__name__

Original comment by sgrinb...@google.com on 16 Nov 2010 at 12:53

GoogleCodeExporter commented 8 years ago
As your wish, it follows:
$ python
Python 2.6.1 (r261:67515, Dec 17 2009, 00:59:15) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml
>>> xml.__name__
'xml'
>>> 

Original comment by rogerio....@gmail.com on 16 Nov 2010 at 12:25

GoogleCodeExporter commented 8 years ago
Fixing the line changing the code at adspygoogle/common/SoapBuffer.py at line 
51 where you have:

import xml as _xmlplus 

to

try
  import _xmlplus
except:
  import xml as _xmlplus.

As described before and you did not put at new patch, the error remains:

python get_all_placements.py 
/Library/Python/2.6/site-packages/adspygoogle/common/Errors.py:30: 
DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  self.message = msg
Traceback (most recent call last):
  File "get_all_placements.py", line 39, in <module>
    placements = DfpUtils.GetAllEntitiesByStatement(client, 'Placement')
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpUtils.py", line 100, in GetAllEntitiesByStatement
    % method_name)
  File "<string>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/PlacementService.py", line 151, in GetPlacementsByStatement
    request)
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 193, in CallMethod
    self.__ManageSoap(buf, start_time, stop_time, error)
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 118, in __ManageSoap
    raise Error(e)
adspygoogle.common.Errors.Error/Library/Python/2.6/site-packages/adspygoogle/com
mon/Errors.py:33: DeprecationWarning: BaseException.message has been deprecated 
as of Python 2.6
  return str(self.message)
: 
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/adspygoogle/common/WebService.py", line 208, in CallMethod
    eval('service.%s(request)' % method_name))
  File "<string>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/zsi/v201010/PlacementService_services.py", line 69, in getPlacementsByStatement
    self.binding.Send(None, None, request, soapaction="", **kw)
  File "build/bdist.macosx-10.6-universal/egg/ZSI/client.py", line 267, in Send
    self.SendSOAPData(soapdata, url, soapaction, **kw)
  File "build/bdist.macosx-10.6-universal/egg/ZSI/client.py", line 301, in SendSOAPData
    self.h.send(soapdata)
  File "/Library/Python/2.6/site-packages/adspygoogle/common/zsi/HttpsConnectionHandler.py", line 93, in send
    httplib.HTTPSConnection.endheaders(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 868, in endheaders
    self._send_output()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 740, in _send_output
    self.send(msg)
  File "/Library/Python/2.6/site-packages/adspygoogle/common/zsi/HttpsConnectionHandler.py", line 93, in send
    httplib.HTTPSConnection.endheaders(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 866, in endheaders
    raise CannotSendHeader()
CannotSendHeader [RAW DATA: _________________________________ Tue Nov 16 
10:31:15 2010 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><RequestH
eader 
xmlns="https://www.google.com/apis/ads/publisher/v201010"><applicationName>DfpAp
i-Python-4.0.0|salesflow</applicationName><authToken>DQAAAH4AAADVbPeuAd0StcunAG3
gFkrbSVjFKzx47p2aeOsc2vL5ZSKxfqSSc1OWcQbvQBgIgnF1YBIqkCBBgovsA47Scqor8ygE0Bdmz-C
woQeWGN6Lcr2rsfssSj3b8hTa4TuXHxacOVKH5kaXFlNNo-4VgMdSctI0VzGAcUBtE7byM04JRg</aut
hToken></RequestHeader></SOAP-ENV:Header><SOAP-ENV:Body 
xmlns:ns1="https://www.google.com/apis/ads/publisher/v201010"><ns1:getPlacements
ByStatement 
xmlns:ns1="https://www.google.com/apis/ads/publisher/v201010"><ns1:filterStateme
nt xsi:type="ns1:Statement"><ns1:query> LIMIT 500 OFFSET 
0</ns1:query></ns1:filterStatement></ns1:getPlacementsByStatement></SOAP-ENV:Bod
y></SOAP-ENV:Envelope>

Original comment by rogerio....@gmail.com on 16 Nov 2010 at 12:34

GoogleCodeExporter commented 8 years ago
I'm not convinced that's the right approach to fixing this issue. If your 
Python instance was using the right PyXML, then you should've seen the 
following:

>>> import xml
>>> xml.__name__
'_xmlplus'
>>>

Note the "_xmlplus" and not the "xml".

Could you try re installing the PyXML on your end and make sure that it is set 
up under the same Python instance you are using to call the script? In a 
meantime, I'll look into why this is happening.

Original comment by api.sgri...@gmail.com on 16 Nov 2010 at 3:25

GoogleCodeExporter commented 8 years ago
Springberg,

If I do:

$ python
Python 2.6.1 (r261:67515, Dec 17 2009, 00:59:15)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

'_xmlplus'

It proves that PyXML is installed.

MacBook-de-Rogerio-Carrasqueira:site-packages rgcarrasqueira$ pwd
/Library/Python/2.6/site-packages
MacBook-de-Rogerio-Carrasqueira:site-packages rgcarrasqueira$ ls -l PyXML*
total 0
drwxr-xr-x   9 root  admin  306 10 Nov 17:46 EGG-INFO
drwxr-xr-x  16 root  admin  544 10 Nov 17:46 _xmlplus

Please review the approach and accept my suggestion:

Cheers
Rog�rio Carrasqueira

Original comment by rogerio....@gmail.com on 16 Nov 2010 at 4:50

GoogleCodeExporter commented 8 years ago
I'm unable to reproduce this issue on my end, but if the patch works for you 
that's good enough ;-)

Before I can apply your patch, could you sign the CLA? We have individual and 
corporate. This only needs to  be done once, so that I can use your patches in 
our code.

http://code.google.com/legal/individual-cla-v1.0.html
http://code.google.com/legal/corporate-cla-v1.0.html

Original comment by api.sgri...@gmail.com on 17 Nov 2010 at 6:25

GoogleCodeExporter commented 8 years ago
Done,

It was signed on using the e-mail rogerio.carrasqueira@gmail.com
Rog�rio Carrasqueira

Original comment by rogerio....@gmail.com on 17 Nov 2010 at 11:48

GoogleCodeExporter commented 8 years ago
Great! I'll patch it in for the next release.

Original comment by api.sgri...@gmail.com on 23 Nov 2010 at 10:12

GoogleCodeExporter commented 8 years ago
Any news???

Original comment by rogerio....@gmail.com on 18 Jan 2011 at 6:46

GoogleCodeExporter commented 8 years ago
The next release is planned within couple of weeks. Thanks!

Original comment by api.sgri...@gmail.com on 27 Jan 2011 at 2:24

GoogleCodeExporter commented 8 years ago
After following this thread I was able to fix a lot of my problems, but once 
still remains ...

Traceback (most recent call last):
  File "get_all_ad_units.py", line 20, in <module>
    ad_units = inventory_service.GetAdUnitsByStatement(statement)[0]['results']
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/InventoryService.py", line 143, in GetAdUnitsByStatement
    return self.__service.CallMethod(method_name, (filter_statement))
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 193, in CallMethod
    self.__ManageSoap(buf, start_time, stop_time, error)
  File "/Library/Python/2.6/site-packages/adspygoogle/dfp/DfpWebService.py", line 118, in __ManageSoap
    raise Error(e)
adspygoogle.common.Errors.Error: call() got an unexpected keyword argument 
'timeout'

Also using python 2.6 without google app engine, with PyXML 0.8.4 and ZSI 
2.0-rc3 on MAC OS X 10.6.

Any word on the next release?

Original comment by te...@iknowmac.com on 26 Feb 2011 at 2:56