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

Python 3 related fix in highstate_return.py #48997

Merged
merged 2 commits into from Aug 9, 2018

Conversation

Projects
None yet
3 participants
@AVeenstra
Contributor

AVeenstra commented Aug 8, 2018

In Python 3 key sets of dicts no longer support indexing:
TypeError: 'dict_keys' object does not support indexing

What does this PR do?

It makes the highstate returner function under Python 3.

What issues does this PR fix or reference?

Could not find any.

Previous Behavior

2018-08-08 11:37:53,693 [salt.utils.schedule:740 ][ERROR   ][26560] Unhandled exception running state.highstate
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 732, in handle_func
    self.returners[ret_str](ret)
  File "/usr/lib/python3/dist-packages/salt/returners/highstate_return.py", line 481, in returner
    _produce_output(report, failed, setup)
  File "/usr/lib/python3/dist-packages/salt/returners/highstate_return.py", line 434, in _produce_output
    _generate_html(report, string_file)
  File "/usr/lib/python3/dist-packages/salt/returners/highstate_return.py", line 270, in _generate_html
    _generate_html_table(data, out, 0)
  File "/usr/lib/python3/dist-packages/salt/returners/highstate_return.py", line 190, in _generate_html_table
    name = subdata.keys()[0]
TypeError: 'dict_keys' object does not support indexing

New Behavior

You get a mail about the highstate. Also when using Python 2.

Tests written?

No

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

Python 3 related fix in highstate_return.py
In Python 3 key sets of dicts no longer support indexing:
`TypeError: 'dict_keys' object does not support indexing`

@rallytime rallytime requested review from cachedout and terminalmage Aug 8, 2018

name = subdata.keys()[0]
value = subdata.values()[0]
name = list(subdata.keys())[0]
value = list(subdata.values())[0]

This comment has been minimized.

@terminalmage

terminalmage Aug 8, 2018

Member

How about using a generator, like so?

name = next(six.iterkeys(subdata))
value = next(six.itervalues(subdata))

This comment has been minimized.

@AVeenstra

AVeenstra Aug 8, 2018

Contributor

Now using an iterator as requested

@rallytime rallytime requested a review from terminalmage Aug 9, 2018

@rallytime rallytime merged commit c5f3fd6 into saltstack:2017.7 Aug 9, 2018

8 checks passed

WIP ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details

@AVeenstra AVeenstra deleted the AVeenstra:patch-1 branch Aug 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment