def package(): if not os.path.exists(source_dir): print "%s directory does not exist" % source_dir sys.exit(1) elif not os.path.isdir(source_dir): print "%s exists, but it is not a directory" % source_dir sys.exit(1) print "Cleaning directory %s ..." % source_dir clean.clean_dir(source_dir) if os.path.exists(zip_archive): print "Deleting old package %s ..." % zip_archive os.remove(zip_archive) if os.path.exists(tar_archive): print "Deleting old package %s ..." % tar_archive os.remove(tar_archive) print "Packaging files ..." print " creating package %s ..." % zip_archive factory = zipfile.ZipFile(zip_archive, 'w', zipfile.ZIP_DEFLATED) zip_write(factory, source_dir) zip_write(factory, example_dir) zip_write(factory, install_script) zip_write(factory, readme_file) factory.close() print " creating package %s ..." % tar_archive factory = tarfile.open(tar_archive, 'w:%s' % tar_compression) factory.add(example_dir, '%s%s' % (tar_prefix, example_dir)) factory.add(source_dir, '%s%s' % (tar_prefix, source_dir)) factory.add(install_script, '%s%s' % (tar_prefix, install_script)) factory.add(readme_file, '%s%s' % (tar_prefix, readme_file)) factory.close()
if len(sys.argv) < 2: package_all = True else: for id in sys.argv[1:]: if id == 'all': package_all = True break else: package_ids[id] = True master_dir = os.getcwd() try: print "Cleaning..." for directory in clean_dirs: clean.clean_dir(directory) except IOError, e: raise ExMessage("Cleaning failed. %s" % e.__str__()) try: print "Compiling..." for directory in compile_dirs: compile.compile_dir(directory) except IOError, e: raise ExMessage("Compile failed. %s" % e.__str__()) try: print "Copying compiled directories..." for (id, source, destination) in copy_dirs_compiled: if (not package_all) and (not package_ids.has_key(id)): continue