[pitivi] tests: Simplify the no color logging setting



commit 40a3f236c3307c9a58f7ec45107470cce4462e23
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Jan 29 13:17:30 2014 +0100

    tests: Simplify the no color logging setting

 pitivi/application.py    |   12 +++---------
 pitivi/utils/loggable.py |   14 ++++----------
 tests/runtests.py        |    2 +-
 3 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index ae8d683..d276a46 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -95,13 +95,10 @@ class Pitivi(Loggable, Signallable):
         "shutdown": None}
 
     def __init__(self):
-        """
-        initialize pitivi with the command line arguments
-        """
         Loggable.__init__(self)
 
-        # init logging as early as possible so we can log startup code
-        enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0')
+        # Init logging as early as possible so we can log startup code
+        enable_color = not os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '1')
         # Let's show a human-readable pitivi debug output by default, and only
         # show a crazy unreadable mess when surrounded by gst debug statements.
         enable_crack_output = "GST_DEBUG" in os.environ
@@ -109,15 +106,12 @@ class Pitivi(Loggable, Signallable):
 
         self.info('starting up')
 
-        self.current_project = None
-
-        # get settings
         self.settings = GlobalSettings()
         self.threads = ThreadMaster()
-
         self.effects = EffectsHandler()
         self.system = getSystem()
 
+        self.current_project = None
         self.projectManager = ProjectManager(self)
         self._connectToProjectManager(self.projectManager)
 
diff --git a/pitivi/utils/loggable.py b/pitivi/utils/loggable.py
index 7678fae..0ab28f7 100644
--- a/pitivi/utils/loggable.py
+++ b/pitivi/utils/loggable.py
@@ -660,13 +660,10 @@ def stderrHandler(level, object, category, file, line, message):
     sys.stderr.flush()
 
 
-def _preformatLevels(noColorEnvVarName):
+def _preformatLevels(enableColorOutput):
     format = '%-5s'
 
-    if (noColorEnvVarName is not None
-        and (noColorEnvVarName not in os.environ
-             or not os.environ[noColorEnvVarName])):
-
+    if enableColorOutput:
         t = TerminalController()
         formatter = lambda level: ''.join((t.BOLD, getattr(t, COLORS[level]),
                             format % (_LEVEL_NAMES[level - 1], ), t.NORMAL))
@@ -681,7 +678,7 @@ def _preformatLevels(noColorEnvVarName):
 # setup functions
 
 
-def init(envVarName, enableColorOutput=False, enableCrackOutput=True):
+def init(envVarName, enableColorOutput=True, enableCrackOutput=True):
     """
     Initialize the logging system and parse the environment variable
     of the given name.
@@ -697,10 +694,7 @@ def init(envVarName, enableColorOutput=False, enableCrackOutput=True):
     global _ENV_VAR_NAME
     _ENV_VAR_NAME = envVarName
 
-    if enableColorOutput:
-        _preformatLevels(envVarName + "_NO_COLOR")
-    else:
-        _preformatLevels(None)
+    _preformatLevels(enableColorOutput)
 
     if envVarName in os.environ:
         # install a log handler that uses the value of the environment var
diff --git a/tests/runtests.py b/tests/runtests.py
index ed5dd95..aa25aed 100644
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -68,7 +68,7 @@ if __name__ == "__main__":
         descriptions = 2
         verbosity = 2
     from pitivi.utils import loggable as log
-    log.init('PITIVI_DEBUG', 1)
+    log.init('PITIVI_DEBUG')
 
     suite = _tests_suite()
     if not list(suite):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]