Commit 2e742fe5 authored by Hardik Juneja's avatar Hardik Juneja Committed by Julien Muchembled

Fix the monkeypatch in random.py to incorporate the recent changes in buildout 'get' function

Buildout commit in discussion:  nexedi/slapos.buildout@43839169

/reviewed-on nexedi/slapos!176
parent 04bac13a
...@@ -123,7 +123,6 @@ class Password(object): ...@@ -123,7 +123,6 @@ class Password(object):
""" """
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
options_get = options.get
self.create_once = options.get('create-once', 'True').lower() \ self.create_once = options.get('create-once', 'True').lower() \
in GenericBaseRecipe.TRUE_VALUES in GenericBaseRecipe.TRUE_VALUES
try: try:
...@@ -140,13 +139,21 @@ class Password(object): ...@@ -140,13 +139,21 @@ class Password(object):
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
if not passwd: if not passwd:
passwd = self.generatePassword(int(options_get('bytes', '8'))) passwd = self.generatePassword(int(options.get('bytes', '8')))
self.update = self.install self.update = self.install
self.passwd = passwd.strip('\n') self.passwd = passwd.strip('\n')
# Password must not go into .installed file, for 2 reasons: # Password must not go into .installed file, for 2 reasons:
# security of course but also to prevent buildout to always reinstall. # security of course but also to prevent buildout to always reinstall.
options.get = lambda option, *args, **kw: passwd \ def get(option, *args, **kw):
if option == 'passwd' else options_get(option, *args, **kw) return passwd if option == 'passwd' else options_get(option, *args, **kw)
try:
options_get = options._get
except AttributeError:
options_get = options.get
options.get = get
else:
options._get = get
generatePassword = staticmethod(generatePassword) generatePassword = staticmethod(generatePassword)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment