Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the safety child of strategy fails after saving a safety #57

Open
pierce27 opened this issue Nov 6, 2015 · 2 comments
Open

Comments

@pierce27
Copy link

pierce27 commented Nov 6, 2015

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',)"
@pswaminathan
Copy link
Contributor

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
Copy link
Contributor

Note that this also affects @amnoonan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants