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
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)
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:]:
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("#") + \
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")
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()
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]
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
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)
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
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)
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, \
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)
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",
# 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
# 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
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
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)
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
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)
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