commit/galaxy-central: greg: Add script for merging specific local Galaxy config universe_wsgi.ini.cri with default Galaxy universe_wsgi.ini.sample contributed by Anne Pajon.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/28641bb41910/ changeset: 28641bb41910 user: greg date: 2012-03-27 16:19:04 summary: Add script for merging specific local Galaxy config universe_wsgi.ini.cri with default Galaxy universe_wsgi.ini.sample contributed by Anne Pajon. affected #: 1 file diff -r 7dc0e48e9105f19a564263c54684d51bee8ac16e -r 28641bb419101ca7d83f9d1ca92b134866155cf2 contrib/universe_merger.py --- /dev/null +++ b/contrib/universe_merger.py @@ -0,0 +1,71 @@ +#! /usr/bin/env python +''' +universe_merger.py + +Created by Anne Pajon on 31 Jan 2012 +Copyright (c) 2012 Cancer Research UK - Cambridge Research Institute. All rights reserved. + +Script for merging specific local Galaxy config universe_wsgi.ini.cri with default Galaxy universe_wsgi.ini.sample +''' +import ConfigParser +import sys +import optparse +import logging + +def main(): + # logging configuration + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) + + # get the options + parser = optparse.OptionParser() + parser.add_option("-s", "--sample", dest="sample", action="store", help="the path to the Galaxy universe_wsgi.ini.sample file") + parser.add_option("-c", "--config", dest="config", action="store", help="the path to your own universe_wsgi.ini.cri file") + parser.add_option("-o", "--output", dest="output", action="store", help="the path to the new merged universe_wsgi.ini file") + (options, args) = parser.parse_args() + + for option in ['sample', 'config']: + if getattr(options, option) == None: + print "Please supply a --%s parameter.\n" % (option) + parser.print_help() + sys.exit() + + config_sample = ConfigParser.RawConfigParser() + config_sample.read(options.sample) + config_sample_content = open(options.sample, 'r').read() + + config = ConfigParser.RawConfigParser() + config.read(options.config) + + logging.info("Merging your own config file %s into the sample one %s." % (options.config, options.sample)) + logging.info("---------- DIFFERENCE ANALYSIS BEGIN ----------") + for section in config.sections(): + if not config_sample.has_section(section): + logging.warning("-MISSING- section [%s] not found in sample file. It will be ignored." % section) + else: + for (name, value) in config.items(section): + if not config_sample.has_option(section, name): + if not "#%s" % name in config_sample_content: + logging.warning("-MISSING- section [%s] option '%s' not found in sample file. It will be ignored." % (section, name)) + else: + logging.info("-notset- section [%s] option '%s' not set in sample file. It will be added." % (section, name)) + config_sample.set(section, name, value) + else: + if not config_sample.get(section, name) == value: + logging.info("- diff - section [%s] option '%s' has different value ('%s':'%s'). It will be modified." % (section, name, config_sample.get(section, name), value)) + config_sample.set(section, name, value) + logging.info("---------- DIFFERENCE ANALYSIS END ----------") + + if options.output: + outputfile = open(options.output, 'w') + config_sample.write(outputfile) + outputfile.close() + else: + #print "----------" + #config_sample.write(sys.stdout) + #print "----------" + logging.info("use -o OUTPUT to write the merged configuration into a file.") + + logging.info("read Galaxy universe_wsgi.ini.sample for detailed information.") + +if __name__ == '__main__': + main() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket