summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2007-02-11 01:13:56 +0000
committerMarius Mauch <genone@gentoo.org>2007-02-11 01:13:56 +0000
commit54421fd308149c4b6623557f072a64131bd728ab (patch)
tree902f4eae8a0cbbc8bd7196988387332658b698e4
parent7b492bc9dec901aa1e94e09a8d8e1dfb0f2478f8 (diff)
downloadportage-54421fd308149c4b6623557f072a64131bd728ab.tar.gz
portage-54421fd308149c4b6623557f072a64131bd728ab.tar.bz2
portage-54421fd308149c4b6623557f072a64131bd728ab.zip
Make subpackage naming consistent
svn path=/main/trunk/; revision=5955
l---------pym/elog_modules2
-rw-r--r--pym/portage/__init__.py104
-rw-r--r--pym/portage/dbapi/vartree.py3
-rw-r--r--pym/portage/elog/__init__.py111
-rw-r--r--pym/portage/elog/mod_custom.py (renamed from pym/portage/elog_modules/mod_custom.py)0
-rw-r--r--pym/portage/elog/mod_mail.py (renamed from pym/portage/elog_modules/mod_mail.py)0
-rw-r--r--pym/portage/elog/mod_mail_summary.py (renamed from pym/portage/elog_modules/mod_mail_summary.py)0
-rw-r--r--pym/portage/elog/mod_save.py (renamed from pym/portage/elog_modules/mod_save.py)0
-rw-r--r--pym/portage/elog/mod_save_summary.py (renamed from pym/portage/elog_modules/mod_save_summary.py)0
-rw-r--r--pym/portage/elog/mod_syslog.py (renamed from pym/portage/elog_modules/mod_syslog.py)0
-rw-r--r--pym/portage/elog_modules/__init__.py0
11 files changed, 114 insertions, 106 deletions
diff --git a/pym/elog_modules b/pym/elog_modules
index 32f0ca7fb..6b14e4bbf 120000
--- a/pym/elog_modules
+++ b/pym/elog_modules
@@ -1 +1 @@
-portage/elog_modules \ No newline at end of file
+portage/elog \ No newline at end of file
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 7f0ed6fd3..ff5b319c2 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -458,110 +458,6 @@ class digraph:
print "(%s)" % self.nodes[node][0][child]
-_elog_atexit_handlers = []
-def elog_process(cpv, mysettings):
- mylogfiles = listdir(mysettings["T"]+"/logging/")
- # shortcut for packages without any messages
- if len(mylogfiles) == 0:
- return
- # exploit listdir() file order so we process log entries in chronological order
- mylogfiles.reverse()
- all_logentries = {}
- for f in mylogfiles:
- msgfunction, msgtype = f.split(".")
- if msgfunction not in portage.const.EBUILD_PHASES:
- writemsg("!!! can't process invalid log file: %s\n" % f,
- noiselevel=-1)
- continue
- if not msgfunction in all_logentries:
- all_logentries[msgfunction] = []
- msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines()
- all_logentries[msgfunction].append((msgtype, msgcontent))
-
- def filter_loglevels(logentries, loglevels):
- # remove unwanted entries from all logentries
- rValue = {}
- loglevels = map(str.upper, loglevels)
- for phase in logentries.keys():
- for msgtype, msgcontent in logentries[phase]:
- if msgtype.upper() in loglevels or "*" in loglevels:
- if not rValue.has_key(phase):
- rValue[phase] = []
- rValue[phase].append((msgtype, msgcontent))
- return rValue
-
- my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
- default_logentries = filter_loglevels(all_logentries, my_elog_classes)
-
- # in case the filters matched all messages and no module overrides exist
- if len(default_logentries) == 0 and (not ":" in mysettings.get("PORTAGE_ELOG_SYSTEM", "")):
- return
-
- def combine_logentries(logentries):
- # generate a single string with all log messages
- rValue = ""
- for phase in portage.const.EBUILD_PHASES:
- if not phase in logentries:
- continue
- for msgtype,msgcontent in logentries[phase]:
- rValue += "%s: %s\n" % (msgtype, phase)
- for line in msgcontent:
- rValue += line
- rValue += "\n"
- return rValue
-
- default_fulllog = combine_logentries(default_logentries)
-
- # pass the processing to the individual modules
- logsystems = mysettings["PORTAGE_ELOG_SYSTEM"].split()
- for s in logsystems:
- # allow per module overrides of PORTAGE_ELOG_CLASSES
- if ":" in s:
- s, levels = s.split(":", 1)
- levels = levels.split(",")
- mod_logentries = filter_loglevels(all_logentries, levels)
- mod_fulllog = combine_logentries(mod_logentries)
- else:
- mod_logentries = default_logentries
- mod_fulllog = default_fulllog
- if len(mod_logentries) == 0:
- continue
- # - is nicer than _ for module names, so allow people to use it.
- s = s.replace("-", "_")
- try:
- # FIXME: ugly ad.hoc import code
- # TODO: implement a common portage module loader
- logmodule = __import__("portage.elog_modules.mod_"+s)
- m = getattr(logmodule, "mod_"+s)
- def timeout_handler(signum, frame):
- raise portage.exception.PortageException(
- "Timeout in elog_process for system '%s'" % s)
- import signal
- signal.signal(signal.SIGALRM, timeout_handler)
- # Timeout after one minute (in case something like the mail
- # module gets hung).
- signal.alarm(60)
- try:
- m.process(mysettings, cpv, mod_logentries, mod_fulllog)
- finally:
- signal.alarm(0)
- if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers:
- _elog_atexit_handlers.append(m.finalize)
- atexit_register(m.finalize, mysettings)
- except (ImportError, AttributeError), e:
- writemsg("!!! Error while importing logging modules " + \
- "while loading \"mod_%s\":\n" % str(s))
- writemsg("%s\n" % str(e), noiselevel=-1)
- except portage.exception.PortageException, e:
- writemsg("%s\n" % str(e), noiselevel=-1)
-
- # clean logfiles to avoid repetitions
- for f in mylogfiles:
- try:
- os.unlink(os.path.join(mysettings["T"], "logging", f))
- except OSError:
- pass
-
#parse /etc/env.d and generate /etc/profile.env
def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 1e2cceac5..4afe4a247 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -4,6 +4,7 @@ from portage.data import portage_gid, portage_uid
from portage.dbapi import dbapi
from portage.dep import dep_getslot, use_reduce, paren_reduce, isvalidatom, \
isjustname, dep_getkey, match_from_list
+from portage.elog import elog_process
from portage.exception import InvalidPackageName, InvalidAtom, \
UnsupportedAPIException, FileNotFound
from portage.locks import lockdir, unlockdir
@@ -15,7 +16,7 @@ from portage.util import apply_secpass_permissions, ConfigProtect, ensure_dirs,
from portage.versions import pkgsplit, catpkgsplit, catsplit, best, pkgcmp
from portage import listdir, dep_expand, config, flatten, key_expand, \
- doebuild_environment, doebuild, elog_process, env_update, dircache, \
+ doebuild_environment, doebuild, env_update, dircache, \
abssymlink, movefile, bsd_chflags
import os, sys, stat, cPickle, errno, commands, copy, time
diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py
new file mode 100644
index 000000000..5ba49793d
--- /dev/null
+++ b/pym/portage/elog/__init__.py
@@ -0,0 +1,111 @@
+from portage.const import EBUILD_PHASES
+from portage.exception import PortageException
+from portage.process import atexit_register
+from portage.util import writemsg
+
+from portage import listdir
+
+import os
+
+_elog_atexit_handlers = []
+def elog_process(cpv, mysettings):
+ mylogfiles = listdir(mysettings["T"]+"/logging/")
+ # shortcut for packages without any messages
+ if len(mylogfiles) == 0:
+ return
+ # exploit listdir() file order so we process log entries in chronological order
+ mylogfiles.reverse()
+ all_logentries = {}
+ for f in mylogfiles:
+ msgfunction, msgtype = f.split(".")
+ if msgfunction not in EBUILD_PHASES:
+ writemsg("!!! can't process invalid log file: %s\n" % f,
+ noiselevel=-1)
+ continue
+ if not msgfunction in all_logentries:
+ all_logentries[msgfunction] = []
+ msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines()
+ all_logentries[msgfunction].append((msgtype, msgcontent))
+
+ def filter_loglevels(logentries, loglevels):
+ # remove unwanted entries from all logentries
+ rValue = {}
+ loglevels = map(str.upper, loglevels)
+ for phase in logentries.keys():
+ for msgtype, msgcontent in logentries[phase]:
+ if msgtype.upper() in loglevels or "*" in loglevels:
+ if not rValue.has_key(phase):
+ rValue[phase] = []
+ rValue[phase].append((msgtype, msgcontent))
+ return rValue
+
+ my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
+ default_logentries = filter_loglevels(all_logentries, my_elog_classes)
+
+ # in case the filters matched all messages and no module overrides exist
+ if len(default_logentries) == 0 and (not ":" in mysettings.get("PORTAGE_ELOG_SYSTEM", "")):
+ return
+
+ def combine_logentries(logentries):
+ # generate a single string with all log messages
+ rValue = ""
+ for phase in EBUILD_PHASES:
+ if not phase in logentries:
+ continue
+ for msgtype, msgcontent in logentries[phase]:
+ rValue += "%s: %s\n" % (msgtype, phase)
+ for line in msgcontent:
+ rValue += line
+ rValue += "\n"
+ return rValue
+
+ default_fulllog = combine_logentries(default_logentries)
+
+ # pass the processing to the individual modules
+ logsystems = mysettings["PORTAGE_ELOG_SYSTEM"].split()
+ for s in logsystems:
+ # allow per module overrides of PORTAGE_ELOG_CLASSES
+ if ":" in s:
+ s, levels = s.split(":", 1)
+ levels = levels.split(",")
+ mod_logentries = filter_loglevels(all_logentries, levels)
+ mod_fulllog = combine_logentries(mod_logentries)
+ else:
+ mod_logentries = default_logentries
+ mod_fulllog = default_fulllog
+ if len(mod_logentries) == 0:
+ continue
+ # - is nicer than _ for module names, so allow people to use it.
+ s = s.replace("-", "_")
+ try:
+ # FIXME: ugly ad.hoc import code
+ # TODO: implement a common portage module loader
+ logmodule = __import__("portage.elog.mod_"+s)
+ m = getattr(logmodule, "mod_"+s)
+ def timeout_handler(signum, frame):
+ raise PortageException("Timeout in elog_process for system '%s'" % s)
+ import signal
+ signal.signal(signal.SIGALRM, timeout_handler)
+ # Timeout after one minute (in case something like the mail
+ # module gets hung).
+ signal.alarm(60)
+ try:
+ m.process(mysettings, cpv, mod_logentries, mod_fulllog)
+ finally:
+ signal.alarm(0)
+ if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers:
+ _elog_atexit_handlers.append(m.finalize)
+ atexit_register(m.finalize, mysettings)
+ except (ImportError, AttributeError), e:
+ writemsg("!!! Error while importing logging modules " + \
+ "while loading \"mod_%s\":\n" % str(s))
+ writemsg("%s\n" % str(e), noiselevel=-1)
+ except portage.exception.PortageException, e:
+ writemsg("%s\n" % str(e), noiselevel=-1)
+
+ # clean logfiles to avoid repetitions
+ for f in mylogfiles:
+ try:
+ os.unlink(os.path.join(mysettings["T"], "logging", f))
+ except OSError:
+ pass
diff --git a/pym/portage/elog_modules/mod_custom.py b/pym/portage/elog/mod_custom.py
index 5fae84078..5fae84078 100644
--- a/pym/portage/elog_modules/mod_custom.py
+++ b/pym/portage/elog/mod_custom.py
diff --git a/pym/portage/elog_modules/mod_mail.py b/pym/portage/elog/mod_mail.py
index b84555e8c..b84555e8c 100644
--- a/pym/portage/elog_modules/mod_mail.py
+++ b/pym/portage/elog/mod_mail.py
diff --git a/pym/portage/elog_modules/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py
index 99c285642..99c285642 100644
--- a/pym/portage/elog_modules/mod_mail_summary.py
+++ b/pym/portage/elog/mod_mail_summary.py
diff --git a/pym/portage/elog_modules/mod_save.py b/pym/portage/elog/mod_save.py
index 2993b45db..2993b45db 100644
--- a/pym/portage/elog_modules/mod_save.py
+++ b/pym/portage/elog/mod_save.py
diff --git a/pym/portage/elog_modules/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index eb453e587..eb453e587 100644
--- a/pym/portage/elog_modules/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
diff --git a/pym/portage/elog_modules/mod_syslog.py b/pym/portage/elog/mod_syslog.py
index 77e1d4ea6..77e1d4ea6 100644
--- a/pym/portage/elog_modules/mod_syslog.py
+++ b/pym/portage/elog/mod_syslog.py
diff --git a/pym/portage/elog_modules/__init__.py b/pym/portage/elog_modules/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/pym/portage/elog_modules/__init__.py
+++ /dev/null