def main(): usage = """usage: %prog [options] PROJECT_NAME Submit change information to Goanna server. This is meant to be run from a Git post-receive hook script.""" from optparse import OptionParser fallback_config = os.path.join(os.getcwd(), "goanna_client_config.py") parser = OptionParser(usage=usage) parser.add_option("-c", "--config-file", help="Configuration file to use", dest="cfg_file", metavar="FILE") try: (opts, (project)) = parser.parse_args() except: return parser.print_help() try: if not opts.cfg_file: raise UsageError("Config file not specified") client = GoannaClient.load_using_config(opts.cfg_file) parser = GitRefListParser(sys.stdin) client.add_changes(parser.get_changes(project)) client.submit() except (UsageError, ConnectionError) as E: sys.stderr.write("ERROR: %s\n" % E) return 1