diff --git a/buildout.cfg b/buildout.cfg index 6737ab6bd9..e2bb8e7bc5 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -58,7 +58,7 @@ eggs = ZServer [zopepy] recipe = zc.recipe.egg -interpreter = ${tox:env} +interpreter = zopepy eggs = Zope2 @@ -131,7 +131,7 @@ eggs = [allpy] recipe = zc.recipe.egg eggs = ${alltests:eggs} -interpreter = all${tox:env} +interpreter = allpy [sphinx] diff --git a/src/Zope2/utilities/copyzopeskel.py b/src/Zope2/utilities/copyzopeskel.py index 3f1f346fcd..15f9954f65 100755 --- a/src/Zope2/utilities/copyzopeskel.py +++ b/src/Zope2/utilities/copyzopeskel.py @@ -65,8 +65,6 @@ import sys import getopt -CVS_DIRS = [os.path.normcase("CVS"), os.path.normcase(".svn")] - def main(): try: @@ -180,8 +178,8 @@ def copyskel(sourcedir, targetdir, uid, gid, **replacements): os.chdir(sourcedir) try: try: - os.path.walk(os.curdir, copydir, - (targetdir, replacements, uid, gid)) + for root, dirs, files in os.walk(os.curdir): + copydir(root, dirs, files, targetdir, replacements, uid, gid) finally: os.chdir(pwd) except (IOError, OSError) as msg: @@ -189,40 +187,34 @@ def copyskel(sourcedir, targetdir, uid, gid, **replacements): sys.exit(1) -def copydir(args, sourcedir, names): - targetdir, replacements, uid, gid = args - # Don't recurse into CVS directories: - for name in names[:]: - if os.path.normcase(name) in CVS_DIRS: - names.remove(name) - elif os.path.isfile(os.path.join(sourcedir, name)): - # Copy the file: - sn, ext = os.path.splitext(name) - if os.path.normcase(ext) == ".in": - dst = os.path.join(targetdir, sourcedir, sn) - if os.path.exists(dst): - continue - copyin(os.path.join(sourcedir, name), dst, replacements, uid, - gid) - if uid is not None: - os.chown(dst, uid, gid) - else: - src = os.path.join(sourcedir, name) - dst = os.path.join(targetdir, src) - if os.path.exists(dst): - continue - shutil.copyfile(src, dst) - shutil.copymode(src, dst) - if uid is not None: - os.chown(dst, uid, gid) +def copydir(sourcedir, dirs, files, targetdir, replacements, uid, gid): + for name in dirs: + dn = os.path.abspath(os.path.join(targetdir, sourcedir, name)) + if not os.path.exists(dn): + os.mkdir(dn) + shutil.copymode(os.path.join(sourcedir, name), dn) + if uid is not None: + os.chown(dn, uid, gid) + + for name in files: + sn, ext = os.path.splitext(name) + if os.path.normcase(ext) == ".in": + dst = os.path.join(targetdir, sourcedir, sn) + if os.path.exists(dst): + continue + copyin(os.path.join(sourcedir, name), dst, replacements, uid, + gid) + if uid is not None: + os.chown(dst, uid, gid) else: - # Directory: - dn = os.path.join(targetdir, sourcedir, name) - if not os.path.exists(dn): - os.mkdir(dn) - shutil.copymode(os.path.join(sourcedir, name), dn) - if uid is not None: - os.chown(dn, uid, gid) + src = os.path.join(sourcedir, name) + dst = os.path.abspath(os.path.join(targetdir, src)) + if os.path.exists(dst): + continue + shutil.copyfile(src, dst) + shutil.copymode(src, dst) + if uid is not None: + os.chown(dst, uid, gid) def copyin(src, dst, replacements, uid, gid): @@ -246,5 +238,6 @@ def usage(stream, msg=None): program = os.path.basename(sys.argv[0]) stream.write(__doc__ % {"program": program}) + if __name__ == '__main__': main() diff --git a/src/Zope2/utilities/mkwsgiinstance.py b/src/Zope2/utilities/mkwsgiinstance.py index 3389755efb..ecc79a614a 100644 --- a/src/Zope2/utilities/mkwsgiinstance.py +++ b/src/Zope2/utilities/mkwsgiinstance.py @@ -189,7 +189,7 @@ def write_inituser(fn, user, password): import binascii from hashlib import sha1 as sha fp = open(fn, "w") - pw = binascii.b2a_base64(sha(password).digest())[:-1] + pw = binascii.b2a_base64(sha(password.encode('utf-8')).digest())[:-1] fp.write('%s:{SHA}%s\n' % (user, pw)) fp.close() os.chmod(fn, 0o644) @@ -209,7 +209,7 @@ def get_zope2path(python): """ Get Zope2 path from selected Python interpreter. """ zope2file = '' - p = os.popen('"%s" -c"import Zope2; print Zope2.__file__"' % python) + p = os.popen('"%s" -c"import Zope2; print(Zope2.__file__)"' % python) try: zope2file = p.readline()[:-1] finally: @@ -220,5 +220,6 @@ def get_zope2path(python): zope2file = Zope2.__file__ return os.path.abspath(os.path.dirname(os.path.dirname(zope2file))) + if __name__ == "__main__": main() diff --git a/util.py b/util.py index a97b26adb9..71a5673ca2 100644 --- a/util.py +++ b/util.py @@ -1,6 +1,10 @@ -from ConfigParser import RawConfigParser import os +try: + from configparser import RawConfigParser +except ImportError: + from ConfigParser import RawConfigParser + HERE = os.path.abspath(os.path.dirname(__file__)) @@ -31,7 +35,7 @@ def generate(in_, out): continue requirements.append('%s==%s\n' % (name, pin)) - with open(out_file, 'wb') as fd: + with open(out_file, 'w') as fd: fd.write(zope_requirement) for req in sorted(requirements): fd.write(req)