1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Several more changes to suport python3 syntax.

This commit is contained in:
ian 2015-04-13 15:37:25 -04:00
parent a444a7f363
commit 1bdf0bb0d6
2 changed files with 5 additions and 5 deletions

View file

@ -19,7 +19,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import StringIO
from six.moves import StringIO
import json
import os
import random

View file

@ -98,7 +98,7 @@ class LookupModule(LookupBase):
pathdir = os.path.dirname(path)
if not os.path.isdir(pathdir):
try:
os.makedirs(pathdir, mode=0700)
os.makedirs(pathdir, mode=0o700)
except OSError as e:
raise AnsibleError("cannot create the path for the password lookup: %s (error was %s)" % (pathdir, str(e)))
@ -111,7 +111,7 @@ class LookupModule(LookupBase):
else:
content = password
with open(path, 'w') as f:
os.chmod(path, 0600)
os.chmod(path, 0o600)
f.write(content + '\n')
else:
content = open(path).read().rstrip()
@ -129,12 +129,12 @@ class LookupModule(LookupBase):
salt = self.random_salt()
content = '%s salt=%s' % (password, salt)
with open(path, 'w') as f:
os.chmod(path, 0600)
os.chmod(path, 0o600)
f.write(content + '\n')
# crypt not requested, remove salt if present
elif (encrypt is None and salt):
with open(path, 'w') as f:
os.chmod(path, 0600)
os.chmod(path, 0o600)
f.write(password + '\n')
if encrypt: