public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/
Date: Fri,  9 Oct 2015 19:35:48 +0000 (UTC)	[thread overview]
Message-ID: <1444369076.fd78adf1f2155a76af380a5294954b253f4e1053.vapier@gentoo> (raw)

commit:     fd78adf1f2155a76af380a5294954b253f4e1053
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  9 05:37:56 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Oct  9 05:37:56 2015 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=fd78adf1

main: convert to new logging module

 catalyst/main.py | 104 +++++++++++++++++++++++--------------------------------
 1 file changed, 43 insertions(+), 61 deletions(-)

diff --git a/catalyst/main.py b/catalyst/main.py
index adae9a6..f33369b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,6 +7,7 @@
 # $Id$
 
 import argparse
+import datetime
 import os
 import sys
 
@@ -31,36 +32,36 @@ conf_values={}
 
 
 def version():
-	print get_version()
-	print "Copyright 2003-2008 Gentoo Foundation"
-	print "Copyright 2008-2012 various authors"
-	print "Distributed under the GNU General Public License version 2.1\n"
+	log.info(get_version())
+	log.info('Copyright 2003-%s Gentoo Foundation', datetime.datetime.now().year)
+	log.info('Copyright 2008-2012 various authors')
+	log.info('Distributed under the GNU General Public License version 2.1')
 
 def parse_config(myconfig):
 	# search a couple of different areas for the main config file
 	myconf={}
 	config_file=""
+	default_config_file = '/etc/catalyst/catalyst.conf'
 
 	# first, try the one passed (presumably from the cmdline)
 	if myconfig:
 		if os.path.exists(myconfig):
-			print "Using command line specified Catalyst configuration file, "+myconfig
+			log.notice('Using command line specified Catalyst configuration file: %s',
+				myconfig)
 			config_file=myconfig
 
 		else:
-			print "!!! catalyst: Could not use specified configuration file "+\
-				myconfig
-			sys.exit(1)
+			log.critical('Specified configuration file does not exist: %s', myconfig)
 
 	# next, try the default location
-	elif os.path.exists("/etc/catalyst/catalyst.conf"):
-		print "Using default Catalyst configuration file, /etc/catalyst/catalyst.conf"
-		config_file="/etc/catalyst/catalyst.conf"
+	elif os.path.exists(default_config_file):
+		log.notice('Using default Catalyst configuration file: %s',
+			default_config_file)
+		config_file = default_config_file
 
 	# can't find a config file (we are screwed), so bail out
 	else:
-		print "!!! catalyst: Could not find a suitable configuration file"
-		sys.exit(1)
+		log.critical('Could not find a suitable configuration file')
 
 	# now, try and parse the config file "config_file"
 	try:
@@ -69,8 +70,7 @@ def parse_config(myconfig):
 		myconf.update(myconfig.get_values())
 
 	except Exception:
-		print "!!! catalyst: Unable to parse configuration file, "+myconfig
-		sys.exit(1)
+		log.critical('Could not find parse configuration file: %s', myconfig)
 
 	# now, load up the values into conf_values so that we can use them
 	for x in list(confdefaults):
@@ -90,7 +90,7 @@ def parse_config(myconfig):
 	# print out any options messages
 	for opt in conf_values['options']:
 		if opt in option_messages:
-			print option_messages[opt]
+			log.info(option_messages[opt])
 
 	for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir",
 				"local_overlay"]:
@@ -102,7 +102,7 @@ def parse_config(myconfig):
 		conf_values["contents"] = myconf["contents"].replace("-", '_')
 
 	if "envscript" in myconf:
-		print "Envscript support enabled."
+		log.info('Envscript support enabled.')
 
 	# take care of any variable substitutions that may be left
 	for x in list(conf_values):
@@ -118,11 +118,8 @@ def import_module(target):
 	try:
 		mod_name = "catalyst.targets." + target
 		module = __import__(mod_name, [],[], ["not empty"])
-	except ImportError as e:
-		print "!!! catalyst: Python module import error: %s " % target + \
-			"in catalyst/targets/ ... exiting."
-		print "ERROR was: ", e
-		sys.exit(1)
+	except ImportError:
+		log.critical('Python module import error: %s', target, exc_info=True)
 	return module
 
 
@@ -278,7 +275,7 @@ def main():
 	parse_config(myconfig)
 
 	conf_values["options"].update(options)
-	#print "MAIN: conf_values['options'] =", conf_values["options"]
+	log.debug('conf_values[options] = %s', conf_values['options'])
 
 	# initialize our contents generator
 	contents_map = ContentsMap(CONTENTS_DEFINITIONS)
