[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Mon Sep 6 22:58:57 PDT 2010


hg Repository: yt
details:   yt/rev/fd25cac2f363
changeset: 3383:fd25cac2f363
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Sep 06 13:35:34 2010 -0700
description:
Adding an option to instinfo to output the current version to a text file

hg Repository: yt
details:   yt/rev/550185a0c7fd
changeset: 3384:550185a0c7fd
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Sep 06 22:58:23 2010 -0700
description:
Removed old loggers, made the whole thing more straightforward, and this will
close #187.

diffstat:

 yt/analysis_modules/light_ray/light_ray.py |   1 -
 yt/utilities/command_line.py               |   5 ++
 yt/utilities/logger.py                     |  37 ++----------------
 3 files changed, 10 insertions(+), 33 deletions(-)

diffs (93 lines):

diff -r b217f1ee3103 -r 550185a0c7fd yt/analysis_modules/light_ray/light_ray.py
--- a/yt/analysis_modules/light_ray/light_ray.py	Fri Sep 03 23:22:26 2010 -0700
+++ b/yt/analysis_modules/light_ray/light_ray.py	Mon Sep 06 22:58:23 2010 -0700
@@ -44,7 +44,6 @@
 from yt.analysis_modules.halo_profiler.multi_halo_profiler import \
     HaloProfiler
 from yt.convenience import load
-from yt.utilities.logger import lagosLogger as mylog
 
 class LightRay(EnzoSimulation):
     def __init__(self, EnzoParameterFile, FinalRedshift, InitialRedshift, 
diff -r b217f1ee3103 -r 550185a0c7fd yt/utilities/command_line.py
--- a/yt/utilities/command_line.py	Fri Sep 03 23:22:26 2010 -0700
+++ b/yt/utilities/command_line.py	Mon Sep 06 22:58:23 2010 -0700
@@ -323,6 +323,9 @@
     @cmdln.option("-u", "--update-source", action="store_true",
                   default = False,
                   help="Update the yt installation, if able")
+    @cmdln.option("-o", "--output-version", action="store",
+                  default = None, dest="outputfile",
+                  help="File into which the current revision number will be stored")
     def do_instinfo(self, subcmd, opts):
         """
         ${cmd_name}: Get some information about the yt installation
@@ -350,6 +353,8 @@
             if opts.update_source:  
                 _vcs_updater[vc_type](path)
             print "Updated successfully."
+        if vstring is not None and opts.outputfile is not None:
+            open(opts.outputfile, "w").write(vstring)
 
     def do_load(self, subcmd, opts, arg):
         """
diff -r b217f1ee3103 -r 550185a0c7fd yt/utilities/logger.py
--- a/yt/utilities/logger.py	Fri Sep 03 23:22:26 2010 -0700
+++ b/yt/utilities/logger.py	Mon Sep 06 22:58:23 2010 -0700
@@ -51,9 +51,6 @@
         return fn(*args)
     return new
 
-if ytcfg.getboolean("yt","coloredlogs"):
-    logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit)
-
 level = min(max(ytcfg.getint("yt", "loglevel"), 0), 50)
 fstring = "%(name)-10s %(levelname)-10s %(asctime)s %(message)s"
 logging.basicConfig(
@@ -68,41 +65,17 @@
 ytLogger = logging.getLogger("yt")
 ytLogger.debug("Set log level to %s", level)
 
-fidoLogger = logging.getLogger("yt.fido")
-ravenLogger = logging.getLogger("yt.raven")
-lagosLogger = logging.getLogger("yt.lagos")
-enkiLogger = logging.getLogger("yt.enki")
-deliveratorLogger = logging.getLogger("yt.deliverator")
-reasonLogger = logging.getLogger("yt.reason")
-
-# Maybe some day we'll make this more configurable...  unfortunately, for now,
-# we preserve thread-safety by opening in the current directory.
-
-mb = 10*1024*1024
-bc = 10
-
-loggers = []
-file_handlers = []
-
-if ytcfg.getboolean("yt","logfile") and os.access(".", os.W_OK):
-    log_file_name = ytcfg.get("yt","LogFileName")
-    ytFileHandler = handlers.RotatingFileHandler(log_file_name,
-                                             maxBytes=mb, backupCount=bc)
-    k = logging.Formatter(fstring)
-    ytFileHandler.setFormatter(k)
-    ytLogger.addHandler(ytFileHandler)
-    loggers.append(ytLogger)
-    file_handlers.append(ytFileHandler)
-
 def disable_stream_logging():
     # We just remove the root logger's handlers
     for handler in rootLogger.handlers:
         if isinstance(handler, logging.StreamHandler):
             rootLogger.removeHandler(handler)
 
-def disable_file_logging():
-    for logger, handler in zip(loggers, file_handlers):
-        logger.removeHandler(handler)
+def colorize_logging():
+    logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit)
+
+if ytcfg.getboolean("yt","coloredlogs"):
+    colorize_logging()
 
 if ytcfg.getboolean("yt","suppressStreamLogging"):
     disable_stream_logging()



More information about the yt-svn mailing list