From 9c2f9f6a41a827497f9de4f1f92f9f3b4dd9fad8 Mon Sep 17 00:00:00 2001 From: Daniel Francis Date: Fri, 16 Nov 2012 17:38:32 +0000 Subject: Use logging when building bundles. Now it saves all in the dist directory. Signed-off-by: Daniel Francis --- diff --git a/desktopbuild.py b/desktopbuild.py index 1692020..2ea7edd 100644 --- a/desktopbuild.py +++ b/desktopbuild.py @@ -21,9 +21,23 @@ import sys import os sys.path.append(os.path.abspath('.')) +if not os.path.exists('./dist'): + os.mkdir('./dist') os.environ['INFO_L10N'] = '0' import tarfile import info +import logging +bundle_name = 'dist/%s-%s.tar.gz' % (info.name.replace(' ', ''), info.version) +log_file = '%s.log' % bundle_name +if os.path.exists(log_file): + os.remove(log_file) +logging.basicConfig(filename=log_file, level=logging.DEBUG) +print "Started log in %s" % log_file +logger = logging.getLogger('xo-bundler') +import time + +logger.debug('Log started on %s' % time.strftime('%c')) + ignore_ends = ['.pyc', '~', @@ -75,17 +89,18 @@ def packdir(path, newpath=None): else: new_path = list(os.path.split(filename)) if newpath: - global new_path if newpath != '.': new_path[0] = newpath manifest.append((filename, '/'.join(new_path))) - print '%s listed to pack' % filename + logger.info('%s listed to pack' % filename) packdir('./', '%s-%s' % (info.lower_name, info.version)) -tar = tarfile.open('./%s-%s.tgz' % (info.lower_name, - info.version), 'w:gz') +tar = tarfile.open(bundle_name, 'w:gz') for name, path in manifest: tar.add(name, path) - print 'Packed %s as %s' % (name, path) + logger.info('Packed %s as %s' % (name, path)) tar.close() + +logger.info('Closing log file') +print "Closed log file" diff --git a/xobuild.py b/xobuild.py index fd21c9c..8508bdc 100644 --- a/xobuild.py +++ b/xobuild.py @@ -21,9 +21,22 @@ import sys import os sys.path.append(os.path.abspath('.')) +if not os.path.exists('./dist'): + os.mkdir('./dist') os.environ['INFO_L10N'] = '0' import zipfile import info +import logging +bundle_name = 'dist/%s-%s.xo' % (info.name.replace(' ', ''), info.version) +log_file = '%s.log' % bundle_name +if os.path.exists(log_file): + os.remove(log_file) +logging.basicConfig(filename=log_file, level=logging.DEBUG) +print "Started log in %s" % log_file +logger = logging.getLogger('xo-bundler') +import time + +logger.debug('Log started on %s' % time.strftime('%c')) ignore_ends = ['.pyc', '~', @@ -75,17 +88,18 @@ def packdir(path, newpath=None): else: new_path = list(os.path.split(filename)) if newpath: - global new_path if newpath != '.': new_path[0] = newpath manifest.append((filename, '/'.join(new_path))) - print '%s listed to pack' % filename + logger.info('%s listed to pack' % filename) packdir('./', '%s.activity' % info.name.replace(' ', '')) -xofile = zipfile.ZipFile('./%s-%s.xo' % (info.name.replace(' ', ''), - info.version), 'w') +xofile = zipfile.ZipFile(bundle_name, 'w') for name, path in manifest: xofile.write(name, path) - print 'Packed %s as %s' % (name, path) + logger.info('Packed %s as %s' % (name, path)) xofile.close() + +logger.info('Closing log file') +print "Closed log file" -- cgit v0.9.1