summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-01-09 02:18:42 +0000
committerZac Medico <zmedico@gentoo.org>2009-01-09 02:18:42 +0000
commit6afefabfb5f442a6844cf60664bf0516f661106d (patch)
tree627b52f407558fbf35d88bbafac646ca7f711bd7
parentAdd some blank lines around the messages that suggest --without-mask and (diff)
downloadportage-multirepo-6afefabfb5f442a6844cf60664bf0516f661106d.tar.gz
portage-multirepo-6afefabfb5f442a6844cf60664bf0516f661106d.tar.bz2
portage-multirepo-6afefabfb5f442a6844cf60664bf0516f661106d.zip
Bug #253563 - Replace hardcoded green/red color strings with GOOD/BAD. Thanks
to Vsevolod Kozlov <sevakda@gmail.com> for the initial patch. svn path=/main/trunk/; revision=12401
-rw-r--r--pym/portage/__init__.py25
-rw-r--r--pym/portage/data.py26
-rw-r--r--pym/portage/dbapi/__init__.py5
-rw-r--r--pym/portage/dbapi/bintree.py4
-rw-r--r--pym/portage/dbapi/vartree.py20
-rw-r--r--pym/portage/getbinpkg.py25
6 files changed, 52 insertions, 53 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 75398038..2c807287 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2526,8 +2526,9 @@ class config(object):
if x[0]=="+":
# Not legal. People assume too much. Complain.
- writemsg(red("USE flags should not start with a '+': %s\n" % x),
- noiselevel=-1)
+ writemsg(colorize("BAD",
+ "USE flags should not start with a '+': %s" % x) \
+ + "\n", noiselevel=-1)
x=x[1:]
if not x:
continue
@@ -3423,7 +3424,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
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)
@@ -7215,16 +7217,16 @@ def deprecated_profile_check(settings=None):
deprecatedfile = open(deprecated_profile_file, "r")
dcontent = deprecatedfile.readlines()
deprecatedfile.close()
- writemsg(red("\n!!! Your current profile is deprecated and not supported anymore.\n"),
- noiselevel=-1)
+ 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"),
- noiselevel=-1)
+ 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"),
- noiselevel=-1)
- writemsg(8*" "+green(newprofile)+"\n", noiselevel=-1)
+ writemsg(colorize("BAD", "!!! Please upgrade to the " + \
+ "following profile if possible:") + "\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:]:
@@ -7304,7 +7306,8 @@ def _global_updates(trees, prev_mtimes):
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("#") + \
diff --git a/pym/portage/data.py b/pym/portage/data.py
index 5f4d0563..a7ebd9cb 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -5,7 +5,7 @@
import os, sys, pwd, grp, platform
from portage.util import writemsg
-from portage.output import green,red
+from portage.output import colorize
from portage.output import create_color_func
bad = create_color_func("BAD")
@@ -28,7 +28,8 @@ if not lchown:
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()
@@ -78,17 +79,16 @@ try:
except KeyError:
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( " 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("\n")
+ writemsg(colorize("BAD",
+ "portage: 'portage' user or group missing.") + "\n", noiselevel=-1)
+ writemsg(
+ " For the defaults, line 1 goes into passwd, " + \
+ "and 2 into group.\n", noiselevel=-1)
+ writemsg(colorize("GOOD",
+ " portage:x:250:250:portage:/var/tmp/portage:/bin/false") \
+ + "\n", noiselevel=-1)
+ writemsg(colorize("GOOD", " portage::250:portage") + "\n",
+ noiselevel=-1)
portage_group_warning()
userpriv_groups = [portage_gid]
diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py
index 435ffebb..cdae9457 100644
--- a/pym/portage/dbapi/__init__.py
+++ b/pym/portage/dbapi/__init__.py
@@ -8,7 +8,7 @@ import os
import re
from portage.dep import match_from_list
from portage.locks import unlockfile
-from portage.output import red
+from portage.output import colorize
from portage.util import writemsg
from portage import auxdbkeys, dep_expand
from portage.versions import catpkgsplit, pkgcmp
@@ -196,7 +196,8 @@ class dbapi(object):
pass
elif '/-MERGING-' in mypath:
if os.path.exists(mypath):
- writemsg(red("INCOMPLETE MERGE:")+" "+mypath+"\n", noiselevel=-1)
+ writemsg(colorize("BAD","INCOMPLETE MERGE:")+" %s\n" % mypath,
+ noiselevel=-1)
else:
writemsg("!!! Invalid db entry: %s\n" % mypath, noiselevel=-1)
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 9b6953b7..7f2c0cbf 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -9,7 +9,7 @@ from portage.dep import isvalidatom, isjustname, dep_getkey, match_from_list
from portage.dbapi.virtual import fakedbapi
from portage.exception import InvalidPackageName, \
PermissionDenied, PortageException
-from portage.output import green, EOutput
+from portage.output import 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 @@ class binarytree(object):
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)
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index a9575525..b7cee710 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -17,7 +17,7 @@ from portage.exception import CommandNotFound, \
InvalidData, InvalidPackageName, \
FileNotFound, PermissionDenied, UnsupportedAPIException
from portage.locks import lockdir, unlockdir
-from portage.output import bold, red, green
+from portage.output import bold, colorize
from portage.update import fixdbentries
from portage.util import apply_secpass_permissions, ConfigProtect, ensure_dirs, \
writemsg, writemsg_level, write_atomic, atomic_ofstream, writedict, \
@@ -2817,8 +2817,8 @@ class dblink(object):
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)
@@ -3452,7 +3452,6 @@ class dblink(object):
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",
@@ -3602,18 +3601,7 @@ class dblink(object):
# myrealdest is mydest without the $ROOT prefix (makes a difference if ROOT!="/")
myrealdest = join(sep, offset, x)
# stat file once, test using S_* macros many times (faster that way)
- try:
- 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)
- return 1
-
+ mystat = os.lstat(mysrc)
mymode = mystat[stat.ST_MODE]
# handy variables; mydest is the target object on the live filesystems;
# mysrc is the source object in the temporary install dir
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index cd1bd0dc..9d59437b 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -3,7 +3,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-from portage.output import red, yellow, green
+from portage.output import colorize
from portage.cache.mappings import slot_dict_class
import portage.xpak
import HTMLParser
@@ -22,12 +22,12 @@ except ImportError:
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,9 @@ def create_conn(baseurl,conn=None):
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")+" '%s'" % \
+ (username,) + "\n\n")
conn.login(username)
conn.set_pasv(passive)
conn.set_debuglevel(0)
@@ -231,9 +233,12 @@ def make_http_request(conn, address, params={}, headers={}, dest=None):
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 +592,9 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
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 +636,8 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
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