t1-python icon indicating copy to clipboard operation
t1-python copied to clipboard

Getting the safety child of strategy fails after saving a safety

Open pierce27 opened this issue 9 years ago • 2 comments

If you run the below code in interpreter:

>>> safety = t1.get('strategies', 319492, child='safety', full="*")
>>> safety.include = []
>>> safety.save()
>>> safety = t1.get('strategies', 319492, child='safety', full="*")

the last get will output following traceback:

File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/terminalone/service.py", line 433, in get
    entities, ent_count = super(T1, self)._get(PATHS['mgmt'], _url, params=_params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/terminalone/connection.py", line 81, in _get
    raise ClientError('Could not parse XML response: {!r}'.format(exc))
terminalone.errors.ClientError: "Could not parse XML response: ParseError('no element found: line 1, column 0',)"

pierce27 avatar Nov 06 '15 15:11 pierce27

So here is the problem—it's not consistent. For instance:

>>> td
TargetDimension(_type='target_dimension', parent='strategies', incldue=[], parent_id=683880, exclude=[], include=[TargetValue(_type='target_value', code='Laptop/Desktop', name='Laptop/Desktop', is_targetable=True, value=43000, target_dimension_id=24, id=301523)], id=24)
>>> td.include = []
>>> td.save()
>>> td.add(td.include, 301523)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/models/targetdimension.py", line 79, in add
    '/'.join(url))
  File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/connection.py", line 80, in _get
    raise ClientError('Could not parse XML response: {!r}'.format(exc))
terminalone.errors.ClientError: "Could not parse XML response: ParseError('no element found: line 1, column 0',)"
>>> td.add(td.include, 301523)
>>> td.save()
>>> td.include = []
>>> td.save()
>>> td.add(td.include, 301523)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/models/targetdimension.py", line 79, in add
    '/'.join(url))
  File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/connection.py", line 80, in _get
    raise ClientError('Could not parse XML response: {!r}'.format(exc))
terminalone.errors.ClientError: "Could not parse XML response: ParseError('no element found: line 1, column 0',)"
>>> td.response.request.headers
{'Connection': 'keep-alive', 'Cookie': 'adama_session=e8f8dfee49aaa36c908439d51dff09f4d8547d55', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 't1-python/1.0.4 python-requests/2.8.0'}
>>> td.response.request.url
'https://api.mediamath.com/api/v2.0/target_values/301523?api_key=removed'
>>> td.response.headers
{'Content-Length': '0', 'Connection': 'keep-alive', 'Server': 'Jetty(8.1.3.v20120522)'}
>>> td.response.status_code
400
>>> td.response.content
''

Here, it breaks on the first include, then works, then breaks again the next time. I've also had it break on save. I've also had it never break on the include.

We're looking into this. But it's not straightforward.

@Cawb07 @rolandcrosby

pswaminathan avatar Nov 10 '15 23:11 pswaminathan

Note that this also affects @amnoonan

pswaminathan avatar Feb 03 '16 23:02 pswaminathan