From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id A596C1382C5 for ; Thu, 23 Jun 2016 21:21:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2944C1412D; Thu, 23 Jun 2016 21:21:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BBC281412D for ; Thu, 23 Jun 2016 21:21:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1866A340BFD for ; Thu, 23 Jun 2016 21:21:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3425B2411 for ; Thu, 23 Jun 2016 21:21:32 +0000 (UTC) From: "Sebastian Pipping" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sebastian Pipping" Message-ID: <1466716820.951ed36b0df62fd96640eee80c030f169adb5163.sping@gentoo> Subject: [gentoo-commits] proj/metagen:master commit in: metagen/ X-VCS-Repository: proj/metagen X-VCS-Files: metagen/main.py X-VCS-Directories: metagen/ X-VCS-Committer: sping X-VCS-Committer-Name: Sebastian Pipping X-VCS-Revision: 951ed36b0df62fd96640eee80c030f169adb5163 X-VCS-Branch: master Date: Thu, 23 Jun 2016 21:21:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: cf79c0e4-5d5e-43c5-9e87-9af98c45f702 X-Archives-Hash: 06a391729e195b3d1f57b8bf980a5001 commit: 951ed36b0df62fd96640eee80c030f169adb5163 Author: Sebastian Pipping pipping org> AuthorDate: Thu Jun 23 20:51:47 2016 +0000 Commit: Sebastian Pipping gentoo org> CommitDate: Thu Jun 23 21:20:20 2016 +0000 URL: https://gitweb.gentoo.org/proj/metagen.git/commit/?id=951ed36b No longer crash if herds.xml is missing (bug #577148) metagen/main.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/metagen/main.py b/metagen/main.py index a190733..235fb53 100755 --- a/metagen/main.py +++ b/metagen/main.py @@ -14,11 +14,14 @@ EXAMPLES - man metagen import re import os import sys +import tempfile from argparse import ArgumentParser from commands import getstatusoutput +from textwrap import dedent from portage import config -from portage.output import red, blue +from portage.exception import FileNotFound +from portage.output import red, blue, yellow try: # portage <2.2.22 @@ -32,7 +35,6 @@ from metagen.version import __version__ from metagen import metagenerator PORTDIR = config(local_config=False)["PORTDIR"] -HB = herdbase.make_herd_base(os.path.sep.join([PORTDIR, 'metadata', 'herds.xml'])) # GLEP 67 _MAINTAINER_TYPE_PERSON = 'person' @@ -68,6 +70,20 @@ def parse_echangelog_variable(name, email): name = my_name return name, email +def check_herds(herds): + herds_xml_path = os.path.sep.join([PORTDIR, 'metadata', 'herds.xml']) + try: + HB = herdbase.make_herd_base(herds_xml_path) + except FileNotFound as e: # bug 577148 + print yellow('!!! Warning. Herd names could not be checked ' + 'against the list of known herds as ' + 'file "%s" was not found.' % e.value) + else: + for herd in herds: + if not HB.known_herd(herd): + print red("!!! Error. Herd %s does not exist." % herd) + sys.exit(1) + def generate_xml(options): """Returns metadata.xml text""" @@ -76,12 +92,8 @@ def generate_xml(options): if options.herd: herds = options.herd.split(",") + check_herds(herds) - for herd in herds: - if not HB.known_herd(herd): - print red("!!! Error. Herd %s does not exist." % herd) - sys.exit(1) - metadata.set_herd(herds) if options.echangelog: