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

Problemas to run on python 2.6 #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi.

I'm trying to execute some examples about the Python DFP API, but I'm having 
problems on it to run:

My enviroment is a MAC OS 10.6  Snow Leopard with Python 2.6.1 installed, on 
trying to execute to get all placements that I have, the follow error appeared:

MacBook-de-Rogerio-Carrasqueira:dfp rgcarrasqueira$ 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 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 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.

Checking for the PyXML v.0.8.3

MacBook-de-Rogerio-Carrasqueira:dfp rgcarrasqueira$ sudo easy_install PyXML
Password:
Searching for PyXML
Best match: PyXML 0.8.4
Processing PyXML-0.8.4-py2.6-macosx-10.6-universal.egg
PyXML 0.8.4 is already the active version in easy-install.pth
Installing xmlproc_parse script to /usr/local/bin
Installing xmlproc_val script to /usr/local/bin

Using 
/Library/Python/2.6/site-packages/PyXML-0.8.4-py2.6-macosx-10.6-universal.egg
Processing dependencies for PyXML
Finished processing dependencies for PyXML

Finding for the error on the net, it can be relate in the fact of the version 
python 2.6 version does not support anymore. "BaseException class does not 
provide a way to store error message anymore. You'll have to implement it 
yourself."

So, due to this I would like to report a fix, or information about workaround 
on this issue.

Thanks

Rogério Carrasqueira

Original issue reported on code.google.com by rogerio....@gmail.com on 10 Nov 2010 at 3:19

GoogleCodeExporter commented 8 years ago
To fix this issue consider replacing the code at Class Error at Errors.py on 
common folder with:

class Error(Exception):

  """Implements Error.

  Responsible for handling error.
  """

  def _get_message(self): 
        return self._message

  def _set_message(self, message): 
        self._message = message

  message = property(_get_message, _set_message)

Original comment by rogerio....@gmail.com on 10 Nov 2010 at 4:49

GoogleCodeExporter commented 8 years ago
The problem about python 2.6 still remains regarding the second error where the 
api does not find the installation for PyXML, looking for a solution.

Original comment by rogerio....@gmail.com on 10 Nov 2010 at 4:51

GoogleCodeExporter commented 8 years ago
Are you using SOAPpy or ZSI? And which version?

Original comment by api.sgri...@gmail.com on 11 Nov 2010 at 1:18

GoogleCodeExporter commented 8 years ago
ZSI, the latest version

Original comment by rogerio....@gmail.com on 11 Nov 2010 at 1:25

GoogleCodeExporter commented 8 years ago
Could you be more specific? If by latest you mean v2.1, then that one isn't 
stable version and is not supported by the client library. The client library 
supports v2.0 of ZSI, which is the latest stable version.

Original comment by api.sgri...@gmail.com on 11 Nov 2010 at 1:31

GoogleCodeExporter commented 8 years ago
2.0-rc3 using command sudo easy_install ZSI

Original comment by rogerio....@gmail.com on 11 Nov 2010 at 2:54

GoogleCodeExporter commented 8 years ago
According to 
http://stackoverflow.com/questions/1272138/baseexception-message-deprecated-in-p
ython-2-6, it should also work if you rename the base message. Could you verify 
if this works?

class Error(Exception):

  """Implements Error.

  Responsible for handling error.
  """

  def __init__(self, msg):
    self.msg = msg

  def __str__(self):
    return str(self.msg)

  def __call__(self):
    return (self.msg,)

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

GoogleCodeExporter commented 8 years ago
Yes, it worked. The messages about deprecated errors doe not appear anymore:

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
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:
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: _________________________________ Wed Nov 17
09:52:30 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/v201010"><applicationName>DfpAp
i-Python-4.0.0|salesflow</applicationName><authToken>DQAAAH8AAADm_hEomn1nyn4Psy8
Uibuqi1_NukTVvc3ZXaIIHm7UbeSAvhycZXgdqjx4Iv44PXoe6vWPp6stJVSDseyHCjyM8BhBUMpP_HG
8wNLjbsS2YLQjgbkjcDcuyRg0HuoxPXqiN2yw3yByMRI58u_gLmoXCftxIhg_y_aNdjGya7JZmQ</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>
]

Rog�rio Carrasqueira

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

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:11

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 next couple of weeks. Thanks!

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