@@ -308,14 +305,13 @@ def main():
 
 		# First validate all the requested digests are valid keys.
 		if digests - valid_digests:
-			print
-			print "These are not a valid digest entries:"
-			print ', '.join(digests - valid_digests)
-			print "Valid digest entries:"
-			print ', '.join(sorted(valid_digests))
-			print
-			print "Catalyst aborting...."
-			sys.exit(2)
+			log.critical(
+				'These are not valid digest entries:\n'
+				'%s\n'
+				'Valid digest entries:\n'
+				'%s',
+				', '.join(digests - valid_digests),
+				', '.join(sorted(valid_digests)))
 
 		# Then check for any programs that the hash func requires.
 		for digest in digests:
@@ -326,37 +322,28 @@ def main():
 				if skip_missing:
 					digests.remove(digest)
 					continue
-				print
-				print "digest=" + digest
-				print "\tThe " + hash_map.hash_map[digest].cmd + \
-					" binary was not found. It needs to be in your system path"
-				print
-				print "Catalyst aborting...."
-				sys.exit(2)
+				log.critical(
+					'The "%s" binary needed by digest "%s" was not found. '
+					'It needs to be in your system path.',
+					hash_map.hash_map[digest].cmd, digest)
 
 		# Now reload the config with our updated value.
 		conf_values['digests'] = ' '.join(digests)
 
 	if "hash_function" in conf_values:
 		if conf_values["hash_function"] not in HASH_DEFINITIONS:
-			print
-			print conf_values["hash_function"]+\
-				" is not a valid hash_function entry"
-			print "Valid hash_function entries:"
-			print HASH_DEFINITIONS.keys()
-			print
-			print "Catalyst aborting...."
-			sys.exit(2)
+			log.critical(
+				'%s is not a valid hash_function entry\n'
+				'Valid hash_function entries:\n'
+				'%s', HASH_DEFINITIONS.keys())
 		try:
 			process.find_binary(hash_map.hash_map[conf_values["hash_function"]].cmd)
 		except process.CommandNotFound:
-			print
-			print "hash_function="+conf_values["hash_function"]
-			print "\tThe "+hash_map.hash_map[conf_values["hash_function"]].cmd + \
-				" binary was not found. It needs to be in your system path"
-			print
-			print "Catalyst aborting...."
-			sys.exit(2)
+			log.critical(
+				'The "%s" binary needed by hash_function "%s" was not found. '
+				'It needs to be in your system path.',
+				hash_map.hash_map[conf_values['hash_function']].cmd,
+				conf_values['hash_function'])
 
 	addlargs={}
 
@@ -370,25 +357,20 @@ def main():
 			cmdline.parse_lines(mycmdline)
 			addlargs.update(cmdline.get_values())
 		except CatalystError:
-			print "!!! catalyst: Could not parse commandline, exiting."
-			sys.exit(1)
+			log.critical('Could not parse commandline')
 
 	if "target" not in addlargs:
 		raise CatalystError("Required value \"target\" not specified.")
 
 	if os.getuid() != 0:
 		# catalyst cannot be run as a normal user due to chroots, mounts, etc
-		print "!!! catalyst: This script requires root privileges to operate"
-		sys.exit(2)
+		log.critical('This script requires root privileges to operate')
 
 	# everything is setup, so the build is a go
 	try:
 		success = build_target(addlargs)
 	except KeyboardInterrupt:
