Skip to content

Windows Registry Unicode Support and PY2 character encoding (module.reg) - #32835

Merged
rallytime merged 3 commits into
saltstack:developfrom
damon-atkins:win-reg-unicode-py3
Apr 26, 2016
Merged

rallytime merged 3 commits into
saltstack:developfrom
damon-atkins:win-reg-unicode-py3

Conversation

@damon-atkins

@damon-atkins damon-atkins commented Apr 25, 2016 •

Copy link
Copy Markdown
Contributor

What does this PR do?

salt module reg (reg.py)

  • Start at PY3 support, however not tested against PY3
  • Change to Unicode including from future import unicode_literals
  • If PY2 converts all parameter input unicode to local encoding i.e. Unicode to String
  • If PY3 stays as Unicode as PY3 uses Windows Wide Char
  • Supports non-asiic characters i.e. > 126
  • All output is Unicode, before most of it was Unicode output
  • Added a safty check to recursive delete to try and prevent a mistake like removing all of SOFTWARE
  • Fixed all the pylint errors
  • add _ prefix to internal functions
  • Provided unit test see reg_win_test.py

reg_win_test.py

  • All tests currently make real changes to the registry
  • All changes are performed under SOFTWARE\SaltStackTest under HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER
  • Their is still room for more tests to be developed
  • Test target the new Unicode features of reg.py e.g. Copyright, Tradmark and Register characters
  • General the values set in the registy contain date/time and then checked that they are the current date/time to make sure they are not left over from old tests

What issues does this PR fix or reference?

*Current version did not support unicode input
*Output was mostly unicode, now all output should be unicode
*No Unit tests

Previous Behavior

Mixed Unicode Support
Not reliable Unicode Support
No PY3 support

New Behavior

PY3 Support (not tested)
Handles unicode parameter input.
Outputs only unicode

Tests written?

Yes

* Start at PY3 support, however not tested against PY3
* Change to Unicode including from __future__ import unicode_literals
* If PY2 converts all parameter input unicode to local encoding i.e. Unicode to String
* If PY3 stays as Unicode as PY3 uses Windows Wide Char
* Supports non-asiic characters i.e. > 126
* All output is Unicode, before most of it was Unicode output
* Added a safty check to recursive delete to try and prevent a mistake like removing all of SOFTWARE
* Fixed all the pylint errors
* add _ prefix to internal functions
* Provided unit test see reg_win_test.py
reg_win_test.py
* All tests currently make real changes to the registry
* All changes are performed under SOFTWARE\SaltStackTest under HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER
* Their is still room for more tests to be developed
* Test target the new Unicode features of reg.py e.g. Copyright, Tradmark and Register characters
* General the values set in the registy contain date/time and then checked that they are the current date/time to make sure they are not left over from old tests
@damon-atkins

Copy link
Copy Markdown
Contributor Author

FYI @hrumph @twangboy, @TheBigBear, @UtahDave @jfindlay

@rallytime

Copy link
Copy Markdown
Contributor

@damon-atkins It looks like one of the tests is failing from this change. Can you take a look?

@rallytime rallytime added the pending-discussion The issue or pull request needs more discussion before it can be closed or merged label Apr 25, 2016
@damon-atkins

damon-atkins commented Apr 26, 2016 •

Copy link
Copy Markdown
Contributor Author

How do I configure a test to only run on Windows only, as it does not make sense for it to run on Unix/Linux as it has resulted in the failed test runs, since _wnreg module does not exist on Unix/Linux

ImportError: Failed to import test module: unit.modules.reg_win_test
Traceback (most recent call last):
File "/testing/tests/unit/modules/reg_win_test.py", line 15, in
import _winreg
ImportError: No module named _winreg

Damon Atkins added 2 commits April 27, 2016 01:32
Removed some code which was commented out which is not required
@rallytime rallytime removed the pending-discussion The issue or pull request needs more discussion before it can be closed or merged label Apr 26, 2016
@rallytime
rallytime merged commit cf4826a into saltstack:develop Apr 26, 2016
@damon-atkins

Copy link
Copy Markdown
Contributor Author

Thanks for Merging it.

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

Successfully merging this pull request may close these issues.

2 participants