I’m running a python script to retrieve data from the Adwords API, and it runs successfully on a CentOS server. Using the same configuration file and script on a Ubuntu server, I get a unicode error. Is there some configuration setting that I need to change?
Traceback (most recent call last):
File "adwords_sync.py", line 230, in <module>
adwords = AdWords(config)
File "adwords_sync.py", line 37, in __init__
self.client = AdWordsClient(headers=config.api_headers, config=config.api_config, path=config.api_config['home'])
File "lib/python2.6/site-packages/adspygoogle/adwords/AdWordsClient.py", line 153, in __init__
SanityCheck.ValidateConfigXmlParser(self._config['xml_parser'])
File "lib/python2.6/site-packages/adspygoogle/common/SanityCheck.py", line 96, in ValidateConfigXmlParser
raise ValidationError(msg)
adspygoogle.common.Errors.ValidationError: Invalid input for <type 'unicode'> '1', expecting 1 or 2 of type <str>.
The configuration file is a JSON file:
{
...
"api_config": {
"home": "/srv/logs/pylons",
"log_home": "/srv/logs/pylons",
"soap_lib": "2",
"xml_parser": "1",
...
}
}
What could be causing the line “1” to throw a unicode error on the Ubuntu server (but not the CentOS server)?
Check your python, adsygoogle, and simplejson versions on each server. I’m guessing one of them is out of sync on one of your servers, causing AdWords to accept unicode strings on one but not the other (or causing the simplejson parse to generate unicode strings on one and not the other.)
Failing that, can you cast your values as str(), before passing to the adwords config parser?