--- __init__.py.old 2008-12-29 11:51:47.000000000 +0300 +++ __init__.py 2009-01-03 17:46:26.000000000 +0300 @@ -2514,7 +2514,7 @@ if x[0]=="+": # Not legal. People assume too much. Complain. - writemsg(red("USE flags should not start with a '+': %s\n" % x), + writemsg(colorize("BAD","USE flags should not start with a '+': %s\n" % x), noiselevel=-1) x=x[1:] if not x: @@ -3411,7 +3411,7 @@ if not os.access(mysettings["DISTDIR"],os.W_OK) and fetch_to_ro: if use_locks: - writemsg(red("!!! For fetching to a read-only filesystem, " + \ + writemsg(colorize("BAD","!!! For fetching to a read-only filesystem, " + \ "locking should be turned off.\n"), noiselevel=-1) writemsg("!!! This can be done by adding -distlocks to " + \ "FEATURES in /etc/make.conf\n", noiselevel=-1) @@ -7200,16 +7200,16 @@ deprecatedfile = open(deprecated_profile_file, "r") dcontent = deprecatedfile.readlines() deprecatedfile.close() - writemsg(red("\n!!! Your current profile is deprecated and not supported anymore.\n"), + writemsg(colorize("BAD","\n!!! Your current profile is deprecated and not supported anymore.\n"), noiselevel=-1) if not dcontent: - writemsg(red("!!! Please refer to the Gentoo Upgrading Guide.\n"), + writemsg(colorize("BAD","!!! Please refer to the Gentoo Upgrading Guide.\n"), noiselevel=-1) return True newprofile = dcontent[0] - writemsg(red("!!! Please upgrade to the following profile if possible:\n"), + writemsg(colorize("BAD","!!! Please upgrade to the following profile if possible:\n"), noiselevel=-1) - writemsg(8*" "+green(newprofile)+"\n", noiselevel=-1) + writemsg(8*" "+colorize("GOOD",newprofile)+"\n", noiselevel=-1) if len(dcontent) > 1: writemsg("To upgrade do the following steps:\n", noiselevel=-1) for myline in dcontent[1:]: @@ -7289,7 +7289,7 @@ timestamps = {} for mykey, mystat, mycontent in update_data: writemsg_stdout("\n\n") - writemsg_stdout(green("Performing Global Updates: ")+bold(mykey)+"\n") + writemsg_stdout(colorize("GOOD","Performing Global Updates: ")+bold(mykey)+"\n") writemsg_stdout("(Could take a couple of minutes if you have a lot of binary packages.)\n") writemsg_stdout(" " + bold(".") + "='update pass' " + \ bold("*") + "='binary update' " + bold("#") + \ --- data.py.old 2008-12-29 11:51:47.000000000 +0300 +++ data.py 2009-01-03 17:39:07.000000000 +0300 @@ -28,7 +28,7 @@ lchown = missingos.lchown except ImportError: def lchown(*pos_args, **key_args): - writemsg(red("!!!") + " It seems that os.lchown does not" + \ + writemsg(colorize("BAD", "!!!") + " It seems that os.lchown does not" + \ " exist. Please rebuild python.\n", noiselevel=-1) lchown() @@ -79,15 +79,15 @@ portage_uid=0 portage_gid=0 writemsg("\n") - writemsg( red("portage: 'portage' user or group missing. Please update baselayout\n")) - writemsg( red(" and merge portage user(250) and group(250) into your passwd\n")) - writemsg( red(" and group files. Non-root compilation is disabled until then.\n")) + writemsg( colorize("BAD","portage: 'portage' user or group missing. Please update baselayout\n")) + writemsg( colorize("BAD"," and merge portage user(250) and group(250) into your passwd\n")) + writemsg( colorize("BAD"," and group files. Non-root compilation is disabled until then.\n")) writemsg( " Also note that non-root/wheel users will need to be added to\n") writemsg( " the portage group to do portage commands.\n") writemsg("\n") writemsg( " For the defaults, line 1 goes into passwd, and 2 into group.\n") - writemsg(green(" portage:x:250:250:portage:/var/tmp/portage:/bin/false\n")) - writemsg(green(" portage::250:portage\n")) + writemsg(colorize("GOOD"," portage:x:250:250:portage:/var/tmp/portage:/bin/false\n")) + writemsg(colorize("GOOD"," portage::250:portage\n")) writemsg("\n") portage_group_warning() --- dbapi/__init__.py.old 2009-01-03 17:40:45.000000000 +0300 +++ dbapi/__init__.py 2009-01-03 17:42:05.000000000 +0300 @@ -8,7 +8,7 @@ import re from portage.dep import match_from_list from portage.locks import unlockfile -from portage.output import red +from portage.output import red, colorize from portage.util import writemsg from portage import auxdbkeys, dep_expand from portage.versions import catpkgsplit, pkgcmp @@ -196,7 +196,7 @@ pass elif '/-MERGING-' in mypath: if os.path.exists(mypath): - writemsg(red("INCOMPLETE MERGE:")+" "+mypath+"\n", noiselevel=-1) + writemsg(colorize("BAD","INCOMPLETE MERGE:")+" "+mypath+"\n", noiselevel=-1) else: writemsg("!!! Invalid db entry: %s\n" % mypath, noiselevel=-1) --- dbapi/bintree.py.old 2008-12-29 11:51:48.000000000 +0300 +++ dbapi/bintree.py 2009-01-03 17:41:33.000000000 +0300 @@ -9,7 +9,7 @@ from portage.dbapi.virtual import fakedbapi from portage.exception import InvalidPackageName, \ PermissionDenied, PortageException -from portage.output import green, EOutput +from portage.output import green, EOutput, colorize from portage.util import ensure_dirs, normalize_path, writemsg, writemsg_stdout from portage.versions import best, catpkgsplit, catsplit from portage.update import update_dbentries @@ -737,7 +737,7 @@ chunk_size = 3000 writemsg_stdout("\n") writemsg_stdout( - green("Fetching bininfo from ") + \ + colorize("GOOD", "Fetching bininfo from ") + \ re.sub(r'//(.+):.+@(.+)/', r'//\1:*password*@\2/', base_url) + "\n") self.remotepkgs = portage.getbinpkg.dir_get_metadata( self.settings["PORTAGE_BINHOST"], chunk_size=chunk_size) --- dbapi/vartree.py.old 2009-01-03 17:34:54.000000000 +0300 +++ dbapi/vartree.py 2009-01-03 17:43:13.000000000 +0300 @@ -17,7 +17,7 @@ InvalidData, InvalidPackageName, \ FileNotFound, PermissionDenied, UnsupportedAPIException from portage.locks import lockdir, unlockdir -from portage.output import bold, red, green +from portage.output import bold, red, green, colorize from portage.update import fixdbentries from portage.util import apply_secpass_permissions, ConfigProtect, ensure_dirs, \ writemsg, writemsg_level, write_atomic, atomic_ofstream, writedict, \ @@ -1816,8 +1816,8 @@ collisions = [] destroot = normalize_path(destroot).rstrip(os.path.sep) + \ os.path.sep - showMessage("%s checking %d files for package collisions\n" % \ - (green("*"), len(mycontents))) + showMessage(" %s checking %d files for package collisions\n" % \ + (colorize("GOOD", "*"), len(mycontents))) for i, f in enumerate(mycontents): if i % 1000 == 0 and i != 0: showMessage("%d files checked ...\n" % i) @@ -2427,7 +2427,6 @@ showMessage(">>> Original instance of package unmerged safely.\n") if len(others_in_slot) > 1: - from portage.output import colorize showMessage(colorize("WARN", "WARNING:") + " AUTOCLEAN is disabled. This can cause serious" + " problems due to overlapping packages.\n", @@ -2547,12 +2546,12 @@ mystat = os.lstat(mysrc) except OSError, e: writemsg("\n") - writemsg(red("!!! ERROR: There appears to be ")+bold("FILE SYSTEM CORRUPTION.")+red(" A file that is listed\n")) - writemsg(red("!!! as existing is not capable of being stat'd. If you are using an\n")) - writemsg(red("!!! experimental kernel, please boot into a stable one, force an fsck,\n")) - writemsg(red("!!! and ensure your filesystem is in a sane state. ")+bold("'shutdown -Fr now'\n")) - writemsg(red("!!! File: ")+str(mysrc)+"\n", noiselevel=-1) - writemsg(red("!!! Error: ")+str(e)+"\n", noiselevel=-1) + writemsg(colorize("BAD","!!! ERROR: There appears to be ")+bold("FILE SYSTEM CORRUPTION.")+colorize("BAD"," A file that is listed\n")) + writemsg(colorize("BAD","!!! as existing is not capable of being stat'd. If you are using an\n")) + writemsg(colorize("BAD","!!! experimental kernel, please boot into a stable one, force an fsck,\n")) + writemsg(colorize("BAD","!!! and ensure your filesystem is in a sane state. ")+bold("'shutdown -Fr now'\n")) + writemsg(colorize("BAD","!!! File: ")+str(mysrc)+"\n", noiselevel=-1) + writemsg(colorize("BAD","!!! Error: ")+str(e)+"\n", noiselevel=-1) return 1 mymode = mystat[stat.ST_MODE] --- getbinpkg.py.old 2008-12-29 11:51:47.000000000 +0300 +++ getbinpkg.py 2009-01-03 17:48:08.000000000 +0300 @@ -22,12 +22,12 @@ try: import ftplib except ImportError, e: - sys.stderr.write(red("!!! CANNOT IMPORT FTPLIB: ")+str(e)+"\n") + sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT FTPLIB: ")+str(e)+"\n") try: import httplib except ImportError, e: - sys.stderr.write(red("!!! CANNOT IMPORT HTTPLIB: ")+str(e)+"\n") + sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT HTTPLIB: ")+str(e)+"\n") def make_metadata_dict(data): myid,myglob = data @@ -139,7 +139,7 @@ if password: conn.login(username,password) else: - sys.stderr.write(yellow(" * No password provided for username")+" '"+str(username)+"'\n\n") + sys.stderr.write(colorize("WARN"," * No password provided for username")+" '"+str(username)+"'\n\n") conn.login(username) conn.set_pasv(passive) conn.set_debuglevel(0) @@ -231,9 +231,9 @@ parts = x.split(": ",1) if parts[0] == "Location": if (rc == 301): - sys.stderr.write(red("Location has moved: ")+str(parts[1])+"\n") + sys.stderr.write(colorize("BAD","Location has moved: ")+str(parts[1])+"\n") if (rc == 302): - sys.stderr.write(red("Location has temporarily moved: ")+str(parts[1])+"\n") + sys.stderr.write(colorize("BAD","Location has temporarily moved: ")+str(parts[1])+"\n") address = parts[1] break @@ -587,8 +587,8 @@ self.last_update = cur_time self.display() def display(self): - self.out.write("\r"+yellow("cache miss: '"+str(self.misses)+"'")+\ - " --- "+green("cache hit: '"+str(self.hits)+"'")) + self.out.write("\r"+colorize("WARN","cache miss: '"+str(self.misses)+"'")+\ + " --- "+colorize("GOOD","cache hit: '"+str(self.hits)+"'")) self.out.flush() cache_stats = CacheStats(out) @@ -630,7 +630,7 @@ if myid and myid[0]: metadata[baseurl]["data"][x] = make_metadata_dict(myid) elif verbose: - sys.stderr.write(red("!!! Failed to retrieve metadata on: ")+str(x)+"\n") + sys.stderr.write(colorize("BAD","!!! Failed to retrieve metadata on: ")+str(x)+"\n") sys.stderr.flush() else: cache_stats.hits += 1