Commit d01df033 authored by Łukasz Nowak's avatar Łukasz Nowak

Avoid code duplication.

As slapos.recipe.erp5 depends on Zope2 in order to generate Zope2 aware
scripts reuse this dependency and import needed method instead of
rewriting it.
parent 56abe3ca
...@@ -34,14 +34,7 @@ import sys ...@@ -34,14 +34,7 @@ import sys
import zc.buildout import zc.buildout
import zc.recipe.egg import zc.recipe.egg
import ConfigParser import ConfigParser
from Zope2.utilities.mkzopeinstance import write_inituser
# Taken from Zope2 egg
def write_inituser(fn, user, password):
fp = open(fn, "w")
pw = binascii.b2a_base64(hashlib.sha1(password).digest())[:-1]
fp.write('%s:{SHA}%s\n' % (user, pw))
fp.close()
os.chmod(fn, 0600)
class Recipe(BaseSlapRecipe): class Recipe(BaseSlapRecipe):
...@@ -452,8 +445,8 @@ class Recipe(BaseSlapRecipe): ...@@ -452,8 +445,8 @@ class Recipe(BaseSlapRecipe):
password = self.generatePassword() password = self.generatePassword()
# XXX Unhardcoded me please # XXX Unhardcoded me please
user = 'zope' user = 'zope'
write_inituser(os.path.join(self.erp5_directory, "inituser"), write_inituser(
user, password) os.path.join(self.erp5_directory, "inituser"), user, password)
self._createDirectory(self.erp5_directory) self._createDirectory(self.erp5_directory)
for directory in ( for directory in (
......
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