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

Set default permission mode via stat values #19

Merged
merged 3 commits into from
Dec 12, 2017
Merged

Set default permission mode via stat values #19

merged 3 commits into from
Dec 12, 2017

Conversation

brahmlower
Copy link
Contributor

The existing value is invalid python3, and will result in a difficult to track runtime error. To support compatibility with python2.x and 3.x, I've changed this to use permission bitmasks from the stat library.

I figured I'd get approval from someone in the team before merging.

@brahmlower brahmlower requested a review from a team December 11, 2017 09:55
@@ -59,7 +59,9 @@ def __init__(self, module):
self.path = os.path.expanduser(module.params['path'])
self.owner = module.params['owner']
self.group = module.params['group']
self.mode = module.params['mode'] if module.params['mode'] else 0644
# Python version agnostic way of setting permissions 0644
perm_0644 = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We require Python 2.7 so you can just write 0o644. Likely more understand than these flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize that format was compatible with both major versions. I agree it will be much more readable. I'll update the PR this evening.

@benwebber
Copy link
Collaborator

Thanks for submitting the PR. I'll look at the Docker build.

@benwebber benwebber merged commit 23fb03d into devops-coop:master Dec 12, 2017
@benwebber
Copy link
Collaborator

Thanks! Was this the only Python 3 incompatibility you found?

@brahmlower
Copy link
Contributor Author

Yup! I ran pylint for python versions 2 and 3 against it to double check. It might be worth including a lint check in the CI tests. I can dedicate some time to that if you think it'd be worth while.

@benwebber
Copy link
Collaborator

Sounds great. tox makes that really easy.

The Travis configuration is "generic", so we can't use tox-travis. But we can simply install it with pip and declare our Python versions manually.

Something like this would work:

[tox]
envlist = py27,py35,py36

[testenv]
deps =
  flake8
command = flake8 library/

We could also run ansible-playbook --syntax-check and ansible-lint in the tox environment. Mind creating a new issue?

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.

None yet

2 participants