-		print "\nCatalyst build aborted due to user interrupt ( Ctrl-C )"
-		print
-		print "Catalyst aborting...."
-		sys.exit(2)
+		log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
 	if not success:
 		sys.exit(2)
 	sys.exit(0)


             reply	other threads:[~2015-10-09 19:35 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 19:35 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-07-30 11:08 [gentoo-commits] proj/catalyst:master commit in: catalyst/ Andreas K. Hüttel
2022-11-20  0:21 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2022-11-17 23:42 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2022-02-16 22:34 Matt Turner
2021-06-11  3:30 Matt Turner
2021-06-10  0:48 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2021-02-20 21:27 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2021-02-20 21:27 Matt Turner
2021-01-29 23:50 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2021-01-28  2:41 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-11-14 16:37 Matt Turner
2020-10-30 22:41 Matt Turner
2020-10-30 22:41 Matt Turner
2020-10-08 21:17 Matt Turner
2020-06-05 21:13 Matt Turner
2020-05-21 20:26 Matt Turner
2020-05-21 20:25 Matt Turner
2020-05-21 20:25 Matt Turner
2020-05-21 20:25 Matt Turner
2020-05-20  3:39 [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-21 20:25 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20  1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-21 20:25 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20  1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-21 20:25 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20  1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-21 20:25 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20  1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-21 20:25 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-04-30 22:56 Matt Turner
2020-04-30 22:56 Matt Turner
2020-04-30 22:56 Matt Turner
2020-04-22  5:52 Matt Turner
2020-04-22  5:52 Matt Turner
2020-04-22  5:52 Matt Turner
2020-04-17 19:52 Matt Turner
2020-04-17 19:52 Matt Turner
2020-04-10 21:04 Matt Turner
2019-10-20  0:00 Matt Turner
2019-08-26 16:52 Matt Turner
2019-06-16 18:35 Matt Turner
2019-02-05  3:02 Matt Turner
2018-10-02 15:57 Brian Dolbec
2018-10-01 16:30 Brian Dolbec
2018-09-12  6:43 Brian Dolbec
2018-07-21 18:54 Brian Dolbec
2017-12-30 18:25 Brian Dolbec
2017-12-29  2:27 Brian Dolbec
2017-12-29  0:35 Brian Dolbec
2017-12-07  7:24 Brian Dolbec
2017-12-07  7:21 Brian Dolbec
2017-12-06 18:51 Robin H. Johnson
2017-11-22 15:52 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2017-11-29 17:20 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2017-03-14 20:52 Mike Frysinger
2016-06-25 15:46 Brian Dolbec
2016-05-22  3:48 Mike Frysinger
2016-05-22  3:36 Mike Frysinger
2016-02-17  5:26 Brian Dolbec
2016-02-11 13:59 Mike Frysinger
2016-02-02  6:11 Brian Dolbec
2016-02-02  6:11 Brian Dolbec
2015-12-18  1:53 Mike Frysinger
2015-12-18  1:53 Mike Frysinger
2015-11-21  1:33 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-11-09  2:06 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-10-29  0:28 Mike Frysinger
2015-10-28 16:50 Mike Frysinger
2015-10-28 16:50 Mike Frysinger
2015-10-24  6:58 Mike Frysinger
2015-10-24  6:58 Mike Frysinger
2015-10-24  6:58 Mike Frysinger
2015-10-11 17:26 Mike Frysinger
2015-10-11 17:26 Mike Frysinger
2015-10-09 21:06 Mike Frysinger
2015-10-09 21:06 Mike Frysinger
2015-10-09 21:06 Mike Frysinger
2015-10-09 20:08 Mike Frysinger
2015-10-09 19:35 Mike Frysinger
2015-10-09 19:35 Mike Frysinger
2015-10-08 22:20 Mike Frysinger
2015-10-08 22:11 Mike Frysinger
2015-10-08 17:19 Mike Frysinger
2015-10-06 17:03 Mike Frysinger
2015-10-06 17:03 Mike Frysinger
2015-10-06 15:31 Mike Frysinger
2015-10-06 15:31 Mike Frysinger
2015-10-06 15:31 Mike Frysinger
2015-10-06 15:31 Mike Frysinger
2015-10-06 13:46 Mike Frysinger
2015-10-06 13:46 Mike Frysinger
2015-10-06 13:46 Mike Frysinger
2015-10-06 13:46 Mike Frysinger
2015-10-06 13:46 Mike Frysinger
2015-09-08 14:14 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-08 14:17 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-06 21:21 Brian Dolbec
2015-09-06 21:18 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-06 21:21 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  5:58 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-01  4:50 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  5:58 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-01  4:50 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  4:50 Brian Dolbec
2015-08-31  3:16 Richard Farina
2015-08-30 20:58 Brian Dolbec
2015-08-30  2:15 Brian Dolbec
2015-08-29 16:20 Brian Dolbec
2015-08-29 16:11 Brian Dolbec
2015-08-29 14:41 Brian Dolbec
2015-05-24  0:08 Brian Dolbec
2015-02-26 20:44 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 22:18 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 20:44 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 22:18 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 19:25 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26  4:12 Brian Dolbec
2015-01-01  5:59 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26  4:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01  5:59 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01  5:59 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26  4:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01  5:59 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26  4:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01  5:59 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26  4:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-09-11  3:26 Brian Dolbec
2014-09-11  3:26 Brian Dolbec
2014-05-05 19:17 Brian Dolbec
2014-04-02 20:09 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-05-05 19:17 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-04-02 20:09 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-05-05 19:17 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-04-02 20:09 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-05-05 19:17 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-03-22 22:25 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-03-02 22:55 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444369076.fd78adf1f2155a76af380a5294954b253f4e1053.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox