Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2008-12-18 08:49:43 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2008-12-19 23:50:57 (GMT)
commitebe5a869f2a3304d7ab3148bd39a8bfd023ff84c (patch)
tree7a3cfbe023c68f7f5768b032d60cbac442ecad63
parentd6ba40c9b568a99d1fb8e459cb9497cfffd3e981 (diff)
use env variables to setup debug flags
-rw-r--r--TamTamJam.activity/TamTamJam.py5
-rw-r--r--TamTamSynthLab.activity/TamTamSynthLab.py5
-rw-r--r--common/Config.py21
-rw-r--r--common/Util/CSoundClient.py7
4 files changed, 18 insertions, 20 deletions
diff --git a/TamTamJam.activity/TamTamJam.py b/TamTamJam.activity/TamTamJam.py
index f85899d..f296e0d 100644
--- a/TamTamJam.activity/TamTamJam.py
+++ b/TamTamJam.activity/TamTamJam.py
@@ -4,6 +4,7 @@ import signal , time , sys , os, shutil
import pygtk
pygtk.require( '2.0' )
import gtk
+import logging
import gobject
import time
@@ -81,11 +82,11 @@ class TamTamJam(activity.Activity):
def onActive(self, widget = None, event = None):
if widget.props.active == False:
- Config.logwrite(1, 'Jam.onActivate disconnecting csound')
+ logging.debug('Jam.onActivate disconnecting csound')
csnd = new_csound_client()
csnd.connect(False)
else:
- Config.logwrite(1, 'Jam.onActivate connecting csound')
+ logging.debug('Jam.onActivate connecting csound')
csnd = new_csound_client()
csnd.connect(True)
diff --git a/TamTamSynthLab.activity/TamTamSynthLab.py b/TamTamSynthLab.activity/TamTamSynthLab.py
index 36ea0e0..4f74c78 100644
--- a/TamTamSynthLab.activity/TamTamSynthLab.py
+++ b/TamTamSynthLab.activity/TamTamSynthLab.py
@@ -4,6 +4,7 @@ import signal , time , sys , os, shutil
import pygtk
pygtk.require( '2.0' )
import gtk
+import logging
import gobject
import time
@@ -81,11 +82,11 @@ class TamTamSynthLab(activity.Activity):
def onActive(self, widget = None, event = None):
if widget.props.active == False:
- Config.logwrite(1, 'TamTamSynthLab.onActivate disconnecting csound')
+ logging.debug('TamTamSynthLab.onActivate disconnecting csound')
csnd = new_csound_client()
csnd.connect(False)
else:
- Config.logwrite(1, 'TamTamSynthLab.onActivate connecting csound')
+ logging.debug(1, 'TamTamSynthLab.onActivate connecting csound')
csnd = new_csound_client()
csnd.connect(True)
diff --git a/common/Config.py b/common/Config.py
index 72ae993..7fe8371 100644
--- a/common/Config.py
+++ b/common/Config.py
@@ -2,6 +2,7 @@
import os, sys, time
from sugar.activity.activity import get_bundle_path, get_activity_root
from sugar import env
+import logging
#QUICKLOAD = os.path.isfile("QUICKLOAD") # skip loading inessential comenents to speed things up
@@ -17,21 +18,12 @@ if os.path.isfile("DEBUG"):
if len(l): DEBUG = int( l )
else: DEBUG = 99
else:
- DEBUG = 0
-print "Debug Level %d" % (DEBUG)
-
-# TODO: move this into a logging file in Util/
-# TODO: consider python's logging utility from the stdlib
-def logwrite(level, msg):
- global DEBUG
- if level <= DEBUG:
- if not hasattr(logwrite, 'file'):
- logwrite.file = sys.stdout
- print >> logwrite.file, 'L%i:%f: %s'% (level, time.time(), msg)
- logwrite.file.flush()
+ DEBUG = int(os.getenv("TAMTAM_DEBUG", "0"))
+
+logging.debug("Debug Level %d" % (DEBUG))
TAM_TAM_ROOT = get_bundle_path()
-print 'INFO: loaded TAMTAM_ROOT=%s' % TAM_TAM_ROOT
+logging.debug('INFO: loaded TAMTAM_ROOT=%s' % TAM_TAM_ROOT)
#PATHS
if XO:
@@ -55,7 +47,8 @@ for i in (INSTANCE_DIR, DATA_DIR, SNDS_INFO_DIR, TMP_DIR):
if not os.path.isdir(i): os.makedirs(i)
#PLUGIN
-PLUGIN_DEBUG = "STDERR"
+PLUGIN_DEBUG = os.getenv("CSOUND_LOGFILE")
+if PLUGIN_DEBUG == "": PLUGIN_DEBUG = "STDERR"
PLUGIN_VERBOSE = DEBUG
PLUGIN_UNIVORC = os.path.join(FILES_DIR, "tamtamorc.csd")
PLUGIN_KSMPS = 64
diff --git a/common/Util/CSoundClient.py b/common/Util/CSoundClient.py
index 2ce3238..1fee0cb 100644
--- a/common/Util/CSoundClient.py
+++ b/common/Util/CSoundClient.py
@@ -104,9 +104,12 @@ class _CSoundClientPlugin:
def load_instrument(self, inst):
if not inst in loadedInstruments:
if inst[0:3] == 'mic' or inst[0:3] == 'lab' or self.instrumentDB.instNamed[inst].category == 'mysounds':
- fileName = Config.DATA_DIR + '/' + inst
+ if os.path.isfile(os.path.join(Config.DATA_DIR, inst)):
+ fileName = os.path.join(Config.DATA_DIR, inst)
+ else:
+ fileName = os.path.join(Config.SOUNDS_DIR, 'armbone')
else:
- fileName = Config.SOUNDS_DIR + "/" + inst
+ fileName = os.path.join(Config.SOUNDS_DIR, inst)
instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[ inst ].instrumentId
sc_inputMessage( Config.CSOUND_LOAD_INSTRUMENT % (instrumentId, fileName) )
loadedInstruments.append(inst)