"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildandrun" between
cheetah3-3.2.2.tar.gz and cheetah3-3.2.3.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

buildandrun  (cheetah3-3.2.2):buildandrun  (cheetah3-3.2.3)
#!/usr/bin/env python #!/usr/bin/env python
import logging import logging
import os import os
import os.path import os.path
import shutil
import subprocess import subprocess
import sys import sys
from optparse import OptionParser from optparse import OptionParser
if os.getenv('DEBUG'): if os.getenv('DEBUG'):
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
def recursiverm(d): def recursiverm(d):
for root, dirs, files in os.walk(d): for root, dirs, files in os.walk(d):
for f in files: for f in files:
f = root + os.path.sep + f f = root + os.path.sep + f
logging.debug('Removing file: %s' % f) logging.debug('Removing file: %s' % f)
os.unlink(f) os.unlink(f)
def main(): def main():
op = OptionParser() op = OptionParser()
op.add_option('-c', '--clean', dest='clean', action='store_true', op.add_option('-c', '--clean', dest='clean', action='store_true',
help='Remove the contents of the build directory') help='Remove the contents of the build directory')
opts, args = op.parse_args() opts, args = op.parse_args()
if not args: if not args:
print('Specify a test script') print('Specify a test script')
return sys.exit(1)
if opts.clean: if opts.clean:
logging.debug('Removing build/') logging.debug('Removing build/')
recursiverm('build') recursiverm('build')
logging.debug('Building Cheetah') logging.debug('Building Cheetah')
rc = subprocess.call((sys.executable, 'setup.py', 'build')) rc = subprocess.call((sys.executable, 'setup.py', 'build'))
if rc: if rc:
logging.debug('Build failed!') logging.debug('Build failed!')
return sys.exit(rc)
logging.debug('Adjusting PATH and PYTHONPATH') logging.debug('Adjusting PATH and PYTHONPATH')
cwd = os.getcwd() cwd = os.getcwd()
libdir = None libdir = None
scriptdir = None scriptdir = None
py_ver = '-' + '.'.join([str(v) for v in sys.version_info[:2]]) py_ver = '-' + '.'.join([str(v) for v in sys.version_info[:2]])
for sub in os.listdir('build'): for sub in os.listdir('build'):
if not sub.endswith(py_ver): if not sub.endswith(py_ver):
continue continue
if sub.startswith('scripts'): if sub.startswith('scripts'):
scriptdir = os.path.sep.join((cwd, 'build', sub)) scriptdir = os.path.sep.join((cwd, 'build', sub))
if sub.startswith('lib'): if sub.startswith('lib'):
libdir = os.path.sep.join((cwd, 'build', sub)) libdir = os.path.sep.join((cwd, 'build', sub))
# Copy test templates to the ``build/lib`` directory
tmpldir = os.path.join('Cheetah', 'Tests', 'ImportHooksTemplates')
libtmpldir = os.path.join(libdir, tmpldir)
if not os.path.exists(os.path.join(libtmpldir, 'index.tmpl')):
if os.path.exists(libtmpldir):
shutil.rmtree(libtmpldir)
shutil.copytree(tmpldir, libtmpldir)
newpath = '%s:%s' % (scriptdir, os.getenv('PATH')) newpath = '%s:%s' % (scriptdir, os.getenv('PATH'))
logging.debug('Setting PATH to: %s' % newpath) logging.debug('Setting PATH to: %s' % newpath)
os.putenv('PATH', newpath) os.putenv('PATH', newpath)
logging.debug('Setting PYTHONPATH to: %s' % libdir) logging.debug('Setting PYTHONPATH to: %s' % libdir)
os.putenv('PYTHONPATH', libdir) os.putenv('PYTHONPATH', libdir)
rc = subprocess.call( [sys.executable] + args ) script = args[0]
if os.access(script, os.X_OK):
rc = subprocess.call([sys.executable] + args)
else:
script = os.path.splitext(script)[0]
module = script.replace(os.sep, '.')
args[0] = module
os.chdir(libdir) # To avoid importing ``Cheetah`` from the current dir
rc = subprocess.call([sys.executable, '-m', 'unittest'] + args)
if rc == -11: if rc == -11:
logging.error('Segmentation fault in test process. Test failed.') logging.error('Segmentation fault in test process. Test failed.')
sys.exit(rc) sys.exit(rc)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
 End of changes. 7 change blocks. 
5 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)